On Tue, Nov 24 2026, koraynilay wrote: > On Tue Nov 24, 2026 at 5:13 PM CET, Luis Henriques wrote: >> On Tue, Nov 24 2026, koraynilay wrote: >> >>> When using a FUSE mount over an underlying filesystem that supports >>> xflags, querying them from userspace with file_getattr() strips them >>> because file_getattr sets flags_valid = true so FUSE uses >>> FS_IOC_GETFLAGS instead of FS_IOC_FSGETXATTR. >>> >>> Fix it by setting fsx_valid = true instead. >>> >>> Output when using a simple FUSE mount that simply forwards the ioctls to >>> the underlying fs: >>> >>> before the fix: >>> >>> /xfs/file: FS_IOC_FSGETXATTR: ret=0, projid=69 >>> /xfs/file: file_getattr: ret=0, projid=0 >>> /ext4/file: FS_IOC_FSGETXATTR: ret=0, projid=42 >>> /ext4/file: file_getattr: ret=0, projid=0 >>> >>> after the fix: >>> >>> /xfs/file: FS_IOC_FSGETXATTR: ret=0, projid=69 >>> /xfs/file: file_getattr: ret=0, projid=69 >>> /ext4/file: FS_IOC_FSGETXATTR: ret=0, projid=42 >>> /ext4/file: file_getattr: ret=0, projid=42 >>> >>> Fixes: cb184dd19154 ("fs: init flags_valid before calling vfs_fileattr_get") >>> Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.5.11 >>> Signed-off-by: koraynilay >>> --- >>> Hi, I found this issue while working on the v2 of [1], here is the >>> reproducer, not in the commit message because of the size. > [...] >>> >>> [1]: https://lore.kernel.org/all/DN2YMTH77KWE.3IPE9OG8377X0@gmail.com/T/#t >>> >>> fs/file_attr.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/fs/file_attr.c b/fs/file_attr.c >>> index 833e03810b24..3b249a0a6b36 100644 >>> --- a/fs/file_attr.c >>> +++ b/fs/file_attr.c >>> @@ -383,7 +383,7 @@ SYSCALL_DEFINE5(file_getattr, int, dfd, const char __user *, filename, >>> struct path filepath __free(path_put) = {}; >>> unsigned int lookup_flags = 0; >>> struct file_attr fattr; >>> - struct file_kattr fa = { .flags_valid = true }; /* hint only */ >>> + struct file_kattr fa = { .fsx_valid = true }; /* hint only */ >> >> Isn't this reintroducing the bug that was fixed by commit >> >> cb184dd19154 ("fs: init flags_valid before calling vfs_fileattr_get") ? > > Hmm, it shouldn't, since that was just an uninitialized bug for the > whole struct, while now it's initialized (unless you meant something > else?). /me facepalms Sorry for the noise, I totally misread that fix :-( Cheers, -- Luís >> Maybe fuse_fileattr_get() shouldn't be handling FS_IOC_FSGETXATTR at all, >> and FS_IOC_FSGETXATTR handling should be moved into fuse_do_ioctl() >> instead? (Or, more likely, I'm missing something!) > > The bug being fixed is when using file_getattr tho, which in the vfs is > directly sent to inode->i_op->fileattr_get(dentry, fa), which for FUSE > is fuse_fileattr_get(). > > What should probably be done though (well, not in this patch) is switch > fuse_fileattr_get() from FS_IOC_FSGETXATTR to vfs_fileattr_get(), for > fsx_valid. > This is because while right now FS_IOC_FSGETXATTR is equivalent to > file_getattr VER0, in the [1] above it will be bumped to VER1, making > file_getattr VER1 a superset of file_getattr VER0. > > Thanks, > koraynilay > >> Cheers, > >