xfs: bulkstat should copy lastip whenever userspace supplies one

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>
This commit is contained in:
Darrick J. Wong 2019-07-02 09:39:39 -07:00
parent ebd126a651
commit f16fe3ecde
2 changed files with 12 additions and 14 deletions

View 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;
}

View 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;
}