The common use of FS_IOC_GETFLAGS/SETFLAGS is get-modify-set loop. Filesystems could return verity status with GETFLAGS, attempting to then pass FS_VERITY_FL to SETFLAGS is not allowed. The ext4 and f2fs already treat FS_VERITY_FL in the set path as no-op, however, BTRFS returns -EOPNOTSUPP. So, the modification of other flags doesn't work on BTRFS for fsverity inodes. Fix it for BTRFS and anyone else, the ext4 and f2fs masking becomes no-op. The file_get/setattr() path is fine here as this flag is cleared right before fileattr_set_prepare(). The future fsverity support in XFS would also need it. Cc: Boris Burkov Cc: David Sterba Fixes: 146054090b08 ("btrfs: initial fsverity support") Signed-off-by: Andrey Albershteyn --- fs/file_attr.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/file_attr.c b/fs/file_attr.c index 833e03810b24..b43977d5f8e0 100644 --- a/fs/file_attr.c +++ b/fs/file_attr.c @@ -199,6 +199,16 @@ static int fileattr_set_prepare(struct inode *inode, if (err) return err; + /* + * verity is settable only via FS_IOC_ENABLE_VERITY; never through + * fileattr + * + * Treat it as a no-op so the FS_IOC_GETFLAGS/SETFLAGS round-trip + * doesn't break for other flags + */ + fa->flags &= ~FS_VERITY_FL; + fa->fsx_xflags &= ~FS_XFLAG_VERITY; + /* * Project Quota ID state is only allowed to change from within the init * namespace. Enforce that restriction only if we are trying to change -- 2.54.0