summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2022-11-10 12:16:29 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-01-07 11:12:01 +0100
commit627dd452889d5211342accb3cb7a4625f865898b (patch)
tree787c967e9764276d6a7bd2a8b4091facc7a74873 /fs
parenta77f3bdb03d0b2a8f4a3838a3120a6e56170a8bc (diff)
downloadlinux-627dd452889d5211342accb3cb7a4625f865898b.tar.gz
linux-627dd452889d5211342accb3cb7a4625f865898b.tar.bz2
linux-627dd452889d5211342accb3cb7a4625f865898b.zip
ext4: dont return EINVAL from GETFSUUID when reporting UUID length
commit b76abb5157468756163fe7e3431c9fe32cba57ca upstream. If userspace calls this ioctl with fsu_length (the length of the fsuuid.fsu_uuid array) set to zero, ext4 copies the desired uuid length out to userspace. The kernel call returned a result from a valid input, so the return value here should be zero, not EINVAL. While we're at it, fix the copy_to_user call to make it clear that we're only copying out fsu_len. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Catherine Hoang <catherine.hoang@oracle.com> Link: https://lore.kernel.org/r/166811138914.327006.9241306894437166566.stgit@magnolia Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/ioctl.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 5a12f87df45e..202953b5db49 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -1154,9 +1154,10 @@ static int ext4_ioctl_getuuid(struct ext4_sb_info *sbi,
if (fsuuid.fsu_len == 0) {
fsuuid.fsu_len = UUID_SIZE;
- if (copy_to_user(ufsuuid, &fsuuid, sizeof(fsuuid.fsu_len)))
+ if (copy_to_user(&ufsuuid->fsu_len, &fsuuid.fsu_len,
+ sizeof(fsuuid.fsu_len)))
return -EFAULT;
- return -EINVAL;
+ return 0;
}
if (fsuuid.fsu_len < UUID_SIZE || fsuuid.fsu_flags != 0)