Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <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

authored by

Darrick J. Wong and committed by
Theodore Ts'o
b76abb51 26d75a16

+3 -2
+3 -2
fs/ext4/ioctl.c
··· 1154 1154 1155 1155 if (fsuuid.fsu_len == 0) { 1156 1156 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))) 1158 1159 return -EFAULT; 1159 - return -EINVAL; 1160 + return 0; 1160 1161 } 1161 1162 1162 1163 if (fsuuid.fsu_len != UUID_SIZE || fsuuid.fsu_flags != 0)