[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <175797569745.245695.6936544007331941052.stgit@frogsfrogsfrogs>
Date: Mon, 15 Sep 2025 15:39:32 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org, linux-ext4@...r.kernel.org
Subject: [PATCH 07/12] fuse2fs: fix fssetxattr flags updates
From: Darrick J. Wong <djwong@...nel.org>
Fix flags setting so that it actually works -- we need to preserve the
iflags bits that don't exist in xflags.
Cc: <linux-ext4@...r.kernel.org> # v1.47.3
Fixes: 9b5012c1569d4e ("fuse2fs: support getting and setting via struct fsxattr")
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
misc/fuse2fs.c | 30 ++++++++++++++++++++++++++++--
1 file changed, 28 insertions(+), 2 deletions(-)
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 4ebc949b53d1fe..de675b4ecb9438 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -3891,6 +3891,33 @@ static __u32 fsxflags_to_iflags(__u32 xflags)
return iflags;
}
+#define FUSE2FS_MODIFIABLE_XFLAGS (FS_XFLAG_IMMUTABLE | \
+ FS_XFLAG_APPEND | \
+ FS_XFLAG_SYNC | \
+ FS_XFLAG_NOATIME | \
+ FS_XFLAG_NODUMP | \
+ FS_XFLAG_PROJINHERIT)
+
+#define FUSE2FS_MODIFIABLE_IXFLAGS (FS_IMMUTABLE_FL | \
+ FS_APPEND_FL | \
+ FS_SYNC_FL | \
+ FS_NOATIME_FL | \
+ FS_NODUMP_FL | \
+ FS_PROJINHERIT_FL)
+
+static inline int set_xflags(struct ext2_inode_large *inode, __u32 xflags)
+{
+ __u32 iflags;
+
+ if (xflags & ~FUSE2FS_MODIFIABLE_XFLAGS)
+ return -EINVAL;
+
+ iflags = fsxflags_to_iflags(xflags);
+ inode->i_flags = (inode->i_flags & ~FUSE2FS_MODIFIABLE_IXFLAGS) |
+ (iflags & FUSE2FS_MODIFIABLE_IXFLAGS);
+ return 0;
+}
+
static int ioctl_fssetxattr(struct fuse2fs *ff, struct fuse2fs_file_handle *fh,
void *data)
{
@@ -3900,7 +3927,6 @@ static int ioctl_fssetxattr(struct fuse2fs *ff, struct fuse2fs_file_handle *fh,
int ret;
struct fuse_context *ctxt = fuse_get_context();
struct fsxattr *fsx = data;
- __u32 flags = fsxflags_to_iflags(fsx->fsx_xflags);
unsigned int inode_size;
FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC);
@@ -3912,7 +3938,7 @@ static int ioctl_fssetxattr(struct fuse2fs *ff, struct fuse2fs_file_handle *fh,
if (want_check_owner(ff, ctxt) && inode_uid(inode) != ctxt->uid)
return -EPERM;
- ret = set_iflags(&inode, flags);
+ ret = set_xflags(&inode, fsx->fsx_xflags);
if (ret)
return ret;
Powered by blists - more mailing lists