Skip to content

Commit 9396bfd

Browse files
alberandbrauner
authored andcommitted
fs: reset read-only fsflags together with xflags
While setting file attributes, the read-only flags are reset for ->xflags, but not for ->flags if flag is shared between both. This is fine for now as all read-only xflags don't overlap with flags. However, for any read-only shared flag this will create inconsistency between xflags and flags. The non-shared flag will be reset in vfs_fileattr_set() to the current value, but shared one is past further to ->fileattr_set. Reported-by: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org> Link: https://patch.msgid.link/20260121193645.3611716-1-aalbersh@kernel.org Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent fc94368 commit 9396bfd

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

fs/file_attr.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ static int file_attr_to_fileattr(const struct file_attr *fattr,
141141
if (fattr->fa_xflags & ~mask)
142142
return -EINVAL;
143143

144-
fileattr_fill_xflags(fa, fattr->fa_xflags);
145-
fa->fsx_xflags &= ~FS_XFLAG_RDONLY_MASK;
144+
fileattr_fill_xflags(fa, fattr->fa_xflags & ~FS_XFLAG_RDONLY_MASK);
146145
fa->fsx_extsize = fattr->fa_extsize;
147146
fa->fsx_projid = fattr->fa_projid;
148147
fa->fsx_cowextsize = fattr->fa_cowextsize;
@@ -162,8 +161,7 @@ static int copy_fsxattr_from_user(struct file_kattr *fa,
162161
if (xfa.fsx_xflags & ~mask)
163162
return -EOPNOTSUPP;
164163

165-
fileattr_fill_xflags(fa, xfa.fsx_xflags);
166-
fa->fsx_xflags &= ~FS_XFLAG_RDONLY_MASK;
164+
fileattr_fill_xflags(fa, xfa.fsx_xflags & ~FS_XFLAG_RDONLY_MASK);
167165
fa->fsx_extsize = xfa.fsx_extsize;
168166
fa->fsx_nextents = xfa.fsx_nextents;
169167
fa->fsx_projid = xfa.fsx_projid;

0 commit comments

Comments
 (0)