Skip to contentSkip to conversation

fs: set fsx_valid hint in file_getattr() syscall

PATCH In review Amir Goldstein 3 participants 4 messages Feb 10 – Feb 11

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

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().

Reported-by [email protected]
Fixes be7efb2d20d67 ("fs: introduce file_getattr and file_setattr syscalls")
Cc Andrey Albershteyn <[email protected]>
---
 fs/file_attr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/file_attr.c +1 -1
index 53b356dd8c33a..910c346d81bcd 100644
@@ -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
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · Amir Goldstein

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().

Quoted 6 lines
Reported-by [email protected]
Fixes be7efb2d20d67 ("fs: introduce file_getattr and file_setattr syscalls")
Cc Andrey Albershteyn <[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
index 53b356dd8c33a..910c346d81bcd 100644
@@ -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
Reviewed-by on v1 1/1
#2 lore raw
In reply to Amir Goldstein
Quoted 38 lines · Amir Goldstein

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().

Reported-by [email protected]
Fixes be7efb2d20d67 ("fs: introduce file_getattr and file_setattr syscalls")
Cc Andrey Albershteyn <[email protected]>
---
 fs/file_attr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/file_attr.c +1 -1
index 53b356dd8c33a..910c346d81bcd 100644
@@ -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
#3 lore raw
Quoted 36 lines · Andrey Albershteyn
Quoted 34 lines · Amir Goldstein

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().

Reported-by [email protected]
Fixes be7efb2d20d67 ("fs: introduce file_getattr and file_setattr syscalls")
Cc Andrey Albershteyn <[email protected]>
---
 fs/file_attr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/file_attr.c +1 -1
index 53b356dd8c33a..910c346d81bcd 100644
@@ -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 -1
      BUILD_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.