Re: [PATCH 2/2] ntfs: preserve chmod mode before applying mount masks
Hyunchul Lee <[email protected]> Mon, 27 Jul 2026 10:48:22 +0900
| Newsgroups | dev.linux.lists.ntfs |
|---|---|
| Message-ID | <CANFS6bYsh2=9xK3LVSn7zKRFEK9D6kUnVTnpxbrZh2hnw+afww@mail.gmail.com> |
2026=EB=85=84 7=EC=9B=94 25=EC=9D=BC (=ED=86=A0) =EC=98=A4=EC=A0=84 12:49, = Namjae Jeon <[email protected]>=EB=8B=98=EC=9D=B4 =EC=9E=91=EC=84=B1: > > fmask and dmask must continue to constrain the effective permissions > of every file on a mount. Applying either mask before persisting an > ATTR_MODE change, however, stores the masked mode in . later remount with > a less restrictive mask then cannot restore the mode that chmod requested= . > > Store the requested mode in first, then apply the mount mask to > the in-memory inode. This retains the mount-wide access restriction > without making it permanent. Also return failures while writing the > WSL inode EA to the caller. > > Signed-off-by: Namjae Jeon <[email protected]> Looks good to me. Reviewed-by: Hyunchul Lee <[email protected]> > --- > fs/ntfs/file.c | 11 +++++++---- > 1 file changed, 7 insertions(+), 4 deletions(-) > > diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c > index c8e49f83fd92..a6855d62e1fc 100644 > --- a/fs/ntfs/file.c > +++ b/fs/ntfs/file.c > @@ -342,14 +342,17 @@ int ntfs_setattr(struct mnt_idmap *idmap, struct de= ntry *dentry, > if (ia_valid & ATTR_MODE) > flags |=3D NTFS_EA_MODE; > > + mutex_lock(&ni->mrec_lock); > + err =3D ntfs_ea_set_wsl_inode(vi, 0, NULL, flags); > + mutex_unlock(&ni->mrec_lock); > + if (err) > + goto out; > + > + /* Apply mount masks after saving the unmasked POSIX mode= . */ > if (S_ISDIR(vi->i_mode)) > vi->i_mode &=3D ~vol->dmask; > else > vi->i_mode &=3D ~vol->fmask; > - > - mutex_lock(&ni->mrec_lock); > - ntfs_ea_set_wsl_inode(vi, 0, NULL, flags); > - mutex_unlock(&ni->mrec_lock); > } > > mark_inode_dirty(vi); > -- > 2.25.1 > --=20 Thanks, Hyunchul