diff options
Diffstat (limited to 'kernel/compat.c')
-rw-r--r-- | kernel/compat.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/kernel/compat.c b/kernel/compat.c index 42a1ed4b61b1..f2a297504287 100644 --- a/kernel/compat.c +++ b/kernel/compat.c | |||
@@ -40,10 +40,36 @@ int put_compat_timespec(const struct timespec *ts, struct compat_timespec __user | |||
40 | __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; | 40 | __put_user(ts->tv_nsec, &cts->tv_nsec)) ? -EFAULT : 0; |
41 | } | 41 | } |
42 | 42 | ||
43 | static long compat_nanosleep_restart(struct restart_block *restart) | ||
44 | { | ||
45 | struct compat_timespec __user *rmtp; | ||
46 | struct timespec rmt; | ||
47 | mm_segment_t oldfs; | ||
48 | long ret; | ||
49 | |||
50 | rmtp = (struct compat_timespec __user *)(restart->arg1); | ||
51 | restart->arg1 = (unsigned long)&rmt; | ||
52 | oldfs = get_fs(); | ||
53 | set_fs(KERNEL_DS); | ||
54 | ret = hrtimer_nanosleep_restart(restart); | ||
55 | set_fs(oldfs); | ||
56 | |||
57 | if (ret) { | ||
58 | restart->fn = compat_nanosleep_restart; | ||
59 | restart->arg1 = (unsigned long)rmtp; | ||
60 | |||
61 | if (rmtp && put_compat_timespec(&rmt, rmtp)) | ||
62 | return -EFAULT; | ||
63 | } | ||
64 | |||
65 | return ret; | ||
66 | } | ||
67 | |||
43 | asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp, | 68 | asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp, |
44 | struct compat_timespec __user *rmtp) | 69 | struct compat_timespec __user *rmtp) |
45 | { | 70 | { |
46 | struct timespec tu, rmt; | 71 | struct timespec tu, rmt; |
72 | mm_segment_t oldfs; | ||
47 | long ret; | 73 | long ret; |
48 | 74 | ||
49 | if (get_compat_timespec(&tu, rqtp)) | 75 | if (get_compat_timespec(&tu, rqtp)) |
@@ -52,11 +78,21 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp, | |||
52 | if (!timespec_valid(&tu)) | 78 | if (!timespec_valid(&tu)) |
53 | return -EINVAL; | 79 | return -EINVAL; |
54 | 80 | ||
55 | ret = hrtimer_nanosleep(&tu, rmtp ? &rmt : NULL, HRTIMER_MODE_REL, | 81 | oldfs = get_fs(); |
56 | CLOCK_MONOTONIC); | 82 | set_fs(KERNEL_DS); |
83 | ret = hrtimer_nanosleep(&tu, | ||
84 | rmtp ? (struct timespec __user *)&rmt : NULL, | ||
85 | HRTIMER_MODE_REL, CLOCK_MONOTONIC); | ||
86 | set_fs(oldfs); | ||
87 | |||
88 | if (ret) { | ||
89 | struct restart_block *restart | ||
90 | = ¤t_thread_info()->restart_block; | ||
91 | |||
92 | restart->fn = compat_nanosleep_restart; | ||
93 | restart->arg1 = (unsigned long)rmtp; | ||
57 | 94 | ||
58 | if (ret && rmtp) { | 95 | if (rmtp && put_compat_timespec(&rmt, rmtp)) |
59 | if (put_compat_timespec(&rmt, rmtp)) | ||
60 | return -EFAULT; | 96 | return -EFAULT; |
61 | } | 97 | } |
62 | 98 | ||