Merge tag 'please-pull-pstore' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl...
[sfrench/cifs-2.6.git] / fs / compat.c
index 19252b97f0cc9662940c2782c76e6782c7fa787a..ca926ad0430cf715af12ebc3f0fa86d8c273d492 100644 (file)
@@ -92,8 +92,8 @@ COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filena
        struct timespec tv[2];
 
        if  (t) {
-               if (get_compat_timespec(&tv[0], &t[0]) ||
-                   get_compat_timespec(&tv[1], &t[1]))
+               if (compat_get_timespec(&tv[0], &t[0]) ||
+                   compat_get_timespec(&tv[1], &t[1]))
                        return -EFAULT;
 
                if (tv[0].tv_nsec == UTIME_OMIT && tv[1].tv_nsec == UTIME_OMIT)
@@ -399,12 +399,28 @@ static int put_compat_flock64(struct flock *kfl, struct compat_flock64 __user *u
 }
 #endif
 
+static unsigned int
+convert_fcntl_cmd(unsigned int cmd)
+{
+       switch (cmd) {
+       case F_GETLK64:
+               return F_GETLK;
+       case F_SETLK64:
+               return F_SETLK;
+       case F_SETLKW64:
+               return F_SETLKW;
+       }
+
+       return cmd;
+}
+
 COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
                       compat_ulong_t, arg)
 {
        mm_segment_t old_fs;
        struct flock f;
        long ret;
+       unsigned int conv_cmd;
 
        switch (cmd) {
        case F_GETLK:
@@ -441,16 +457,18 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
        case F_GETLK64:
        case F_SETLK64:
        case F_SETLKW64:
+       case F_GETLKP:
+       case F_SETLKP:
+       case F_SETLKPW:
                ret = get_compat_flock64(&f, compat_ptr(arg));
                if (ret != 0)
                        break;
                old_fs = get_fs();
                set_fs(KERNEL_DS);
-               ret = sys_fcntl(fd, (cmd == F_GETLK64) ? F_GETLK :
-                               ((cmd == F_SETLK64) ? F_SETLK : F_SETLKW),
-                               (unsigned long)&f);
+               conv_cmd = convert_fcntl_cmd(cmd);
+               ret = sys_fcntl(fd, conv_cmd, (unsigned long)&f);
                set_fs(old_fs);
-               if (cmd == F_GETLK64 && ret == 0) {
+               if ((conv_cmd == F_GETLK || conv_cmd == F_GETLKP) && ret == 0) {
                        /* need to return lock information - see above for commentary */
                        if (f.l_start > COMPAT_LOFF_T_MAX)
                                ret = -EOVERFLOW;
@@ -471,8 +489,15 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
 COMPAT_SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd,
                       compat_ulong_t, arg)
 {
-       if ((cmd == F_GETLK64) || (cmd == F_SETLK64) || (cmd == F_SETLKW64))
+       switch (cmd) {
+       case F_GETLK64:
+       case F_SETLK64:
+       case F_SETLKW64:
+       case F_GETLKP:
+       case F_SETLKP:
+       case F_SETLKPW:
                return -EINVAL;
+       }
        return compat_sys_fcntl64(fd, cmd, arg);
 }
 
@@ -505,7 +530,7 @@ COMPAT_SYSCALL_DEFINE5(io_getevents, compat_aio_context_t, ctx_id,
        struct timespec __user *ut = NULL;
 
        if (timeout) {
-               if (get_compat_timespec(&t, timeout))
+               if (compat_get_timespec(&t, timeout))
                        return -EFAULT;
 
                ut = compat_alloc_user_space(sizeof(*ut));