diff options
Diffstat (limited to 'kernel/compat.c')
| -rw-r--r-- | kernel/compat.c | 82 |
1 files changed, 59 insertions, 23 deletions
diff --git a/kernel/compat.c b/kernel/compat.c index 8c9cd88b6785..c1601a84f8d8 100644 --- a/kernel/compat.c +++ b/kernel/compat.c | |||
| @@ -17,10 +17,10 @@ | |||
| 17 | #include <linux/time.h> | 17 | #include <linux/time.h> |
| 18 | #include <linux/signal.h> | 18 | #include <linux/signal.h> |
| 19 | #include <linux/sched.h> /* for MAX_SCHEDULE_TIMEOUT */ | 19 | #include <linux/sched.h> /* for MAX_SCHEDULE_TIMEOUT */ |
| 20 | #include <linux/futex.h> /* for FUTEX_WAIT */ | ||
| 21 | #include <linux/syscalls.h> | 20 | #include <linux/syscalls.h> |
| 22 | #include <linux/unistd.h> | 21 | #include <linux/unistd.h> |
| 23 | #include <linux/security.h> | 22 | #include <linux/security.h> |
| 23 | #include <linux/timex.h> | ||
| 24 | 24 | ||
| 25 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
| 26 | 26 | ||
| @@ -238,28 +238,6 @@ asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *set, | |||
| 238 | return ret; | 238 | return ret; |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | #ifdef CONFIG_FUTEX | ||
| 242 | asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, int val, | ||
| 243 | struct compat_timespec __user *utime, u32 __user *uaddr2, | ||
| 244 | int val3) | ||
| 245 | { | ||
| 246 | struct timespec t; | ||
| 247 | unsigned long timeout = MAX_SCHEDULE_TIMEOUT; | ||
| 248 | int val2 = 0; | ||
| 249 | |||
| 250 | if ((op == FUTEX_WAIT) && utime) { | ||
| 251 | if (get_compat_timespec(&t, utime)) | ||
| 252 | return -EFAULT; | ||
| 253 | timeout = timespec_to_jiffies(&t) + 1; | ||
| 254 | } | ||
| 255 | if (op >= FUTEX_REQUEUE) | ||
| 256 | val2 = (int) (unsigned long) utime; | ||
| 257 | |||
| 258 | return do_futex((unsigned long)uaddr, op, val, timeout, | ||
| 259 | (unsigned long)uaddr2, val2, val3); | ||
| 260 | } | ||
| 261 | #endif | ||
| 262 | |||
| 263 | asmlinkage long compat_sys_setrlimit(unsigned int resource, | 241 | asmlinkage long compat_sys_setrlimit(unsigned int resource, |
| 264 | struct compat_rlimit __user *rlim) | 242 | struct compat_rlimit __user *rlim) |
| 265 | { | 243 | { |
| @@ -898,3 +876,61 @@ asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset, compat | |||
| 898 | return -ERESTARTNOHAND; | 876 | return -ERESTARTNOHAND; |
| 899 | } | 877 | } |
| 900 | #endif /* __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND */ | 878 | #endif /* __ARCH_WANT_COMPAT_SYS_RT_SIGSUSPEND */ |
| 879 | |||
| 880 | asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp) | ||
| 881 | { | ||
| 882 | struct timex txc; | ||
| 883 | int ret; | ||
| 884 | |||
| 885 | memset(&txc, 0, sizeof(struct timex)); | ||
| 886 | |||
| 887 | if (!access_ok(VERIFY_READ, utp, sizeof(struct compat_timex)) || | ||
| 888 | __get_user(txc.modes, &utp->modes) || | ||
| 889 | __get_user(txc.offset, &utp->offset) || | ||
| 890 | __get_user(txc.freq, &utp->freq) || | ||
| 891 | __get_user(txc.maxerror, &utp->maxerror) || | ||
| 892 | __get_user(txc.esterror, &utp->esterror) || | ||
| 893 | __get_user(txc.status, &utp->status) || | ||
| 894 | __get_user(txc.constant, &utp->constant) || | ||
| 895 | __get_user(txc.precision, &utp->precision) || | ||
| 896 | __get_user(txc.tolerance, &utp->tolerance) || | ||
| 897 | __get_user(txc.time.tv_sec, &utp->time.tv_sec) || | ||
| 898 | __get_user(txc.time.tv_usec, &utp->time.tv_usec) || | ||
| 899 | __get_user(txc.tick, &utp->tick) || | ||
| 900 | __get_user(txc.ppsfreq, &utp->ppsfreq) || | ||
| 901 | __get_user(txc.jitter, &utp->jitter) || | ||
| 902 | __get_user(txc.shift, &utp->shift) || | ||
| 903 | __get_user(txc.stabil, &utp->stabil) || | ||
| 904 | __get_user(txc.jitcnt, &utp->jitcnt) || | ||
| 905 | __get_user(txc.calcnt, &utp->calcnt) || | ||
| 906 | __get_user(txc.errcnt, &utp->errcnt) || | ||
| 907 | __get_user(txc.stbcnt, &utp->stbcnt)) | ||
| 908 | return -EFAULT; | ||
| 909 | |||
| 910 | ret = do_adjtimex(&txc); | ||
| 911 | |||
| 912 | if (!access_ok(VERIFY_WRITE, utp, sizeof(struct compat_timex)) || | ||
| 913 | __put_user(txc.modes, &utp->modes) || | ||
| 914 | __put_user(txc.offset, &utp->offset) || | ||
| 915 | __put_user(txc.freq, &utp->freq) || | ||
| 916 | __put_user(txc.maxerror, &utp->maxerror) || | ||
| 917 | __put_user(txc.esterror, &utp->esterror) || | ||
| 918 | __put_user(txc.status, &utp->status) || | ||
| 919 | __put_user(txc.constant, &utp->constant) || | ||
| 920 | __put_user(txc.precision, &utp->precision) || | ||
| 921 | __put_user(txc.tolerance, &utp->tolerance) || | ||
| 922 | __put_user(txc.time.tv_sec, &utp->time.tv_sec) || | ||
| 923 | __put_user(txc.time.tv_usec, &utp->time.tv_usec) || | ||
| 924 | __put_user(txc.tick, &utp->tick) || | ||
| 925 | __put_user(txc.ppsfreq, &utp->ppsfreq) || | ||
| 926 | __put_user(txc.jitter, &utp->jitter) || | ||
| 927 | __put_user(txc.shift, &utp->shift) || | ||
| 928 | __put_user(txc.stabil, &utp->stabil) || | ||
| 929 | __put_user(txc.jitcnt, &utp->jitcnt) || | ||
| 930 | __put_user(txc.calcnt, &utp->calcnt) || | ||
| 931 | __put_user(txc.errcnt, &utp->errcnt) || | ||
| 932 | __put_user(txc.stbcnt, &utp->stbcnt)) | ||
| 933 | ret = -EFAULT; | ||
| 934 | |||
| 935 | return ret; | ||
| 936 | } | ||
