On Sun Dec 6, 2026 at 3:04 PM CET, Amir Goldstein wrote: > On Sun, Dec 6, 2026 at 3:00 PM koraynilay wrote: >> >> On Sun Dec 6, 2026 at 1:19 PM CET, Amir Goldstein wrote: >> > On Sat, Dec 5, 2026 at 3:24 PM koraynilay wrote: >> >> >> >> In preparation for the addition of masks to the fileattr API, switch >> >> fileattr_set_prepare() checks from using FS_*_FL flags to FS_XFLAG_* >> >> xflags and refactor project ID value check to be cleaner. >> >> >> >> Signed-off-by: koraynilay >> >> --- >> >> fs/file_attr.c | 30 ++++++++++++++++++++---------- >> >> 1 file changed, 20 insertions(+), 10 deletions(-) >> >> >> >> diff --git a/fs/file_attr.c b/fs/file_attr.c >> >> index 77e2f1bc22ad..c1a0272f1a83 100644 >> >> --- a/fs/file_attr.c >> >> +++ b/fs/file_attr.c >> >> @@ -74,6 +74,14 @@ void fileattr_fill_flags(struct file_kattr *fa, u32 flags) >> >> } >> >> EXPORT_SYMBOL(fileattr_fill_flags); >> >> >> >> +static u32 xflags_to_flags(u32 xflags) >> >> +{ >> >> + struct file_kattr tmp = {}; >> >> + >> >> + fileattr_fill_xflags(&tmp, xflags); >> >> + return tmp.flags; >> >> +} >> >> + >> >> /** >> >> * vfs_fileattr_get - retrieve miscellaneous file attributes >> >> * @dentry: the object to retrieve from >> >> @@ -201,17 +209,20 @@ static int fileattr_set_prepare(struct inode *inode, >> >> const struct file_kattr *old_ma, >> >> struct file_kattr *fa) >> >> { >> >> + u32 changed = (fa->fsx_xflags ^ old_ma->fsx_xflags) & FSX_FSXATTR_MASK; >> >> int err; >> >> >> >> /* >> >> * The IMMUTABLE and APPEND_ONLY flags can only be changed by >> >> * the relevant capability. >> >> */ >> >> - if ((fa->flags ^ old_ma->flags) & (FS_APPEND_FL | FS_IMMUTABLE_FL) && >> >> + if (changed & (FS_XFLAG_APPEND | FS_XFLAG_IMMUTABLE) && >> >> !capable(CAP_LINUX_IMMUTABLE)) >> >> return -EPERM; >> >> >> >> - err = fscrypt_prepare_setflags(inode, old_ma->flags, fa->flags); >> >> + err = fscrypt_prepare_setflags(inode, >> >> + xflags_to_flags(old_ma->fsx_xflags), >> >> + xflags_to_flags(fa->fsx_xflags)); >> > >> > Why is this needed? >> > fa->flags and old_ma->flags are kept in sync with fsx_xflags by the >> > VFS in all paths, >> Right, >> > including the masks conversions, >> > and fscrypt only cares about a newly set CASEFOLD flag. >> > I think this hunk can be dropped and xflags_to_flags() can be introduced >> > in the patch that first needs it. >> >> but wouldn't it be better to keep it for consistency, since from now on >> set_prepare should only handle xflags, and not rely on the assumption >> that flags is kept up to date? >> >> Though since right now it is kept up to date in all paths, we would just >> need to be careful in later patches and wait until fscrypt_prepare_setflags >> is switched to xflags (?). >> > > I think it need to be switched to xlags with signature and name change > as we discussed in v2, but for now, I think it is a bit of an overkill, so > a simple TODO: comment will do and no need for the xflags_to_flags(). Ok that makes sense, will do that. Thanks, koraynilay > Thanks, > Amir.