aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-06-07 04:42:41 -0400
committerThomas Gleixner <tglx@linutronix.de>2017-06-13 18:00:46 -0400
commit2b2d02856b3176701c91d723356f766d6ee27853 (patch)
tree31524e0ce6ee3c24b312ee46173d71fb5a19aa0b
parentb180db2c8ca6692a10b79631cadc18d03303d494 (diff)
time: Move compat_gettimeofday()/settimeofday() to native
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: John Stultz <john.stultz@linaro.org> Cc: Peter Zijlstra <peterz@infradead.org> Link: http://lkml.kernel.org/r/20170607084241.28657-16-viro@ZenIV.linux.org.uk
-rw-r--r--kernel/compat.c38
-rw-r--r--kernel/time/time.c41
2 files changed, 41 insertions, 38 deletions
diff --git a/kernel/compat.c b/kernel/compat.c
index aa7b9a27f9e7..ebd8bdc3fd68 100644
--- a/kernel/compat.c
+++ b/kernel/compat.c
@@ -92,44 +92,6 @@ int compat_put_timex(struct compat_timex __user *utp, const struct timex *txc)
92 return 0; 92 return 0;
93} 93}
94 94
95COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv,
96 struct timezone __user *, tz)
97{
98 if (tv) {
99 struct timeval ktv;
100 do_gettimeofday(&ktv);
101 if (compat_put_timeval(&ktv, tv))
102 return -EFAULT;
103 }
104 if (tz) {
105 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
106 return -EFAULT;
107 }
108
109 return 0;
110}
111
112COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv,
113 struct timezone __user *, tz)
114{
115 struct timespec64 new_ts;
116 struct timeval user_tv;
117 struct timezone new_tz;
118
119 if (tv) {
120 if (compat_get_timeval(&user_tv, tv))
121 return -EFAULT;
122 new_ts.tv_sec = user_tv.tv_sec;
123 new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC;
124 }
125 if (tz) {
126 if (copy_from_user(&new_tz, tz, sizeof(*tz)))
127 return -EFAULT;
128 }
129
130 return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
131}
132
133static int __compat_get_timeval(struct timeval *tv, const struct compat_timeval __user *ctv) 95static int __compat_get_timeval(struct timeval *tv, const struct compat_timeval __user *ctv)
134{ 96{
135 return (!access_ok(VERIFY_READ, ctv, sizeof(*ctv)) || 97 return (!access_ok(VERIFY_READ, ctv, sizeof(*ctv)) ||
diff --git a/kernel/time/time.c b/kernel/time/time.c
index e5d44999ff78..7c89e437c4d7 100644
--- a/kernel/time/time.c
+++ b/kernel/time/time.c
@@ -257,6 +257,47 @@ SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
257 return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL); 257 return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
258} 258}
259 259
260#ifdef CONFIG_COMPAT
261COMPAT_SYSCALL_DEFINE2(gettimeofday, struct compat_timeval __user *, tv,
262 struct timezone __user *, tz)
263{
264 if (tv) {
265 struct timeval ktv;
266
267 do_gettimeofday(&ktv);
268 if (compat_put_timeval(&ktv, tv))
269 return -EFAULT;
270 }
271 if (tz) {
272 if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
273 return -EFAULT;
274 }
275
276 return 0;
277}
278
279COMPAT_SYSCALL_DEFINE2(settimeofday, struct compat_timeval __user *, tv,
280 struct timezone __user *, tz)
281{
282 struct timespec64 new_ts;
283 struct timeval user_tv;
284 struct timezone new_tz;
285
286 if (tv) {
287 if (compat_get_timeval(&user_tv, tv))
288 return -EFAULT;
289 new_ts.tv_sec = user_tv.tv_sec;
290 new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC;
291 }
292 if (tz) {
293 if (copy_from_user(&new_tz, tz, sizeof(*tz)))
294 return -EFAULT;
295 }
296
297 return do_sys_settimeofday64(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
298}
299#endif
300
260SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p) 301SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)
261{ 302{
262 struct timex txc; /* Local copy of parameter */ 303 struct timex txc; /* Local copy of parameter */