fs: reset read-only fsflags together with xflags
PATCH 1/1 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.
---
The shared read-only flag is going to be added for fsverity. The one for ->flags already exists.
[1]: https://lore.kernel.org/linux-xfs/[email protected]/
--- fs/file_attr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
fs/file_attr.c +2 -4
@@ -142,8 +142,7 @@ static int file_attr_to_fileattr(const struct file_attr *fattr,if (fattr->fa_xflags & ~mask)return -EINVAL ; -fileattr_fill_xflags (fa, fattr->fa_xflags); - fa->fsx_xflags &= ~FS_XFLAG_RDONLY_MASK ; +fileattr_fill_xflags (fa, fattr->fa_xflags & ~FS_XFLAG_RDONLY_MASK ); fa->fsx_extsize = fattr->fa_extsize; fa->fsx_projid = fattr->fa_projid; fa->fsx_cowextsize = fattr->fa_cowextsize;
@@ -163,8 +162,7 @@ static int copy_fsxattr_from_user(struct file_kattr *fa,if (xfa.fsx_xflags & ~mask)return -EOPNOTSUPP ; -fileattr_fill_xflags (fa, xfa.fsx_xflags); - fa->fsx_xflags &= ~FS_XFLAG_RDONLY_MASK ; +fileattr_fill_xflags (fa, xfa.fsx_xflags & ~FS_XFLAG_RDONLY_MASK ); fa->fsx_extsize = xfa.fsx_extsize; fa->fsx_nextents = xfa.fsx_nextents; fa->fsx_projid = xfa.fsx_projid;
Signature · 1 line
2.52.0
Quoted 6 lines · Andrey Albershteyn
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
^^ passed
Quoted 4 lines
to ->fileattr_set.
Reported-by Eric Biggers <[email protected]>Signed-off-by Andrey Albershteyn <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 38 lines
---
The shared read-only flag is going to be added for fsverity. The one for ->flags already exists.
[1]: https://lore.kernel.org/linux-xfs/[email protected]/
--- fs/file_attr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)fs/file_attr.c +2
-4@@ -142,8 +142,7 @@ static int file_attr_to_fileattr(const struct file_attr *fattr,if (fattr->fa_xflags & ~mask)return -EINVAL ; -fileattr_fill_xflags (fa, fattr->fa_xflags); - fa->fsx_xflags &= ~FS_XFLAG_RDONLY_MASK ; +fileattr_fill_xflags (fa, fattr->fa_xflags & ~FS_XFLAG_RDONLY_MASK ); fa->fsx_extsize = fattr->fa_extsize; fa->fsx_projid = fattr->fa_projid; fa->fsx_cowextsize = fattr->fa_cowextsize;@@ -163,8 +162,7 @@ static int copy_fsxattr_from_user(struct file_kattr *fa,if (xfa.fsx_xflags & ~mask)return -EOPNOTSUPP ; -fileattr_fill_xflags (fa, xfa.fsx_xflags); - fa->fsx_xflags &= ~FS_XFLAG_RDONLY_MASK ; +fileattr_fill_xflags (fa, xfa.fsx_xflags & ~FS_XFLAG_RDONLY_MASK ); fa->fsx_extsize = xfa.fsx_extsize; fa->fsx_nextents = xfa.fsx_nextents; fa->fsx_projid = xfa.fsx_projid;Signature · 1 line
2.52.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 9 lines · Andrey Albershteyn
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.[...]
Applied to the vfs-7.0.misc branch of the vfs/vfs.git tree. Patches in the vfs-7.0.misc branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs-7.0.misc
[1/1] fs: reset read-only fsflags together with xflags
https://git.kernel.org/vfs/vfs/c/9396bfdacb5a
Quoted 8 lines · Andrey Albershteyn
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.
Quoted 8 lines
Reported-by Eric Biggers <[email protected]>Signed-off-by Andrey Albershteyn <[email protected]>---
The shared read-only flag is going to be added for fsverity. The one for ->flags already exists.
- Eric