Add transitional get_only_masks selector in file_kattr for filesystems that want to advertise their read-only mask on GET but don't want to receive masked requests on SET. Use it in ovl_fileattr_get() to ask the VFS for unmasked SET if the underlying filesystem returns masks on GET, otherwise ovl_set_protattr() treats fa->flags as the full set of flags and clears IMMUTABLE/APPEND. Signed-off-by: koraynilay --- Amir, is this commit message correct? This is what I understood, but I'm not 100% sure. I wanted to mention the actual bugs fixed, but since I haven't understood them that much I didn't want to just leave the robot's explanation in the commit message :D Thanks. fs/file_attr.c | 2 +- fs/overlayfs/inode.c | 3 +++ include/linux/fileattr.h | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/file_attr.c b/fs/file_attr.c index 7bfd7651d1d8..7ca19364d8c9 100644 --- a/fs/file_attr.c +++ b/fs/file_attr.c @@ -401,7 +401,7 @@ static int fileattr_set_from_masks(struct file_kattr *fa, static int fileattr_set_convert(struct file_kattr *fa, const struct file_kattr *old_ma) { - bool fs_has_masks = old_ma->has_masks; + bool fs_has_masks = old_ma->has_masks && !old_ma->get_only_masks; if (fa->has_masks) { if (!fs_has_masks) diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c index 92df4f5c071e..8d4753fd2d92 100644 --- a/fs/overlayfs/inode.c +++ b/fs/overlayfs/inode.c @@ -747,6 +747,9 @@ int ovl_fileattr_get(struct dentry *dentry, struct file_kattr *fa) err = ovl_real_fileattr_get(&realpath, fa); ovl_fileattr_prot_flags(inode, fa); + if (!err && fa->has_masks) + fa->get_only_masks = true; + return err; } diff --git a/include/linux/fileattr.h b/include/linux/fileattr.h index 8dcabbb294fa..3a8a00545686 100644 --- a/include/linux/fileattr.h +++ b/include/linux/fileattr.h @@ -89,6 +89,8 @@ struct file_kattr { bool has_masks:1; /* struct has valid masks (get/set) */ bool use_masks:1; /* in-kernel callers need to set this to use masks (set) */ + bool get_only_masks:1;/* Transitional: filesystem doesn't support + rw_mask for set, but supports ro_mask on get */ }; int copy_fsxattr_to_user(const struct file_kattr *fa, struct fsxattr __user *ufa); -- 2.56.1.dirty