]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
xfs: bulkstat should copy lastip whenever userspace supplies one
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 2 Jul 2019 16:39:39 +0000 (09:39 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Tue, 2 Jul 2019 16:40:05 +0000 (09:40 -0700)
When userspace passes in a @lastip pointer we should copy the results
back, even if the @ocount pointer is NULL.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
fs/xfs/xfs_ioctl.c
fs/xfs/xfs_ioctl32.c

index 7f1732ad6c4051d63ebb4f930d75191c4a92cd6b..8bc74ae3b72a71638149e134c1faa30669517298 100644 (file)
@@ -759,14 +759,13 @@ xfs_ioc_bulkstat(
        if (error)
                return error;
 
-       if (bulkreq.ocount != NULL) {
-               if (copy_to_user(bulkreq.lastip, &inlast,
-                                               sizeof(xfs_ino_t)))
-                       return -EFAULT;
+       if (bulkreq.lastip != NULL &&
+           copy_to_user(bulkreq.lastip, &inlast, sizeof(xfs_ino_t)))
+               return -EFAULT;
 
-               if (copy_to_user(bulkreq.ocount, &count, sizeof(count)))
-                       return -EFAULT;
-       }
+       if (bulkreq.ocount != NULL &&
+           copy_to_user(bulkreq.ocount, &count, sizeof(count)))
+               return -EFAULT;
 
        return 0;
 }
index d1967fe6747279d2e060aa1903d5b74e225bd397..3c3fb16685b158e94867e6f36e42ab30088ca968 100644 (file)
@@ -305,14 +305,13 @@ xfs_compat_ioc_bulkstat(
        if (error)
                return error;
 
-       if (bulkreq.ocount != NULL) {
-               if (copy_to_user(bulkreq.lastip, &inlast,
-                                               sizeof(xfs_ino_t)))
-                       return -EFAULT;
+       if (bulkreq.lastip != NULL &&
+           copy_to_user(bulkreq.lastip, &inlast, sizeof(xfs_ino_t)))
+               return -EFAULT;
 
-               if (copy_to_user(bulkreq.ocount, &count, sizeof(count)))
-                       return -EFAULT;
-       }
+       if (bulkreq.ocount != NULL &&
+           copy_to_user(bulkreq.ocount, &count, sizeof(count)))
+               return -EFAULT;
 
        return 0;
 }