Merge tag 'compat-ioctl-5.5' of git://git.kernel.org:/pub/scm/linux/kernel/git/arnd...
[linux-2.6-block.git] / drivers / char / ppdev.c
index e02fe2621b943bd5413714ba40f6a2c93c7b31cf..2c2381a806ae7b8830a190a0aae6d811740af2f0 100644 (file)
@@ -619,20 +619,27 @@ static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                if (copy_from_user(time32, argp, sizeof(time32)))
                        return -EFAULT;
 
+               if ((time32[0] < 0) || (time32[1] < 0))
+                       return -EINVAL;
+
                return pp_set_timeout(pp->pdev, time32[0], time32[1]);
 
        case PPSETTIME64:
                if (copy_from_user(time64, argp, sizeof(time64)))
                        return -EFAULT;
 
+               if ((time64[0] < 0) || (time64[1] < 0))
+                       return -EINVAL;
+
+               if (IS_ENABLED(CONFIG_SPARC64) && !in_compat_syscall())
+                       time64[1] >>= 32;
+
                return pp_set_timeout(pp->pdev, time64[0], time64[1]);
 
        case PPGETTIME32:
                jiffies_to_timespec64(pp->pdev->timeout, &ts);
                time32[0] = ts.tv_sec;
                time32[1] = ts.tv_nsec / NSEC_PER_USEC;
-               if ((time32[0] < 0) || (time32[1] < 0))
-                       return -EINVAL;
 
                if (copy_to_user(argp, time32, sizeof(time32)))
                        return -EFAULT;
@@ -643,8 +650,9 @@ static int pp_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
                jiffies_to_timespec64(pp->pdev->timeout, &ts);
                time64[0] = ts.tv_sec;
                time64[1] = ts.tv_nsec / NSEC_PER_USEC;
-               if ((time64[0] < 0) || (time64[1] < 0))
-                       return -EINVAL;
+
+               if (IS_ENABLED(CONFIG_SPARC64) && !in_compat_syscall())
+                       time64[1] <<= 32;
 
                if (copy_to_user(argp, time64, sizeof(time64)))
                        return -EFAULT;