summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/v4l2-core/v4l2-compat-ioctl32.c2
-rw-r--r--fs/compat.c6
-rw-r--r--include/linux/compat.h23
-rw-r--r--ipc/compat.c12
-rw-r--r--ipc/compat_mq.c19
-rw-r--r--kernel/compat.c112
-rw-r--r--kernel/futex_compat.c2
7 files changed, 77 insertions, 99 deletions
diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
index 8f7a6a454a4c..6191968db8fa 100644
--- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
+++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
@@ -733,7 +733,7 @@ static int put_v4l2_event32(struct v4l2_event *kp, struct v4l2_event32 __user *u
733 copy_to_user(&up->u, &kp->u, sizeof(kp->u)) || 733 copy_to_user(&up->u, &kp->u, sizeof(kp->u)) ||
734 put_user(kp->pending, &up->pending) || 734 put_user(kp->pending, &up->pending) ||
735 put_user(kp->sequence, &up->sequence) || 735 put_user(kp->sequence, &up->sequence) ||
736 put_compat_timespec(&kp->timestamp, &up->timestamp) || 736 compat_put_timespec(&kp->timestamp, &up->timestamp) ||
737 put_user(kp->id, &up->id) || 737 put_user(kp->id, &up->id) ||
738 copy_to_user(up->reserved, kp->reserved, 8 * sizeof(__u32))) 738 copy_to_user(up->reserved, kp->reserved, 8 * sizeof(__u32)))
739 return -EFAULT; 739 return -EFAULT;
diff --git a/fs/compat.c b/fs/compat.c
index 19252b97f0cc..f86df85dff61 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -92,8 +92,8 @@ COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filena
92 struct timespec tv[2]; 92 struct timespec tv[2];
93 93
94 if (t) { 94 if (t) {
95 if (get_compat_timespec(&tv[0], &t[0]) || 95 if (compat_get_timespec(&tv[0], &t[0]) ||
96 get_compat_timespec(&tv[1], &t[1])) 96 compat_get_timespec(&tv[1], &t[1]))
97 return -EFAULT; 97 return -EFAULT;
98 98
99 if (tv[0].tv_nsec == UTIME_OMIT && tv[1].tv_nsec == UTIME_OMIT) 99 if (tv[0].tv_nsec == UTIME_OMIT && tv[1].tv_nsec == UTIME_OMIT)
@@ -505,7 +505,7 @@ COMPAT_SYSCALL_DEFINE5(io_getevents, compat_aio_context_t, ctx_id,
505 struct timespec __user *ut = NULL; 505 struct timespec __user *ut = NULL;
506 506
507 if (timeout) { 507 if (timeout) {
508 if (get_compat_timespec(&t, timeout)) 508 if (compat_get_timespec(&t, timeout))
509 return -EFAULT; 509 return -EFAULT;
510 510
511 ut = compat_alloc_user_space(sizeof(*ut)); 511 ut = compat_alloc_user_space(sizeof(*ut));
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 01c0aa57ccec..e6494261eaff 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -147,26 +147,23 @@ struct compat_sigaction {
147}; 147};
148 148
149/* 149/*
150 * These functions operate strictly on struct compat_time*
151 */
152extern int get_compat_timespec(struct timespec *,
153 const struct compat_timespec __user *);
154extern int put_compat_timespec(const struct timespec *,
155 struct compat_timespec __user *);
156extern int get_compat_timeval(struct timeval *,
157 const struct compat_timeval __user *);
158extern int put_compat_timeval(const struct timeval *,
159 struct compat_timeval __user *);
160/*
161 * These functions operate on 32- or 64-bit specs depending on 150 * These functions operate on 32- or 64-bit specs depending on
162 * COMPAT_USE_64BIT_TIME, hence the void user pointer arguments and the 151 * COMPAT_USE_64BIT_TIME, hence the void user pointer arguments.
163 * naming as compat_get/put_ rather than get/put_compat_.
164 */ 152 */
165extern int compat_get_timespec(struct timespec *, const void __user *); 153extern int compat_get_timespec(struct timespec *, const void __user *);
166extern int compat_put_timespec(const struct timespec *, void __user *); 154extern int compat_put_timespec(const struct timespec *, void __user *);
167extern int compat_get_timeval(struct timeval *, const void __user *); 155extern int compat_get_timeval(struct timeval *, const void __user *);
168extern int compat_put_timeval(const struct timeval *, void __user *); 156extern int compat_put_timeval(const struct timeval *, void __user *);
169 157
158/*
159 * This function convert a timespec if necessary and returns a *user
160 * space* pointer. If no conversion is necessary, it returns the
161 * initial pointer. NULL is a legitimate argument and will always
162 * output NULL.
163 */
164extern int compat_convert_timespec(struct timespec __user **,
165 const void __user *);
166
170struct compat_iovec { 167struct compat_iovec {
171 compat_uptr_t iov_base; 168 compat_uptr_t iov_base;
172 compat_size_t iov_len; 169 compat_size_t iov_len;
diff --git a/ipc/compat.c b/ipc/compat.c
index 98b9016cab6c..a4695ada3275 100644
--- a/ipc/compat.c
+++ b/ipc/compat.c
@@ -753,14 +753,8 @@ COMPAT_SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsems,
753 unsigned, nsops, 753 unsigned, nsops,
754 const struct compat_timespec __user *, timeout) 754 const struct compat_timespec __user *, timeout)
755{ 755{
756 struct timespec __user *ts64 = NULL; 756 struct timespec __user *ts64;
757 if (timeout) { 757 if (compat_convert_timespec(&ts64, timeout))
758 struct timespec ts; 758 return -EFAULT;
759 ts64 = compat_alloc_user_space(sizeof(*ts64));
760 if (get_compat_timespec(&ts, timeout))
761 return -EFAULT;
762 if (copy_to_user(ts64, &ts, sizeof(ts)))
763 return -EFAULT;
764 }
765 return sys_semtimedop(semid, tsems, nsops, ts64); 759 return sys_semtimedop(semid, tsems, nsops, ts64);
766} 760}
diff --git a/ipc/compat_mq.c b/ipc/compat_mq.c
index d58747293772..90d29f59cac6 100644
--- a/ipc/compat_mq.c
+++ b/ipc/compat_mq.c
@@ -64,20 +64,6 @@ COMPAT_SYSCALL_DEFINE4(mq_open, const char __user *, u_name,
64 return sys_mq_open(u_name, oflag, mode, p); 64 return sys_mq_open(u_name, oflag, mode, p);
65} 65}
66 66
67static int compat_prepare_timeout(struct timespec __user **p,
68 const struct compat_timespec __user *u)
69{
70 struct timespec ts;
71 if (!u) {
72 *p = NULL;
73 return 0;
74 }
75 *p = compat_alloc_user_space(sizeof(ts));
76 if (get_compat_timespec(&ts, u) || copy_to_user(*p, &ts, sizeof(ts)))
77 return -EFAULT;
78 return 0;
79}
80
81COMPAT_SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, 67COMPAT_SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes,
82 const char __user *, u_msg_ptr, 68 const char __user *, u_msg_ptr,
83 compat_size_t, msg_len, unsigned int, msg_prio, 69 compat_size_t, msg_len, unsigned int, msg_prio,
@@ -85,7 +71,7 @@ COMPAT_SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes,
85{ 71{
86 struct timespec __user *u_ts; 72 struct timespec __user *u_ts;
87 73
88 if (compat_prepare_timeout(&u_ts, u_abs_timeout)) 74 if (compat_convert_timespec(&u_ts, u_abs_timeout))
89 return -EFAULT; 75 return -EFAULT;
90 76
91 return sys_mq_timedsend(mqdes, u_msg_ptr, msg_len, 77 return sys_mq_timedsend(mqdes, u_msg_ptr, msg_len,
@@ -98,7 +84,8 @@ COMPAT_SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes,
98 const struct compat_timespec __user *, u_abs_timeout) 84 const struct compat_timespec __user *, u_abs_timeout)
99{ 85{
100 struct timespec __user *u_ts; 86 struct timespec __user *u_ts;
101 if (compat_prepare_timeout(&u_ts, u_abs_timeout)) 87
88 if (compat_convert_timespec(&u_ts, u_abs_timeout))
102 return -EFAULT; 89 return -EFAULT;
103 90
104 return sys_mq_timedreceive(mqdes, u_msg_ptr, msg_len, 91 return sys_mq_timedreceive(mqdes, u_msg_ptr, msg_len,
diff --git a/kernel/compat.c b/kernel/compat.c
index 488ff8c4cf48..e40b0430b562 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -30,28 +30,6 @@
30 30
31#include <asm/uaccess.h> 31#include <asm/uaccess.h>
32 32
33/*
34 * Get/set struct timeval with struct timespec on the native side
35 */
36static int compat_get_timeval_convert(struct timespec *o,
37 struct compat_timeval __user *i)
38{
39 long usec;
40
41 if (get_user(o->tv_sec, &i->tv_sec) ||
42 get_user(usec, &i->tv_usec))
43 return -EFAULT;
44 o->tv_nsec = usec * 1000;
45 return 0;
46}
47
48static int compat_put_timeval_convert(struct compat_timeval __user *o,
49 struct timeval *i)
50{
51 return (put_user(i->tv_sec, &o->tv_sec) ||
52 put_user(i->tv_usec, &o->tv_usec)) ? -EFAULT : 0;
53}
54
55static int compat_get_timex(struct timex *txc, struct compat_timex __user *utp) 33static int compat_get_timex(struct timex *txc, struct compat_timex __user *utp)
56{ 34{
57 memset(txc, 0, sizeof(struct timex)); 35 memset(txc, 0, sizeof(struct timex));
@@ -116,7 +94,7 @@ COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv,
116 if (tv) { 94 if (tv) {
117 struct timeval ktv; 95 struct timeval ktv;
118 do_gettimeofday(&ktv); 96 do_gettimeofday(&ktv);
119 if (compat_put_timeval_convert(tv, &ktv)) 97 if (compat_put_timeval(&ktv, tv))
120 return -EFAULT; 98 return -EFAULT;
121 } 99 }
122 if (tz) { 100 if (tz) {
@@ -130,59 +108,58 @@ COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv,
130COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv, 108COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv,
131 struct timezone __user *, tz) 109 struct timezone __user *, tz)
132{ 110{
133 struct timespec kts; 111 struct timeval user_tv;
134 struct timezone ktz; 112 struct timespec new_ts;
113 struct timezone new_tz;
135 114
136 if (tv) { 115 if (tv) {
137 if (compat_get_timeval_convert(&kts, tv)) 116 if (compat_get_timeval(&user_tv, tv))
138 return -EFAULT; 117 return -EFAULT;
118 new_ts.tv_sec = user_tv.tv_sec;
119 new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC;
139 } 120 }
140 if (tz) { 121 if (tz) {
141 if (copy_from_user(&ktz, tz, sizeof(ktz))) 122 if (copy_from_user(&new_tz, tz, sizeof(*tz)))
142 return -EFAULT; 123 return -EFAULT;
143 } 124 }
144 125
145 return do_sys_settimeofday(tv ? &kts : NULL, tz ? &ktz : NULL); 126 return do_sys_settimeofday(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
146} 127}
147 128
148int get_compat_timeval(struct timeval *tv, const struct compat_timeval __user *ctv) 129static int __compat_get_timeval(struct timeval *tv, const struct compat_timeval __user *ctv)
149{ 130{
150 return (!access_ok(VERIFY_READ, ctv, sizeof(*ctv)) || 131 return (!access_ok(VERIFY_READ, ctv, sizeof(*ctv)) ||
151 __get_user(tv->tv_sec, &ctv->tv_sec) || 132 __get_user(tv->tv_sec, &ctv->tv_sec) ||
152 __get_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0; 133 __get_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0;
153} 134}
154EXPORT_SYMBOL_GPL(get_compat_timeval);
155 135
156int put_compat_timeval(const struct timeval *tv, struct compat_timeval __user *ctv) 136static int __compat_put_timeval(const struct timeval *tv, struct compat_timeval __user *ctv)
157{ 137{
158 return (!access_ok(VERIFY_WRITE, ctv, sizeof(*ctv)) || 138 return (!access_ok(VERIFY_WRITE, ctv, sizeof(*ctv)) ||
159 __put_user(tv->tv_sec, &ctv->tv_sec) || 139 __put_user(tv->tv_sec, &ctv->tv_sec) ||
160 __put_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0; 140 __put_user(tv->tv_usec, &ctv->tv_usec)) ? -EFAULT : 0;
161} 141}
162EXPORT_SYMBOL_GPL(put_compat_timeval);
163 142
164int get_compat_timespec(struct timespec *ts, const struct compat_timespec __user *cts) 143static int __compat_get_timespec(struct timespec *ts, const struct compat_timespec __user *cts)
165{ 144{
166 return (!access_ok(VERIFY_READ, cts, sizeof(*cts)) || 145 return (!access_ok(VERIFY_READ, cts, sizeof(*cts)) ||
167 __get_user(ts->tv_sec, &cts->tv_sec) || 146 __get_user(ts->tv_sec, &cts->tv_sec) ||
168 __get_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; 147 __get_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
169} 148}
170EXPORT_SYMBOL_GPL(get_compat_timespec);
171 149
172int put_compat_timespec(const struct timespec *ts, struct compat_timespec __user *cts) 150static int __compat_put_timespec(const struct timespec *ts, struct compat_timespec __user *cts)
173{ 151{
174 return (!access_ok(VERIFY_WRITE, cts, sizeof(*cts)) || 152 return (!access_ok(VERIFY_WRITE, cts, sizeof(*cts)) ||
175 __put_user(ts->tv_sec, &cts->tv_sec) || 153 __put_user(ts->tv_sec, &cts->tv_sec) ||
176 __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; 154 __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0;
177} 155}
178EXPORT_SYMBOL_GPL(put_compat_timespec);
179 156
180int compat_get_timeval(struct timeval *tv, const void __user *utv) 157int compat_get_timeval(struct timeval *tv, const void __user *utv)
181{ 158{
182 if (COMPAT_USE_64BIT_TIME) 159 if (COMPAT_USE_64BIT_TIME)
183 return copy_from_user(tv, utv, sizeof *tv) ? -EFAULT : 0; 160 return copy_from_user(tv, utv, sizeof *tv) ? -EFAULT : 0;
184 else 161 else
185 return get_compat_timeval(tv, utv); 162 return __compat_get_timeval(tv, utv);
186} 163}
187EXPORT_SYMBOL_GPL(compat_get_timeval); 164EXPORT_SYMBOL_GPL(compat_get_timeval);
188 165
@@ -191,7 +168,7 @@ int compat_put_timeval(const struct timeval *tv, void __user *utv)
191 if (COMPAT_USE_64BIT_TIME) 168 if (COMPAT_USE_64BIT_TIME)
192 return copy_to_user(utv, tv, sizeof *tv) ? -EFAULT : 0; 169 return copy_to_user(utv, tv, sizeof *tv) ? -EFAULT : 0;
193 else 170 else
194 return put_compat_timeval(tv, utv); 171 return __compat_put_timeval(tv, utv);
195} 172}
196EXPORT_SYMBOL_GPL(compat_put_timeval); 173EXPORT_SYMBOL_GPL(compat_put_timeval);
197 174
@@ -200,7 +177,7 @@ int compat_get_timespec(struct timespec *ts, const void __user *uts)
200 if (COMPAT_USE_64BIT_TIME) 177 if (COMPAT_USE_64BIT_TIME)
201 return copy_from_user(ts, uts, sizeof *ts) ? -EFAULT : 0; 178 return copy_from_user(ts, uts, sizeof *ts) ? -EFAULT : 0;
202 else 179 else
203 return get_compat_timespec(ts, uts); 180 return __compat_get_timespec(ts, uts);
204} 181}
205EXPORT_SYMBOL_GPL(compat_get_timespec); 182EXPORT_SYMBOL_GPL(compat_get_timespec);
206 183
@@ -209,10 +186,33 @@ int compat_put_timespec(const struct timespec *ts, void __user *uts)
209 if (COMPAT_USE_64BIT_TIME) 186 if (COMPAT_USE_64BIT_TIME)
210 return copy_to_user(uts, ts, sizeof *ts) ? -EFAULT : 0; 187 return copy_to_user(uts, ts, sizeof *ts) ? -EFAULT : 0;
211 else 188 else
212 return put_compat_timespec(ts, uts); 189 return __compat_put_timespec(ts, uts);
213} 190}
214EXPORT_SYMBOL_GPL(compat_put_timespec); 191EXPORT_SYMBOL_GPL(compat_put_timespec);
215 192
193int compat_convert_timespec(struct timespec __user **kts,
194 const void __user *cts)
195{
196 struct timespec ts;
197 struct timespec __user *uts;
198
199 if (!cts || COMPAT_USE_64BIT_TIME) {
200 *kts = (struct timespec __user *)cts;
201 return 0;
202 }
203
204 uts = compat_alloc_user_space(sizeof(ts));
205 if (!uts)
206 return -EFAULT;
207 if (compat_get_timespec(&ts, cts))
208 return -EFAULT;
209 if (copy_to_user(uts, &ts, sizeof(ts)))
210 return -EFAULT;
211
212 *kts = uts;
213 return 0;
214}
215
216static long compat_nanosleep_restart(struct restart_block *restart) 216static long compat_nanosleep_restart(struct restart_block *restart)
217{ 217{
218 struct compat_timespec __user *rmtp; 218 struct compat_timespec __user *rmtp;
@@ -229,7 +229,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
229 if (ret) { 229 if (ret) {
230 rmtp = restart->nanosleep.compat_rmtp; 230 rmtp = restart->nanosleep.compat_rmtp;
231 231
232 if (rmtp && put_compat_timespec(&rmt, rmtp)) 232 if (rmtp && compat_put_timespec(&rmt, rmtp))
233 return -EFAULT; 233 return -EFAULT;
234 } 234 }
235 235
@@ -243,7 +243,7 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,
243 mm_segment_t oldfs; 243 mm_segment_t oldfs;
244 long ret; 244 long ret;
245 245
246 if (get_compat_timespec(&tu, rqtp)) 246 if (compat_get_timespec(&tu, rqtp))
247 return -EFAULT; 247 return -EFAULT;
248 248
249 if (!timespec_valid(&tu)) 249 if (!timespec_valid(&tu))
@@ -263,7 +263,7 @@ COMPAT_SYSCALL_DEFINE2(nanosleep, struct compat_timespec __user *, rqtp,
263 restart->fn = compat_nanosleep_restart; 263 restart->fn = compat_nanosleep_restart;
264 restart->nanosleep.compat_rmtp = rmtp; 264 restart->nanosleep.compat_rmtp = rmtp;
265 265
266 if (rmtp && put_compat_timespec(&rmt, rmtp)) 266 if (rmtp && compat_put_timespec(&rmt, rmtp))
267 return -EFAULT; 267 return -EFAULT;
268 } 268 }
269 269
@@ -451,7 +451,7 @@ COMPAT_SYSCALL_DEFINE2(old_getrlimit, unsigned int, resource,
451 mm_segment_t old_fs = get_fs(); 451 mm_segment_t old_fs = get_fs();
452 452
453 set_fs(KERNEL_DS); 453 set_fs(KERNEL_DS);
454 ret = sys_old_getrlimit(resource, &r); 454 ret = sys_old_getrlimit(resource, (struct rlimit __user *)&r);
455 set_fs(old_fs); 455 set_fs(old_fs);
456 456
457 if (!ret) { 457 if (!ret) {
@@ -647,8 +647,8 @@ COMPAT_SYSCALL_DEFINE3(sched_getaffinity, compat_pid_t, pid, unsigned int, len,
647int get_compat_itimerspec(struct itimerspec *dst, 647int get_compat_itimerspec(struct itimerspec *dst,
648 const struct compat_itimerspec __user *src) 648 const struct compat_itimerspec __user *src)
649{ 649{
650 if (get_compat_timespec(&dst->it_interval, &src->it_interval) || 650 if (__compat_get_timespec(&dst->it_interval, &src->it_interval) ||
651 get_compat_timespec(&dst->it_value, &src->it_value)) 651 __compat_get_timespec(&dst->it_value, &src->it_value))
652 return -EFAULT; 652 return -EFAULT;
653 return 0; 653 return 0;
654} 654}
@@ -656,8 +656,8 @@ int get_compat_itimerspec(struct itimerspec *dst,
656int put_compat_itimerspec(struct compat_itimerspec __user *dst, 656int put_compat_itimerspec(struct compat_itimerspec __user *dst,
657 const struct itimerspec *src) 657 const struct itimerspec *src)
658{ 658{
659 if (put_compat_timespec(&src->it_interval, &dst->it_interval) || 659 if (__compat_put_timespec(&src->it_interval, &dst->it_interval) ||
660 put_compat_timespec(&src->it_value, &dst->it_value)) 660 __compat_put_timespec(&src->it_value, &dst->it_value))
661 return -EFAULT; 661 return -EFAULT;
662 return 0; 662 return 0;
663} 663}
@@ -727,7 +727,7 @@ COMPAT_SYSCALL_DEFINE2(clock_settime, clockid_t, which_clock,
727 mm_segment_t oldfs; 727 mm_segment_t oldfs;
728 struct timespec ts; 728 struct timespec ts;
729 729
730 if (get_compat_timespec(&ts, tp)) 730 if (compat_get_timespec(&ts, tp))
731 return -EFAULT; 731 return -EFAULT;
732 oldfs = get_fs(); 732 oldfs = get_fs();
733 set_fs(KERNEL_DS); 733 set_fs(KERNEL_DS);
@@ -749,7 +749,7 @@ COMPAT_SYSCALL_DEFINE2(clock_gettime, clockid_t, which_clock,
749 err = sys_clock_gettime(which_clock, 749 err = sys_clock_gettime(which_clock,
750 (struct timespec __user *) &ts); 750 (struct timespec __user *) &ts);
751 set_fs(oldfs); 751 set_fs(oldfs);
752 if (!err && put_compat_timespec(&ts, tp)) 752 if (!err && compat_put_timespec(&ts, tp))
753 return -EFAULT; 753 return -EFAULT;
754 return err; 754 return err;
755} 755}
@@ -789,7 +789,7 @@ COMPAT_SYSCALL_DEFINE2(clock_getres, clockid_t, which_clock,
789 err = sys_clock_getres(which_clock, 789 err = sys_clock_getres(which_clock,
790 (struct timespec __user *) &ts); 790 (struct timespec __user *) &ts);
791 set_fs(oldfs); 791 set_fs(oldfs);
792 if (!err && tp && put_compat_timespec(&ts, tp)) 792 if (!err && tp && compat_put_timespec(&ts, tp))
793 return -EFAULT; 793 return -EFAULT;
794 return err; 794 return err;
795} 795}
@@ -799,7 +799,7 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
799 long err; 799 long err;
800 mm_segment_t oldfs; 800 mm_segment_t oldfs;
801 struct timespec tu; 801 struct timespec tu;
802 struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp; 802 struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
803 803
804 restart->nanosleep.rmtp = (struct timespec __user *) &tu; 804 restart->nanosleep.rmtp = (struct timespec __user *) &tu;
805 oldfs = get_fs(); 805 oldfs = get_fs();
@@ -808,7 +808,7 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
808 set_fs(oldfs); 808 set_fs(oldfs);
809 809
810 if ((err == -ERESTART_RESTARTBLOCK) && rmtp && 810 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
811 put_compat_timespec(&tu, rmtp)) 811 compat_put_timespec(&tu, rmtp))
812 return -EFAULT; 812 return -EFAULT;
813 813
814 if (err == -ERESTART_RESTARTBLOCK) { 814 if (err == -ERESTART_RESTARTBLOCK) {
@@ -827,7 +827,7 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
827 struct timespec in, out; 827 struct timespec in, out;
828 struct restart_block *restart; 828 struct restart_block *restart;
829 829
830 if (get_compat_timespec(&in, rqtp)) 830 if (compat_get_timespec(&in, rqtp))
831 return -EFAULT; 831 return -EFAULT;
832 832
833 oldfs = get_fs(); 833 oldfs = get_fs();
@@ -838,7 +838,7 @@ COMPAT_SYSCALL_DEFINE4(clock_nanosleep, clockid_t, which_clock, int, flags,
838 set_fs(oldfs); 838 set_fs(oldfs);
839 839
840 if ((err == -ERESTART_RESTARTBLOCK) && rmtp && 840 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
841 put_compat_timespec(&out, rmtp)) 841 compat_put_timespec(&out, rmtp))
842 return -EFAULT; 842 return -EFAULT;
843 843
844 if (err == -ERESTART_RESTARTBLOCK) { 844 if (err == -ERESTART_RESTARTBLOCK) {
@@ -1130,7 +1130,7 @@ COMPAT_SYSCALL_DEFINE2(sched_rr_get_interval,
1130 set_fs(KERNEL_DS); 1130 set_fs(KERNEL_DS);
1131 ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t); 1131 ret = sys_sched_rr_get_interval(pid, (struct timespec __user *)&t);
1132 set_fs(old_fs); 1132 set_fs(old_fs);
1133 if (put_compat_timespec(&t, interval)) 1133 if (compat_put_timespec(&t, interval))
1134 return -EFAULT; 1134 return -EFAULT;
1135 return ret; 1135 return ret;
1136} 1136}
diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
index f9f44fd4d34d..55c8c9349cfe 100644
--- a/kernel/futex_compat.c
+++ b/kernel/futex_compat.c
@@ -183,7 +183,7 @@ COMPAT_SYSCALL_DEFINE6(futex, u32 __user *, uaddr, int, op, u32, val,
183 if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI || 183 if (utime && (cmd == FUTEX_WAIT || cmd == FUTEX_LOCK_PI ||
184 cmd == FUTEX_WAIT_BITSET || 184 cmd == FUTEX_WAIT_BITSET ||
185 cmd == FUTEX_WAIT_REQUEUE_PI)) { 185 cmd == FUTEX_WAIT_REQUEUE_PI)) {
186 if (get_compat_timespec(&ts, utime)) 186 if (compat_get_timespec(&ts, utime))
187 return -EFAULT; 187 return -EFAULT;
188 if (!timespec_valid(&ts)) 188 if (!timespec_valid(&ts))
189 return -EINVAL; 189 return -EINVAL;