fs: set fsx_valid hint in file_getattr() syscall
Subsystems (2)
PATCH 1/1 fs: set fsx_valid hint in file_getattr() syscall
The vfs_fileattr_get() API is a unification of the two legacy ioctls FS_IOC_GETFLAGS and FS_IOC_FSGETXATTR.
The legacy ioctls set a hint flag, either flags_valid or fsx_valid, which overlayfs and fuse may use to convert back to one of the two legacy ioctls.
The new file_getattr() syscall is a modern version of the ioctl FS_IOC_FSGETXATTR, but it does not set the fsx_valid hint leading to uninit-value KMSAN warning in ovl_fileattr_get() as is also expected to happen in fuse_fileattr_get().
--- fs/file_attr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/file_attr.c +1 -1
@@ -379,7 +379,7 @@ SYSCALL_DEFINE5(file_getattr, int, dfd, const char __user *, filename, struct filename *name __free(putname) = NULL;unsigned int lookup_flags =0 ;struct file_attr fattr; -struct file_kattr fa; +struct file_kattr fa = { .fsx_valid = true };/* hint only */ int error;BUILD_BUG_ON (sizeof (struct file_attr ) <FILE_ATTR_SIZE_VER0 );
Signature · 1 line
2.52.0
Quoted 12 lines · Amir Goldstein
The
vfs_fileattr_get()API is a unification of the two legacy ioctlsFS_IOC_GETFLAGSandFS_IOC_FSGETXATTR.The legacy ioctls set a hint flag, either
flags_validorfsx_valid, which overlayfs and fuse may use to convert back to one of the two legacy ioctls.The new
file_getattr()syscall is a modern version of the ioctlFS_IOC_FSGETXATTR, but it does not set thefsx_validhint leading to uninit-value KMSAN warning inovl_fileattr_get()as is also expected to happen infuse_fileattr_get().
Quoted 6 lines
Reported-by [email protected]Fixes be7efb2d20d67 ("fs: introduce file_getattr and file_setattr syscalls")Cc Andrey Albershteyn <[email protected]>Signed-off-by Amir Goldstein <[email protected]>
Looks good to me. Feel free to add:
Honza
Quoted 20 lines
--- fs/file_attr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/file_attr.c +1
-1@@ -379,7 +379,7 @@ SYSCALL_DEFINE5(file_getattr, int, dfd, const char __user *, filename, struct filename *name __free(putname) = NULL;unsigned int lookup_flags =0 ;struct file_attr fattr; -struct file_kattr fa; +struct file_kattr fa = { .fsx_valid = true };/* hint only */ int error;BUILD_BUG_ON (sizeof (struct file_attr ) <FILE_ATTR_SIZE_VER0 );Signature · 1 line
2.52.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 38 lines · Amir Goldstein
The
vfs_fileattr_get()API is a unification of the two legacy ioctlsFS_IOC_GETFLAGSandFS_IOC_FSGETXATTR.The legacy ioctls set a hint flag, either
flags_validorfsx_valid, which overlayfs and fuse may use to convert back to one of the two legacy ioctls.The new
file_getattr()syscall is a modern version of the ioctlFS_IOC_FSGETXATTR, but it does not set thefsx_validhint leading to uninit-value KMSAN warning inovl_fileattr_get()as is also expected to happen infuse_fileattr_get().Reported-by [email protected]Fixes be7efb2d20d67 ("fs: introduce file_getattr and file_setattr syscalls")Cc Andrey Albershteyn <[email protected]>Signed-off-by Amir Goldstein <[email protected]>--- fs/file_attr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/file_attr.c +1
-1@@ -379,7 +379,7 @@ SYSCALL_DEFINE5(file_getattr, int, dfd, const char __user *, filename, struct filename *name __free(putname) = NULL;unsigned int lookup_flags =0 ;struct file_attr fattr; -struct file_kattr fa; +struct file_kattr fa = { .fsx_valid = true };/* hint only */ int error;BUILD_BUG_ON (sizeof (struct file_attr ) <FILE_ATTR_SIZE_VER0 );Signature · 1 line
2.52.0
There's same patch a bit earlier from Edward
https://lore.kernel.org/linux-fsdevel/[email protected]/
Looks good to me
Signature · 1 line
- Andrey
Quoted 36 lines · Andrey Albershteyn
Quoted 34 lines · Amir Goldstein
The
vfs_fileattr_get()API is a unification of the two legacy ioctlsFS_IOC_GETFLAGSandFS_IOC_FSGETXATTR.The legacy ioctls set a hint flag, either
flags_validorfsx_valid, which overlayfs and fuse may use to convert back to one of the two legacy ioctls.The new
file_getattr()syscall is a modern version of the ioctlFS_IOC_FSGETXATTR, but it does not set thefsx_validhint leading to uninit-value KMSAN warning inovl_fileattr_get()as is also expected to happen infuse_fileattr_get().Reported-by [email protected]Fixes be7efb2d20d67 ("fs: introduce file_getattr and file_setattr syscalls")Cc Andrey Albershteyn <[email protected]>Signed-off-by Amir Goldstein <[email protected]>--- fs/file_attr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/file_attr.c +1
-1@@ -379,7 +379,7 @@ SYSCALL_DEFINE5(file_getattr, int, dfd, const char __user *, filename, struct filename *name __free(putname) = NULL;unsigned int lookup_flags =0 ;struct file_attr fattr; -struct file_kattr fa; +struct file_kattr fa = { .fsx_valid = true };/* hint only */ int error;
Quoted 8 lines
Quoted 4 lines
fs/file_attr.c +0
-1BUILD_BUG_ON (sizeof (struct file_attr ) <FILE_ATTR_SIZE_VER0 ); --2.52.0
There's same patch a bit earlier from Edward
https://lore.kernel.org/linux-fsdevel/[email protected]/
Nice. I'm fine with taking Edward's patch.
With addition of the Fixes: and cc: stable tags.
Thanks,
Amir.