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: don't fail GETFSUUID when the caller provides a long buffer

If userspace provides a longer UUID buffer than is required, we
shouldn't fail the call with EINVAL -- rather, we can fill the caller's
buffer with the bytes we /can/ fill, and update the length field to
reflect what we copied. This doesn't break the UAPI since we're
enabling a case that currently fails, and so far Ted hasn't released a
version of e2fsprogs that uses the new ext4 ioctl.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Catherine Hoang <catherine.hoang@oracle.com>
Link: https://lore.kernel.org/r/166811139478.327006.13879198441587445544.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
a7e9d977 b76abb51

+4 -2
+4 -2
fs/ext4/ioctl.c
··· 1160 1160 return 0; 1161 1161 } 1162 1162 1163 - if (fsuuid.fsu_len != UUID_SIZE || fsuuid.fsu_flags != 0) 1163 + if (fsuuid.fsu_len < UUID_SIZE || fsuuid.fsu_flags != 0) 1164 1164 return -EINVAL; 1165 1165 1166 1166 lock_buffer(sbi->s_sbh); 1167 1167 memcpy(uuid, sbi->s_es->s_uuid, UUID_SIZE); 1168 1168 unlock_buffer(sbi->s_sbh); 1169 1169 1170 - if (copy_to_user(&ufsuuid->fsu_uuid[0], uuid, UUID_SIZE)) 1170 + fsuuid.fsu_len = UUID_SIZE; 1171 + if (copy_to_user(ufsuuid, &fsuuid, sizeof(fsuuid)) || 1172 + copy_to_user(&ufsuuid->fsu_uuid[0], uuid, UUID_SIZE)) 1171 1173 return -EFAULT; 1172 1174 return 0; 1173 1175 }