Skip to content

Commit b76abb5

Browse files
Darrick J. Wongtytso
Darrick J. Wong
authored andcommitted
ext4: dont return EINVAL from GETFSUUID when reporting UUID length
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 <[email protected]> Reviewed-by: Catherine Hoang <[email protected]> Link: https://lore.kernel.org/r/166811138914.327006.9241306894437166566.stgit@magnolia Signed-off-by: Theodore Ts'o <[email protected]> Cc: [email protected]
1 parent 26d75a1 commit b76abb5

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

fs/ext4/ioctl.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -1154,9 +1154,10 @@ static int ext4_ioctl_getuuid(struct ext4_sb_info *sbi,
11541154

11551155
if (fsuuid.fsu_len == 0) {
11561156
fsuuid.fsu_len = UUID_SIZE;
1157-
if (copy_to_user(ufsuuid, &fsuuid, sizeof(fsuuid.fsu_len)))
1157+
if (copy_to_user(&ufsuuid->fsu_len, &fsuuid.fsu_len,
1158+
sizeof(fsuuid.fsu_len)))
11581159
return -EFAULT;
1159-
return -EINVAL;
1160+
return 0;
11601161
}
11611162

11621163
if (fsuuid.fsu_len != UUID_SIZE || fsuuid.fsu_flags != 0)

0 commit comments

Comments
 (0)