From: Dan Carpenter Date: Tue, 15 Jul 2025 23:03:17 +0000 (-0500) Subject: fs: tighten a sanity check in file_attr_to_fileattr() X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e85931d1cd699307e6a3f1060cbe4c42748f3fff;p=thirdparty%2Fkernel%2Flinux.git 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: be7efb2d20d6 ("fs: introduce file_getattr and file_setattr syscalls") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/baf7b808-bcf2-4ac1-9313-882c91cc87b2@sabinyo.mountain Signed-off-by: Christian Brauner --- diff --git a/fs/file_attr.c b/fs/file_attr.c index 17745c89e2be5..12424d4945d0a 100644 --- a/fs/file_attr.c +++ b/fs/file_attr.c @@ -136,7 +136,7 @@ EXPORT_SYMBOL(copy_fsxattr_to_user); static int file_attr_to_fileattr(const struct file_attr *fattr, struct file_kattr *fa) { - __u32 mask = FS_XFLAGS_MASK; + __u64 mask = FS_XFLAGS_MASK; if (fattr->fa_xflags & ~mask) return -EINVAL;