2
0
mirror of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git synced 2025-09-04 20:19:47 +08:00

fs: tighten a sanity check in file_attr_to_fileattr()

The fattr->fa_xflags is a u64 that comes from the user.  This is a sanity
check to ensure that the users are only setting allowed flags.  The
problem is that it doesn't check the upper 32 bits.  It doesn't really
affect anything but for more flexibility in the future, we want to enforce
users zero out those bits.

Fixes: be7efb2d20 ("fs: introduce file_getattr and file_setattr syscalls")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/baf7b808-bcf2-4ac1-9313-882c91cc87b2@sabinyo.mountain
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Dan Carpenter 2025-07-15 18:03:17 -05:00 committed by Christian Brauner
parent ca115d7e75
commit e85931d1cd
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2

View File

@ -136,7 +136,7 @@ EXPORT_SYMBOL(copy_fsxattr_to_user);
static int file_attr_to_fileattr(const struct file_attr *fattr, static int file_attr_to_fileattr(const struct file_attr *fattr,
struct file_kattr *fa) struct file_kattr *fa)
{ {
__u32 mask = FS_XFLAGS_MASK; __u64 mask = FS_XFLAGS_MASK;
if (fattr->fa_xflags & ~mask) if (fattr->fa_xflags & ~mask)
return -EINVAL; return -EINVAL;