semtimedop(): move compat to native

... and finally kill the sodding compat_convert_timespec()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 44ee4546 a78ee9ed

+33 -53
-9
include/linux/compat.h
··· 171 171 extern int put_compat_itimerspec64(const struct itimerspec64 *its, 172 172 struct compat_itimerspec __user *uits); 173 173 174 - /* 175 - * This function convert a timespec if necessary and returns a *user 176 - * space* pointer. If no conversion is necessary, it returns the 177 - * initial pointer. NULL is a legitimate argument and will always 178 - * output NULL. 179 - */ 180 - extern int compat_convert_timespec(struct timespec __user **, 181 - const void __user *); 182 - 183 174 struct compat_iovec { 184 175 compat_uptr_t iov_base; 185 176 compat_size_t iov_len;
-10
ipc/compat.c
··· 79 79 to->mode = from->mode; 80 80 to->seq = from->seq; 81 81 } 82 - 83 - COMPAT_SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsems, 84 - unsigned, nsops, 85 - const struct compat_timespec __user *, timeout) 86 - { 87 - struct timespec __user *ts64; 88 - if (compat_convert_timespec(&ts64, timeout)) 89 - return -EFAULT; 90 - return sys_semtimedop(semid, tsems, nsops, ts64); 91 - }
+33 -11
ipc/sem.c
··· 1855 1855 return un; 1856 1856 } 1857 1857 1858 - SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, 1859 - unsigned, nsops, const struct timespec __user *, timeout) 1858 + static long do_semtimedop(int semid, struct sembuf __user *tsops, 1859 + unsigned nsops, const struct timespec *timeout) 1860 1860 { 1861 1861 int error = -EINVAL; 1862 1862 struct sem_array *sma; ··· 1887 1887 } 1888 1888 1889 1889 if (timeout) { 1890 - struct timespec _timeout; 1891 - if (copy_from_user(&_timeout, timeout, sizeof(*timeout))) { 1892 - error = -EFAULT; 1893 - goto out_free; 1894 - } 1895 - if (_timeout.tv_sec < 0 || _timeout.tv_nsec < 0 || 1896 - _timeout.tv_nsec >= 1000000000L) { 1890 + if (timeout->tv_sec < 0 || timeout->tv_nsec < 0 || 1891 + timeout->tv_nsec >= 1000000000L) { 1897 1892 error = -EINVAL; 1898 1893 goto out_free; 1899 1894 } 1900 - jiffies_left = timespec_to_jiffies(&_timeout); 1895 + jiffies_left = timespec_to_jiffies(timeout); 1901 1896 } 1902 1897 1903 1898 max = 0; ··· 2107 2112 return error; 2108 2113 } 2109 2114 2115 + SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, 2116 + unsigned, nsops, const struct timespec __user *, timeout) 2117 + { 2118 + if (timeout) { 2119 + struct timespec ts; 2120 + if (copy_from_user(&ts, timeout, sizeof(*timeout))) 2121 + return -EFAULT; 2122 + return do_semtimedop(semid, tsops, nsops, &ts); 2123 + } 2124 + return do_semtimedop(semid, tsops, nsops, NULL); 2125 + } 2126 + 2127 + #ifdef CONFIG_COMPAT 2128 + COMPAT_SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsems, 2129 + unsigned, nsops, 2130 + const struct compat_timespec __user *, timeout) 2131 + { 2132 + if (timeout) { 2133 + struct timespec ts; 2134 + if (compat_get_timespec(&ts, timeout)) 2135 + return -EFAULT; 2136 + return do_semtimedop(semid, tsems, nsops, &ts); 2137 + } 2138 + return do_semtimedop(semid, tsems, nsops, NULL); 2139 + } 2140 + #endif 2141 + 2110 2142 SYSCALL_DEFINE3(semop, int, semid, struct sembuf __user *, tsops, 2111 2143 unsigned, nsops) 2112 2144 { 2113 - return sys_semtimedop(semid, tsops, nsops, NULL); 2145 + return do_semtimedop(semid, tsops, nsops, NULL); 2114 2146 } 2115 2147 2116 2148 /* If CLONE_SYSVSEM is set, establish sharing of SEM_UNDO state between
-23
kernel/compat.c
··· 200 200 } 201 201 EXPORT_SYMBOL_GPL(compat_put_timespec); 202 202 203 - int compat_convert_timespec(struct timespec __user **kts, 204 - const void __user *cts) 205 - { 206 - struct timespec ts; 207 - struct timespec __user *uts; 208 - 209 - if (!cts || COMPAT_USE_64BIT_TIME) { 210 - *kts = (struct timespec __user *)cts; 211 - return 0; 212 - } 213 - 214 - uts = compat_alloc_user_space(sizeof(ts)); 215 - if (!uts) 216 - return -EFAULT; 217 - if (compat_get_timespec(&ts, cts)) 218 - return -EFAULT; 219 - if (copy_to_user(uts, &ts, sizeof(ts))) 220 - return -EFAULT; 221 - 222 - *kts = uts; 223 - return 0; 224 - } 225 - 226 203 int get_compat_itimerval(struct itimerval *o, const struct compat_itimerval __user *i) 227 204 { 228 205 struct compat_itimerval v32;