]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fs: port ->set_acl() to pass mnt_idmap
authorChristian Brauner <brauner@kernel.org>
Fri, 13 Jan 2023 11:49:20 +0000 (12:49 +0100)
committerChristian Brauner (Microsoft) <brauner@kernel.org>
Thu, 19 Jan 2023 08:24:27 +0000 (09:24 +0100)
Convert to struct mnt_idmap.

Last cycle we merged the necessary infrastructure in
256c8aed2b42 ("fs: introduce dedicated idmap type for mounts").
This is just the conversion to struct mnt_idmap.

Currently we still pass around the plain namespace that was attached to a
mount. This is in general pretty convenient but it makes it easy to
conflate namespaces that are relevant on the filesystem with namespaces
that are relevent on the mount level. Especially for non-vfs developers
without detailed knowledge in this area this can be a potential source for
bugs.

Once the conversion to struct mnt_idmap is done all helpers down to the
really low-level helpers will take a struct mnt_idmap argument instead of
two namespace arguments. This way it becomes impossible to conflate the two
eliminating the possibility of any bugs. All of the vfs and all filesystems
only operate on struct mnt_idmap.

Acked-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
62 files changed:
Documentation/filesystems/vfs.rst
fs/9p/acl.c
fs/9p/acl.h
fs/bad_inode.c
fs/btrfs/acl.c
fs/btrfs/acl.h
fs/btrfs/inode.c
fs/ceph/acl.c
fs/ceph/inode.c
fs/ceph/super.h
fs/cifs/cifsacl.c
fs/cifs/cifsproto.h
fs/ecryptfs/inode.c
fs/ext2/acl.c
fs/ext2/acl.h
fs/ext2/inode.c
fs/ext4/acl.c
fs/ext4/acl.h
fs/ext4/inode.c
fs/f2fs/acl.c
fs/f2fs/acl.h
fs/f2fs/file.c
fs/fuse/acl.c
fs/fuse/fuse_i.h
fs/gfs2/acl.c
fs/gfs2/acl.h
fs/gfs2/inode.c
fs/jffs2/acl.c
fs/jffs2/acl.h
fs/jffs2/fs.c
fs/jfs/acl.c
fs/jfs/file.c
fs/jfs/jfs_acl.h
fs/ksmbd/smb2pdu.c
fs/ksmbd/smbacl.c
fs/ksmbd/vfs.c
fs/ksmbd/vfs.h
fs/nfs/nfs3_fs.h
fs/nfs/nfs3acl.c
fs/nfsd/nfs2acl.c
fs/nfsd/nfs3acl.c
fs/nfsd/vfs.c
fs/ntfs3/file.c
fs/ntfs3/ntfs_fs.h
fs/ntfs3/xattr.c
fs/ocfs2/acl.c
fs/ocfs2/acl.h
fs/orangefs/acl.c
fs/orangefs/inode.c
fs/orangefs/orangefs-kernel.h
fs/overlayfs/inode.c
fs/overlayfs/overlayfs.h
fs/posix_acl.c
fs/reiserfs/acl.h
fs/reiserfs/xattr_acl.c
fs/xattr.c
fs/xfs/xfs_acl.c
fs/xfs/xfs_acl.h
fs/xfs/xfs_iops.c
include/linux/fs.h
include/linux/posix_acl.h
mm/shmem.c

index 056e446c70e0e9547fcf61d365769c69e9bd4f5c..19afe53f7060c848cc062b46b18cec167fc1de76 100644 (file)
@@ -444,7 +444,7 @@ As of kernel 2.6.22, the following members are defined:
                                   unsigned open_flag, umode_t create_mode);
                int (*tmpfile) (struct mnt_idmap *, struct inode *, struct file *, umode_t);
                struct posix_acl * (*get_acl)(struct mnt_idmap *, struct dentry *, int);
-               int (*set_acl)(struct user_namespace *, struct dentry *, struct posix_acl *, int);
+               int (*set_acl)(struct mnt_idmap *, struct dentry *, struct posix_acl *, int);
                int (*fileattr_set)(struct user_namespace *mnt_userns,
                                    struct dentry *dentry, struct fileattr *fa);
                int (*fileattr_get)(struct dentry *dentry, struct fileattr *fa);
index cfd4545f2d02e4e339606e4f6ea67cc6b2dd7fa1..ae278016ae954134ca38334772a878aced727772 100644 (file)
@@ -151,7 +151,7 @@ struct posix_acl *v9fs_iop_get_acl(struct mnt_idmap *idmap,
        return v9fs_get_cached_acl(d_inode(dentry), type);
 }
 
-int v9fs_iop_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int v9fs_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                     struct posix_acl *acl, int type)
 {
        int retval;
index e0e58967d91629a422dfbe10214f2996737a0f9a..333cfcc281da44fe166f0e3af68bb21dfb1c4220 100644 (file)
@@ -12,7 +12,7 @@ struct posix_acl *v9fs_iop_get_inode_acl(struct inode *inode, int type,
                                   bool rcu);
 struct posix_acl *v9fs_iop_get_acl(struct mnt_idmap *idmap,
                                          struct dentry *dentry, int type);
-int v9fs_iop_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int v9fs_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                     struct posix_acl *acl, int type);
 int v9fs_acl_chmod(struct inode *inode, struct p9_fid *fid);
 int v9fs_set_create_acl(struct inode *inode, struct p9_fid *fid,
index 4bdf40b187ff258b98730d3ad38e991220263298..350ad34611291cafe2ed321e37545ad47733c6b8 100644 (file)
@@ -153,7 +153,7 @@ static int bad_inode_tmpfile(struct mnt_idmap *idmap,
        return -EIO;
 }
 
-static int bad_inode_set_acl(struct user_namespace *mnt_userns,
+static int bad_inode_set_acl(struct mnt_idmap *idmap,
                             struct dentry *dentry, struct posix_acl *acl,
                             int type)
 {
index 3da1779e8b795cfb1da9c6e64c5b0340b6d1a8f8..7a3ab7e4b1637f1ab6a764aa70dd9683488234f3 100644 (file)
@@ -110,10 +110,11 @@ out:
        return ret;
 }
 
-int btrfs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                  struct posix_acl *acl, int type)
 {
        int ret;
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        struct inode *inode = d_inode(dentry);
        umode_t old_mode = inode->i_mode;
 
index 39bd36e6eeb7e0f63afc2362ce0a99b838fa1331..a270e71ec05f9125b53799ec080e9723e433d608 100644 (file)
@@ -6,7 +6,7 @@
 #ifdef CONFIG_BTRFS_FS_POSIX_ACL
 
 struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu);
-int btrfs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                  struct posix_acl *acl, int type);
 int __btrfs_set_acl(struct btrfs_trans_handle *trans, struct inode *inode,
                    struct posix_acl *acl, int type);
index c10157a5a6f80ab4be3eae55bd0348f4a1de5467..6a74767b12cb4d8fb47c34836dbe77e91893bb7e 100644 (file)
@@ -5307,8 +5307,7 @@ static int btrfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
                err = btrfs_dirty_inode(BTRFS_I(inode));
 
                if (!err && attr->ia_valid & ATTR_MODE)
-                       err = posix_acl_chmod(mnt_idmap_owner(idmap), dentry,
-                                             inode->i_mode);
+                       err = posix_acl_chmod(idmap, dentry, inode->i_mode);
        }
 
        return err;
index c7e8dd5b58d47a928d0e6bedfc18a4b3f3b6a6e3..59a05fd259f0bcc95e453c9e77ec7a5dcd4fe42c 100644 (file)
@@ -85,7 +85,7 @@ retry:
        return acl;
 }
 
-int ceph_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                 struct posix_acl *acl, int type)
 {
        int ret = 0, size = 0;
index fcc84cc1d8f185c2afd1a05abcd62f8518d14238..d9ae943423afc8b6abe3ebe1cd65f9bed9236c3f 100644 (file)
@@ -2255,7 +2255,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
        err = __ceph_setattr(inode, attr);
 
        if (err >= 0 && (attr->ia_valid & ATTR_MODE))
-               err = posix_acl_chmod(&init_user_ns, dentry, attr->ia_mode);
+               err = posix_acl_chmod(&nop_mnt_idmap, dentry, attr->ia_mode);
 
        return err;
 }
index 063dad749a079365e687d771cb6fa7a5510abf7d..51c6c10e03751e098713afc2a97cb93f65ae8a2f 100644 (file)
@@ -1118,7 +1118,7 @@ void ceph_release_acl_sec_ctx(struct ceph_acl_sec_ctx *as_ctx);
 #ifdef CONFIG_CEPH_FS_POSIX_ACL
 
 struct posix_acl *ceph_get_acl(struct inode *, int, bool);
-int ceph_set_acl(struct user_namespace *mnt_userns,
+int ceph_set_acl(struct mnt_idmap *idmap,
                 struct dentry *dentry, struct posix_acl *acl, int type);
 int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
                       struct ceph_acl_sec_ctx *as_ctx);
index 1fae9b60e48f031cb6aee5c231f76808e689e3c9..9a2d390bd06f23e3ab28556a1c1b0d83b9e2359e 100644 (file)
@@ -1738,7 +1738,7 @@ out:
 #endif
 }
 
-int cifs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int cifs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                 struct posix_acl *acl, int type)
 {
 #if defined(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) && defined(CONFIG_CIFS_POSIX)
index aeae6544cdd83692edb9a0289df3d07bad4ab6bc..b8a47704a6efb00cc4b7c780651672cf0f25288c 100644 (file)
@@ -227,7 +227,7 @@ extern struct cifs_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *,
                                const struct cifs_fid *, u32 *, u32);
 extern struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap,
                                      struct dentry *dentry, int type);
-extern int cifs_set_acl(struct user_namespace *mnt_userns,
+extern int cifs_set_acl(struct mnt_idmap *idmap,
                        struct dentry *dentry, struct posix_acl *acl, int type);
 extern int set_cifs_acl(struct cifs_ntsd *, __u32, struct inode *,
                                const char *, int);
index 8487ac0cc2395110aa8337ab84fed2872b0cf16b..b62351b7ad6a49fd4095aec4124f963621f21026 100644 (file)
@@ -1129,7 +1129,7 @@ static struct posix_acl *ecryptfs_get_acl(struct mnt_idmap *idmap,
                           posix_acl_xattr_name(type));
 }
 
-static int ecryptfs_set_acl(struct user_namespace *mnt_userns,
+static int ecryptfs_set_acl(struct mnt_idmap *idmap,
                            struct dentry *dentry, struct posix_acl *acl,
                            int type)
 {
@@ -1137,7 +1137,7 @@ static int ecryptfs_set_acl(struct user_namespace *mnt_userns,
        struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
        struct inode *lower_inode = d_inode(lower_dentry);
 
-       rc = vfs_set_acl(&init_user_ns, lower_dentry,
+       rc = vfs_set_acl(&nop_mnt_idmap, lower_dentry,
                         posix_acl_xattr_name(type), acl);
        if (!rc)
                fsstack_copy_attr_all(d_inode(dentry), lower_inode);
index 440d5f1e9d479ff9e2bf7040f1a3f6f97fe1be35..f20953c7ec654e0859252dce6e33a933317acaf7 100644 (file)
@@ -219,7 +219,7 @@ __ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
  * inode->i_mutex: down
  */
 int
-ext2_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+ext2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
             struct posix_acl *acl, int type)
 {
        int error;
index 3841becb94ff0589ed33c2f335deb70b253d3869..4a8443a2b8ec79e698771c9a4c0828cef21561a5 100644 (file)
@@ -56,7 +56,7 @@ static inline int ext2_acl_count(size_t size)
 
 /* acl.c */
 extern struct posix_acl *ext2_get_acl(struct inode *inode, int type, bool rcu);
-extern int ext2_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+extern int ext2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                        struct posix_acl *acl, int type);
 extern int ext2_init_acl (struct inode *, struct inode *);
 
index bbc9941dbb432814db8de8c3d94906799369f181..fb7fdadefd3d0b8cbc58aaa42d7d75372de63624 100644 (file)
@@ -1647,7 +1647,7 @@ int ext2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
        }
        setattr_copy(&nop_mnt_idmap, inode, iattr);
        if (iattr->ia_valid & ATTR_MODE)
-               error = posix_acl_chmod(&init_user_ns, dentry, inode->i_mode);
+               error = posix_acl_chmod(&nop_mnt_idmap, dentry, inode->i_mode);
        mark_inode_dirty(inode);
 
        return error;
index a9f89539aeeea6da5c38057af9e80bc81254f3cb..05139feb728249115d772072a99cbf9dbdc2b567 100644 (file)
@@ -225,9 +225,10 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int type,
 }
 
 int
-ext4_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+ext4_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
             struct posix_acl *acl, int type)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        handle_t *handle;
        int error, credits, retries = 0;
        size_t acl_size = acl ? ext4_acl_size(acl->a_count) : 0;
index 09c4a8a3b71647fe0781c199ae64b425337c37fd..0c5a79c3b5d4806f9a76241c7fd1ee5a971b9dba 100644 (file)
@@ -56,7 +56,7 @@ static inline int ext4_acl_count(size_t size)
 
 /* acl.c */
 struct posix_acl *ext4_get_acl(struct inode *inode, int type, bool rcu);
-int ext4_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int ext4_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                 struct posix_acl *acl, int type);
 extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
 
index d60eab65319d9342c2f561dc2f62bd89f7d17f57..3aae0be8c91e59d7d3f773cb0c0e281e8ded03d4 100644 (file)
@@ -5643,7 +5643,7 @@ out_mmap_sem:
                ext4_orphan_del(NULL, inode);
 
        if (!error && (ia_valid & ATTR_MODE))
-               rc = posix_acl_chmod(mnt_userns, dentry, inode->i_mode);
+               rc = posix_acl_chmod(idmap, dentry, inode->i_mode);
 
 err_out:
        if  (error)
index c1c74aa658ae0d0ba0c64ebec1b6af0b99f97ebd..6ced63bce4e4dc2ec557f6fd71405075547633c1 100644 (file)
@@ -276,9 +276,10 @@ static int __f2fs_set_acl(struct user_namespace *mnt_userns,
        return error;
 }
 
-int f2fs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int f2fs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                 struct posix_acl *acl, int type)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        struct inode *inode = d_inode(dentry);
 
        if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
index ea2bbb3f264b6eef06cc16bec0c41028809c4cae..94ebfbfbdc6f94e57271d8862d2808bae46eb31d 100644 (file)
@@ -34,7 +34,7 @@ struct f2fs_acl_header {
 #ifdef CONFIG_F2FS_FS_POSIX_ACL
 
 extern struct posix_acl *f2fs_get_acl(struct inode *, int, bool);
-extern int f2fs_set_acl(struct user_namespace *, struct dentry *,
+extern int f2fs_set_acl(struct mnt_idmap *, struct dentry *,
                        struct posix_acl *, int);
 extern int f2fs_init_acl(struct inode *, struct inode *, struct page *,
                                                        struct page *);
index 267507ff16ccca373d60f9dfd59c4e5e524d4f80..a5e936a6225ad16f8c9718339b710e4ead0cdc40 100644 (file)
@@ -1028,7 +1028,7 @@ int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
        __setattr_copy(idmap, inode, attr);
 
        if (attr->ia_valid & ATTR_MODE) {
-               err = posix_acl_chmod(mnt_userns, dentry, f2fs_get_inode_mode(inode));
+               err = posix_acl_chmod(idmap, dentry, f2fs_get_inode_mode(inode));
 
                if (is_inode_flag_set(inode, FI_ACL_MODE)) {
                        if (!err)
index a4850aee2639ff819d244f1869d34c22e92f324c..4eb9adefa91464befae9051c3fc5bb2a8818153a 100644 (file)
@@ -53,7 +53,7 @@ struct posix_acl *fuse_get_acl(struct inode *inode, int type, bool rcu)
        return acl;
 }
 
-int fuse_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                 struct posix_acl *acl, int type)
 {
        struct inode *inode = d_inode(dentry);
index c673faefdcb9c253cdbe3851e8de6de2e612787c..570941be0fd0ffa3a2ae6b79c42976832514fdca 100644 (file)
@@ -1269,7 +1269,7 @@ extern const struct xattr_handler *fuse_no_acl_xattr_handlers[];
 
 struct posix_acl;
 struct posix_acl *fuse_get_acl(struct inode *inode, int type, bool rcu);
-int fuse_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                 struct posix_acl *acl, int type);
 
 /* readdir.c */
index 3dcde49124131cd3a755975fd5797f1f27d087f7..e2a79d7e5605fb1d07f4e396c9134eb376a03292 100644 (file)
@@ -109,7 +109,7 @@ out:
        return error;
 }
 
-int gfs2_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int gfs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                 struct posix_acl *acl, int type)
 {
        struct inode *inode = d_inode(dentry);
index b8de8c148f5c0c68e9c0be4c6737a1ad50b1b64a..d4deb2b1995952dabbd50a892f500f355445d9a4 100644 (file)
@@ -13,7 +13,7 @@
 
 extern struct posix_acl *gfs2_get_acl(struct inode *inode, int type, bool rcu);
 extern int __gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type);
-extern int gfs2_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+extern int gfs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                        struct posix_acl *acl, int type);
 
 #endif /* __ACL_DOT_H__ */
index f4af5580780883c82b7163aedb8b71ef1360b6d7..0818d4e25d7503a82ba51a7935f39ea51ae95c0c 100644 (file)
@@ -2007,7 +2007,7 @@ static int gfs2_setattr(struct mnt_idmap *idmap,
        else {
                error = gfs2_setattr_simple(inode, attr);
                if (!error && attr->ia_valid & ATTR_MODE)
-                       error = posix_acl_chmod(&init_user_ns, dentry,
+                       error = posix_acl_chmod(&nop_mnt_idmap, dentry,
                                                inode->i_mode);
        }
 
index 8bb58ce5c06c6bb3ecf7e6345be68de1d14e756f..672eaf51a66db7eb4e37d9da2843184b44a7c430 100644 (file)
@@ -229,7 +229,7 @@ static int __jffs2_set_acl(struct inode *inode, int xprefix, struct posix_acl *a
        return rc;
 }
 
-int jffs2_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int jffs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                  struct posix_acl *acl, int type)
 {
        int rc, xprefix;
index ca36a6eca5949ad2706ea202b10fa99978357fc9..e976b8cb82cf914d553bce6c26b153621b25bbba 100644 (file)
@@ -28,7 +28,7 @@ struct jffs2_acl_header {
 #ifdef CONFIG_JFFS2_FS_POSIX_ACL
 
 struct posix_acl *jffs2_get_acl(struct inode *inode, int type, bool rcu);
-int jffs2_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int jffs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                  struct posix_acl *acl, int type);
 extern int jffs2_init_acl_pre(struct inode *, struct inode *, umode_t *);
 extern int jffs2_init_acl_post(struct inode *);
index 28f7eea4c46d5e5a1132c0a4620a1118e1e42989..09174898efd008d1b9a2939ee48a3a736931aeff 100644 (file)
@@ -202,7 +202,7 @@ int jffs2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
 
        rc = jffs2_do_setattr(inode, iattr);
        if (!rc && (iattr->ia_valid & ATTR_MODE))
-               rc = posix_acl_chmod(&init_user_ns, dentry, inode->i_mode);
+               rc = posix_acl_chmod(&nop_mnt_idmap, dentry, inode->i_mode);
 
        return rc;
 }
index 3b667eccc73b75ebabca0f9000b9340854ab257a..25b78dd8209942a4cd87e4225aaebf21f5227d9f 100644 (file)
@@ -94,7 +94,7 @@ out:
        return rc;
 }
 
-int jfs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int jfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                struct posix_acl *acl, int type)
 {
        int rc;
index 8cda5d8112650f550b3a4dbe1d11f90ce70d2e8c..c2cfb8033b1f8937070f679bb35d8eaaf6b2e409 100644 (file)
@@ -123,7 +123,7 @@ int jfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
        mark_inode_dirty(inode);
 
        if (iattr->ia_valid & ATTR_MODE)
-               rc = posix_acl_chmod(&init_user_ns, dentry, inode->i_mode);
+               rc = posix_acl_chmod(&nop_mnt_idmap, dentry, inode->i_mode);
        return rc;
 }
 
index f0704a25835f58924f0328f3006ab955c681a7b2..f892e54d0fcd2d0a956beb9cd9811310ffdc063b 100644 (file)
@@ -8,7 +8,7 @@
 #ifdef CONFIG_JFS_POSIX_ACL
 
 struct posix_acl *jfs_get_acl(struct inode *inode, int type, bool rcu);
-int jfs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int jfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                struct posix_acl *acl, int type);
 int jfs_init_acl(tid_t, struct inode *, struct inode *);
 
index ba8146f39adb9e078aabe42fc4ae785cf755f0dc..50d049bb84defb51794b3821c005b1b1df13c97a 100644 (file)
@@ -2512,6 +2512,7 @@ int smb2_open(struct ksmbd_work *work)
        struct ksmbd_share_config *share = tcon->share_conf;
        struct ksmbd_file *fp = NULL;
        struct file *filp = NULL;
+       struct mnt_idmap *idmap = NULL;
        struct user_namespace *user_ns = NULL;
        struct kstat stat;
        struct create_context *context;
@@ -2765,7 +2766,8 @@ int smb2_open(struct ksmbd_work *work)
                rc = 0;
        } else {
                file_present = true;
-               user_ns = mnt_user_ns(path.mnt);
+               idmap = mnt_idmap(path.mnt);
+               user_ns = mnt_idmap_owner(idmap);
        }
        if (stream_name) {
                if (req->CreateOptions & FILE_DIRECTORY_FILE_LE) {
@@ -2864,7 +2866,8 @@ int smb2_open(struct ksmbd_work *work)
                }
 
                created = true;
-               user_ns = mnt_user_ns(path.mnt);
+               idmap = mnt_idmap(path.mnt);
+               user_ns = mnt_idmap_owner(idmap);
                if (ea_buf) {
                        if (le32_to_cpu(ea_buf->ccontext.DataLength) <
                            sizeof(struct smb2_ea_info)) {
@@ -2957,7 +2960,7 @@ int smb2_open(struct ksmbd_work *work)
                int posix_acl_rc;
                struct inode *inode = d_inode(path.dentry);
 
-               posix_acl_rc = ksmbd_vfs_inherit_posix_acl(user_ns,
+               posix_acl_rc = ksmbd_vfs_inherit_posix_acl(idmap,
                                                           path.dentry,
                                                           d_inode(path.dentry->d_parent));
                if (posix_acl_rc)
@@ -2973,7 +2976,7 @@ int smb2_open(struct ksmbd_work *work)
                        rc = smb2_create_sd_buffer(work, req, &path);
                        if (rc) {
                                if (posix_acl_rc)
-                                       ksmbd_vfs_set_init_posix_acl(user_ns,
+                                       ksmbd_vfs_set_init_posix_acl(idmap,
                                                                     path.dentry);
 
                                if (test_share_config_flag(work->tcon->share_conf,
index 6490342bbb386e2c62be879a26e77290e9bd760b..6e144880eeffb8fe1e0891670d9c3ea824ccd7e4 100644 (file)
@@ -1384,17 +1384,17 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
        newattrs.ia_valid |= ATTR_MODE;
        newattrs.ia_mode = (inode->i_mode & ~0777) | (fattr.cf_mode & 0777);
 
-       ksmbd_vfs_remove_acl_xattrs(user_ns, path->dentry);
+       ksmbd_vfs_remove_acl_xattrs(idmap, path->dentry);
        /* Update posix acls */
        if (IS_ENABLED(CONFIG_FS_POSIX_ACL) && fattr.cf_dacls) {
-               rc = set_posix_acl(user_ns, path->dentry,
+               rc = set_posix_acl(idmap, path->dentry,
                                   ACL_TYPE_ACCESS, fattr.cf_acls);
                if (rc < 0)
                        ksmbd_debug(SMB,
                                    "Set posix acl(ACL_TYPE_ACCESS) failed, rc : %d\n",
                                    rc);
                if (S_ISDIR(inode->i_mode) && fattr.cf_dacls) {
-                       rc = set_posix_acl(user_ns, path->dentry,
+                       rc = set_posix_acl(idmap, path->dentry,
                                           ACL_TYPE_DEFAULT, fattr.cf_dacls);
                        if (rc)
                                ksmbd_debug(SMB,
index cf60e62d6e73029d39ebe81b1f2f4a6202a15133..21f420d21b3edd50ec1a6401fda7900a430caaae 100644 (file)
@@ -1305,7 +1305,7 @@ struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,
        return dent;
 }
 
-int ksmbd_vfs_remove_acl_xattrs(struct user_namespace *user_ns,
+int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
                                struct dentry *dentry)
 {
        char *name, *xattr_list = NULL;
@@ -1328,7 +1328,7 @@ int ksmbd_vfs_remove_acl_xattrs(struct user_namespace *user_ns,
                             sizeof(XATTR_NAME_POSIX_ACL_ACCESS) - 1) ||
                    !strncmp(name, XATTR_NAME_POSIX_ACL_DEFAULT,
                             sizeof(XATTR_NAME_POSIX_ACL_DEFAULT) - 1)) {
-                       err = vfs_remove_acl(user_ns, dentry, name);
+                       err = vfs_remove_acl(idmap, dentry, name);
                        if (err)
                                ksmbd_debug(SMB,
                                            "remove acl xattr failed : %s\n", name);
@@ -1830,7 +1830,7 @@ void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock)
        locks_delete_block(flock);
 }
 
-int ksmbd_vfs_set_init_posix_acl(struct user_namespace *user_ns,
+int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
                                 struct dentry *dentry)
 {
        struct posix_acl_state acl_state;
@@ -1864,13 +1864,13 @@ int ksmbd_vfs_set_init_posix_acl(struct user_namespace *user_ns,
                return -ENOMEM;
        }
        posix_state_to_acl(&acl_state, acls->a_entries);
-       rc = set_posix_acl(user_ns, dentry, ACL_TYPE_ACCESS, acls);
+       rc = set_posix_acl(idmap, dentry, ACL_TYPE_ACCESS, acls);
        if (rc < 0)
                ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_ACCESS) failed, rc : %d\n",
                            rc);
        else if (S_ISDIR(inode->i_mode)) {
                posix_state_to_acl(&acl_state, acls->a_entries);
-               rc = set_posix_acl(user_ns, dentry, ACL_TYPE_DEFAULT, acls);
+               rc = set_posix_acl(idmap, dentry, ACL_TYPE_DEFAULT, acls);
                if (rc < 0)
                        ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_DEFAULT) failed, rc : %d\n",
                                    rc);
@@ -1880,7 +1880,7 @@ int ksmbd_vfs_set_init_posix_acl(struct user_namespace *user_ns,
        return rc;
 }
 
-int ksmbd_vfs_inherit_posix_acl(struct user_namespace *user_ns,
+int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap,
                                struct dentry *dentry, struct inode *parent_inode)
 {
        struct posix_acl *acls;
@@ -1903,12 +1903,12 @@ int ksmbd_vfs_inherit_posix_acl(struct user_namespace *user_ns,
                }
        }
 
-       rc = set_posix_acl(user_ns, dentry, ACL_TYPE_ACCESS, acls);
+       rc = set_posix_acl(idmap, dentry, ACL_TYPE_ACCESS, acls);
        if (rc < 0)
                ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_ACCESS) failed, rc : %d\n",
                            rc);
        if (S_ISDIR(inode->i_mode)) {
-               rc = set_posix_acl(user_ns, dentry, ACL_TYPE_DEFAULT,
+               rc = set_posix_acl(idmap, dentry, ACL_TYPE_DEFAULT,
                                   acls);
                if (rc < 0)
                        ksmbd_debug(SMB, "Set posix acl(ACL_TYPE_DEFAULT) failed, rc : %d\n",
index 619304b08a7fe9e5bc6c89ea3e9fab34c4648e30..1f8c5ac03041247ea80505316d599829c1f0a77f 100644 (file)
@@ -141,7 +141,7 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
 void ksmbd_vfs_posix_lock_wait(struct file_lock *flock);
 int ksmbd_vfs_posix_lock_wait_timeout(struct file_lock *flock, long timeout);
 void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock);
-int ksmbd_vfs_remove_acl_xattrs(struct user_namespace *user_ns,
+int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
                                struct dentry *dentry);
 int ksmbd_vfs_remove_sd_xattrs(struct user_namespace *user_ns,
                               struct dentry *dentry);
@@ -159,9 +159,9 @@ int ksmbd_vfs_set_dos_attrib_xattr(struct user_namespace *user_ns,
 int ksmbd_vfs_get_dos_attrib_xattr(struct user_namespace *user_ns,
                                   struct dentry *dentry,
                                   struct xattr_dos_attrib *da);
-int ksmbd_vfs_set_init_posix_acl(struct user_namespace *user_ns,
+int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
                                 struct dentry *dentry);
-int ksmbd_vfs_inherit_posix_acl(struct user_namespace *user_ns,
+int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap,
                                struct dentry *dentry,
                                struct inode *parent_inode);
 #endif /* __KSMBD_VFS_H__ */
index df9ca56db347022132e3e9e2109beca4e67af260..4fa37dc038b58f1038f0cdeac06823f85976e63e 100644 (file)
@@ -12,7 +12,7 @@
  */
 #ifdef CONFIG_NFS_V3_ACL
 extern struct posix_acl *nfs3_get_acl(struct inode *inode, int type, bool rcu);
-extern int nfs3_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+extern int nfs3_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                        struct posix_acl *acl, int type);
 extern int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
                struct posix_acl *dfacl);
index 74d11e3c420555ea35ede04248f56630766c388b..1247f544a440e41303637a252d864eeb97b990fb 100644 (file)
@@ -255,7 +255,7 @@ int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
 
 }
 
-int nfs3_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int nfs3_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                 struct posix_acl *acl, int type)
 {
        struct posix_acl *orig = acl, *dfacl = NULL, *alloc;
index 1457f59f447a415f1e2e518045655f1c56257bfe..995cb2c90b1a0d5628253516a2508d73b4d47684 100644 (file)
@@ -113,11 +113,11 @@ static __be32 nfsacld_proc_setacl(struct svc_rqst *rqstp)
 
        inode_lock(inode);
 
-       error = set_posix_acl(&init_user_ns, fh->fh_dentry, ACL_TYPE_ACCESS,
+       error = set_posix_acl(&nop_mnt_idmap, fh->fh_dentry, ACL_TYPE_ACCESS,
                              argp->acl_access);
        if (error)
                goto out_drop_lock;
-       error = set_posix_acl(&init_user_ns, fh->fh_dentry, ACL_TYPE_DEFAULT,
+       error = set_posix_acl(&nop_mnt_idmap, fh->fh_dentry, ACL_TYPE_DEFAULT,
                              argp->acl_default);
        if (error)
                goto out_drop_lock;
index 647108138e8abf401ff0044ebb06086b73a297bb..887803735e2ae6cfb56895ad8fa0dd064b4169e3 100644 (file)
@@ -103,11 +103,11 @@ static __be32 nfsd3_proc_setacl(struct svc_rqst *rqstp)
 
        inode_lock(inode);
 
-       error = set_posix_acl(&init_user_ns, fh->fh_dentry, ACL_TYPE_ACCESS,
+       error = set_posix_acl(&nop_mnt_idmap, fh->fh_dentry, ACL_TYPE_ACCESS,
                              argp->acl_access);
        if (error)
                goto out_drop_lock;
-       error = set_posix_acl(&init_user_ns, fh->fh_dentry, ACL_TYPE_DEFAULT,
+       error = set_posix_acl(&nop_mnt_idmap, fh->fh_dentry, ACL_TYPE_DEFAULT,
                              argp->acl_default);
 
 out_drop_lock:
index 371d7f03fe2dac6d0fef5d90b61f78c67e6f5850..66517ad6ac137c482d43f73b84b4141e2def44b8 100644 (file)
@@ -542,12 +542,12 @@ nfsd_setattr(struct svc_rqst *rqstp, struct svc_fh *fhp,
                attr->na_labelerr = security_inode_setsecctx(dentry,
                        attr->na_seclabel->data, attr->na_seclabel->len);
        if (IS_ENABLED(CONFIG_FS_POSIX_ACL) && attr->na_pacl)
-               attr->na_aclerr = set_posix_acl(&init_user_ns,
+               attr->na_aclerr = set_posix_acl(&nop_mnt_idmap,
                                                dentry, ACL_TYPE_ACCESS,
                                                attr->na_pacl);
        if (IS_ENABLED(CONFIG_FS_POSIX_ACL) &&
            !attr->na_aclerr && attr->na_dpacl && S_ISDIR(inode->i_mode))
-               attr->na_aclerr = set_posix_acl(&init_user_ns,
+               attr->na_aclerr = set_posix_acl(&nop_mnt_idmap,
                                                dentry, ACL_TYPE_DEFAULT,
                                                attr->na_dpacl);
        inode_unlock(inode);
index 33299e4f931ed4d63f58bf018b0fe10b2ba8004c..181d5677ccd1f9826e3fd955f76f401ac52443ca 100644 (file)
@@ -707,7 +707,7 @@ int ntfs3_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
        setattr_copy(idmap, inode, attr);
 
        if (mode != inode->i_mode) {
-               err = ntfs_acl_chmod(mnt_idmap_owner(idmap), dentry);
+               err = ntfs_acl_chmod(idmap, dentry);
                if (err)
                        goto out;
 
index 41cd797b3c9605016f67669f758de9f7dc3b3110..9d45a259695c60d97ce7f2e9a255f5a24d06abdd 100644 (file)
@@ -859,7 +859,7 @@ unsigned long ntfs_names_hash(const u16 *name, size_t len, const u16 *upcase,
 /* globals from xattr.c */
 #ifdef CONFIG_NTFS3_FS_POSIX_ACL
 struct posix_acl *ntfs_get_acl(struct inode *inode, int type, bool rcu);
-int ntfs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                 struct posix_acl *acl, int type);
 int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *inode,
                  struct inode *dir);
@@ -868,7 +868,7 @@ int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *inode,
 #define ntfs_set_acl NULL
 #endif
 
-int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct dentry *dentry);
+int ntfs_acl_chmod(struct mnt_idmap *idmap, struct dentry *dentry);
 int ntfs_permission(struct user_namespace *mnt_userns, struct inode *inode,
                    int mask);
 ssize_t ntfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
index 616df209feea7d3963a05bff722ac0b3d63b9364..370effca6b2c1aa12816046612e300b7b7785a31 100644 (file)
@@ -652,9 +652,11 @@ out:
 /*
  * ntfs_set_acl - inode_operations::set_acl
  */
-int ntfs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                 struct posix_acl *acl, int type)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
+
        return ntfs_set_acl_ex(mnt_userns, d_inode(dentry), acl, type, false);
 }
 
@@ -697,7 +699,7 @@ int ntfs_init_acl(struct user_namespace *mnt_userns, struct inode *inode,
 /*
  * ntfs_acl_chmod - Helper for ntfs3_setattr().
  */
-int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct dentry *dentry)
+int ntfs_acl_chmod(struct mnt_idmap *idmap, struct dentry *dentry)
 {
        struct inode *inode = d_inode(dentry);
        struct super_block *sb = inode->i_sb;
@@ -708,7 +710,7 @@ int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct dentry *dentry)
        if (S_ISLNK(inode->i_mode))
                return -EOPNOTSUPP;
 
-       return posix_acl_chmod(mnt_userns, dentry, inode->i_mode);
+       return posix_acl_chmod(idmap, dentry, inode->i_mode);
 }
 
 /*
index 9f19cf9a5a9fc01337b57131a7a0659539f5d2e6..9809756a0d5135b2e3b99c09120353c6bef1769e 100644 (file)
@@ -260,7 +260,7 @@ static int ocfs2_set_acl(handle_t *handle,
        return ret;
 }
 
-int ocfs2_iop_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int ocfs2_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                      struct posix_acl *acl, int type)
 {
        struct buffer_head *bh = NULL;
index a897c4e41b269fc26c64c80ee5bb62dc8658e77c..667c6f03fa606f32b4e65ffeebe28868ce7e58c8 100644 (file)
@@ -17,7 +17,7 @@ struct ocfs2_acl_entry {
 };
 
 struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type, bool rcu);
-int ocfs2_iop_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int ocfs2_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                      struct posix_acl *acl, int type);
 extern int ocfs2_acl_chmod(struct inode *, struct buffer_head *);
 extern int ocfs2_init_acl(handle_t *, struct inode *, struct inode *,
index c5da2091cefb8bb9b586b85501bb1b3e0b54c85d..6a81336142c0279307ab126015376651606ea194 100644 (file)
@@ -118,7 +118,7 @@ out:
        return error;
 }
 
-int orangefs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int orangefs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                     struct posix_acl *acl, int type)
 {
        int error;
index 71cc7f11c7a086a021c69bc272a8610161e308e7..1e41eeee18e10855ff595e58a785a1ebdac60d33 100644 (file)
@@ -839,7 +839,7 @@ int __orangefs_setattr_mode(struct dentry *dentry, struct iattr *iattr)
        ret = __orangefs_setattr(inode, iattr);
        /* change mode on a file that has ACLs */
        if (!ret && (iattr->ia_valid & ATTR_MODE))
-               ret = posix_acl_chmod(&init_user_ns, dentry, inode->i_mode);
+               ret = posix_acl_chmod(&nop_mnt_idmap, dentry, inode->i_mode);
        return ret;
 }
 
index 064a52980283063fcee8bc7a4efef0e310273c12..f1ac4bd03c8dae056132b72bf631095d64bce660 100644 (file)
@@ -106,7 +106,7 @@ enum orangefs_vfs_op_states {
 extern const struct xattr_handler *orangefs_xattr_handlers[];
 
 extern struct posix_acl *orangefs_get_acl(struct inode *inode, int type, bool rcu);
-extern int orangefs_set_acl(struct user_namespace *mnt_userns,
+extern int orangefs_set_acl(struct mnt_idmap *idmap,
                            struct dentry *dentry, struct posix_acl *acl,
                            int type);
 int __orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
index 3ea4fc54f46996756a39723e0d6336e6abd23164..f52d9304d7e42dbb7123448c67f67a8185f2219f 100644 (file)
@@ -653,7 +653,7 @@ out_drop_write:
        return err;
 }
 
-int ovl_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int ovl_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                struct posix_acl *acl, int type)
 {
        int err;
index 1e8b0be85e4b8450804ff5e3a0d053bbc03221df..0f2ac8402f10b3168f3754ad6c09d853d9f34638 100644 (file)
@@ -284,13 +284,13 @@ static inline int ovl_removexattr(struct ovl_fs *ofs, struct dentry *dentry,
 static inline int ovl_do_set_acl(struct ovl_fs *ofs, struct dentry *dentry,
                                 const char *acl_name, struct posix_acl *acl)
 {
-       return vfs_set_acl(ovl_upper_mnt_userns(ofs), dentry, acl_name, acl);
+       return vfs_set_acl(ovl_upper_mnt_idmap(ofs), dentry, acl_name, acl);
 }
 
 static inline int ovl_do_remove_acl(struct ovl_fs *ofs, struct dentry *dentry,
                                    const char *acl_name)
 {
-       return vfs_remove_acl(ovl_upper_mnt_userns(ofs), dentry, acl_name);
+       return vfs_remove_acl(ovl_upper_mnt_idmap(ofs), dentry, acl_name);
 }
 
 static inline int ovl_do_rename(struct ovl_fs *ofs, struct inode *olddir,
@@ -623,7 +623,7 @@ static inline struct posix_acl *ovl_get_acl(struct mnt_idmap *idmap,
 {
        return do_ovl_get_acl(idmap, d_inode(dentry), type, false, false);
 }
-int ovl_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int ovl_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                struct posix_acl *acl, int type);
 struct posix_acl *ovl_get_acl_path(const struct path *path,
                                   const char *acl_name, bool noperm);
index 17e141a94671f50327799415b66a3cce397de514..678b86ec2b4c54e7c1a65e7ac86de795f18b779e 100644 (file)
@@ -591,18 +591,18 @@ EXPORT_SYMBOL(__posix_acl_chmod);
 /**
  * posix_acl_chmod - chmod a posix acl
  *
- * @mnt_userns:        user namespace of the mount @inode was found from
+ * @idmap:     idmap of the mount @inode was found from
  * @dentry:    dentry to check permissions on
  * @mode:      the new mode of @inode
  *
- * If the dentry has been found through an idmapped mount the user namespace of
- * the vfsmount must be passed through @mnt_userns. This function will then
- * take care to map the inode according to @mnt_userns before checking
+ * If the dentry has been found through an idmapped mount the idmap of
+ * the vfsmount must be passed through @idmap. This function will then
+ * take care to map the inode according to @idmap before checking
  * permissions. On non-idmapped mounts or if permission checking is to be
- * performed on the raw inode simply passs init_user_ns.
+ * performed on the raw inode simply passs @nop_mnt_idmap.
  */
 int
- posix_acl_chmod(struct user_namespace *mnt_userns, struct dentry *dentry,
+ posix_acl_chmod(struct mnt_idmap *idmap, struct dentry *dentry,
                    umode_t mode)
 {
        struct inode *inode = d_inode(dentry);
@@ -624,7 +624,7 @@ int
        ret = __posix_acl_chmod(&acl, GFP_KERNEL, mode);
        if (ret)
                return ret;
-       ret = inode->i_op->set_acl(mnt_userns, dentry, acl, ACL_TYPE_ACCESS);
+       ret = inode->i_op->set_acl(idmap, dentry, acl, ACL_TYPE_ACCESS);
        posix_acl_release(acl);
        return ret;
 }
@@ -934,7 +934,7 @@ static ssize_t vfs_posix_acl_to_xattr(struct mnt_idmap *idmap,
 }
 
 int
-set_posix_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+set_posix_acl(struct mnt_idmap *idmap, struct dentry *dentry,
              int type, struct posix_acl *acl)
 {
        struct inode *inode = d_inode(dentry);
@@ -946,7 +946,7 @@ set_posix_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
 
        if (type == ACL_TYPE_DEFAULT && !S_ISDIR(inode->i_mode))
                return acl ? -EACCES : 0;
-       if (!inode_owner_or_capable(mnt_userns, inode))
+       if (!inode_owner_or_capable(mnt_idmap_owner(idmap), inode))
                return -EPERM;
 
        if (acl) {
@@ -954,7 +954,7 @@ set_posix_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
                if (ret)
                        return ret;
        }
-       return inode->i_op->set_acl(mnt_userns, dentry, acl, type);
+       return inode->i_op->set_acl(idmap, dentry, acl, type);
 }
 EXPORT_SYMBOL(set_posix_acl);
 
@@ -978,10 +978,11 @@ const struct xattr_handler posix_acl_default_xattr_handler = {
 };
 EXPORT_SYMBOL_GPL(posix_acl_default_xattr_handler);
 
-int simple_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int simple_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                   struct posix_acl *acl, int type)
 {
        int error;
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        struct inode *inode = d_inode(dentry);
 
        if (type == ACL_TYPE_ACCESS) {
@@ -1041,7 +1042,7 @@ static int vfs_set_acl_idmapped_mnt(struct user_namespace *mnt_userns,
 
 /**
  * vfs_set_acl - set posix acls
- * @mnt_userns: user namespace of the mount
+ * @idmap: idmap of the mount
  * @dentry: the dentry based on which to set the posix acls
  * @acl_name: the name of the posix acl
  * @kacl: the posix acls in the appropriate VFS format
@@ -1051,11 +1052,12 @@ static int vfs_set_acl_idmapped_mnt(struct user_namespace *mnt_userns,
  *
  * Return: On success 0, on error negative errno.
  */
-int vfs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int vfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                const char *acl_name, struct posix_acl *kacl)
 {
        int acl_type;
        int error;
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        struct inode *inode = d_inode(dentry);
        struct inode *delegated_inode = NULL;
 
@@ -1096,7 +1098,7 @@ retry_deleg:
                goto out_inode_unlock;
 
        if (inode->i_opflags & IOP_XATTR)
-               error = set_posix_acl(mnt_userns, dentry, acl_type, kacl);
+               error = set_posix_acl(idmap, dentry, acl_type, kacl);
        else if (unlikely(is_bad_inode(inode)))
                error = -EIO;
        else
@@ -1167,7 +1169,7 @@ EXPORT_SYMBOL_GPL(vfs_get_acl);
 
 /**
  * vfs_remove_acl - remove posix acls
- * @mnt_userns: user namespace of the mount
+ * @idmap: idmap of the mount
  * @dentry: the dentry based on which to retrieve the posix acls
  * @acl_name: the name of the posix acl
  *
@@ -1175,11 +1177,12 @@ EXPORT_SYMBOL_GPL(vfs_get_acl);
  *
  * Return: On success 0, on error negative errno.
  */
-int vfs_remove_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int vfs_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                   const char *acl_name)
 {
        int acl_type;
        int error;
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        struct inode *inode = d_inode(dentry);
        struct inode *delegated_inode = NULL;
 
@@ -1207,7 +1210,7 @@ retry_deleg:
                goto out_inode_unlock;
 
        if (inode->i_opflags & IOP_XATTR)
-               error = set_posix_acl(mnt_userns, dentry, acl_type, NULL);
+               error = set_posix_acl(idmap, dentry, acl_type, NULL);
        else if (unlikely(is_bad_inode(inode)))
                error = -EIO;
        else
@@ -1246,7 +1249,7 @@ int do_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                        return PTR_ERR(acl);
        }
 
-       error = vfs_set_acl(mnt_idmap_owner(idmap), dentry, acl_name, acl);
+       error = vfs_set_acl(idmap, dentry, acl_name, acl);
        posix_acl_release(acl);
        return error;
 }
index 29c503a06db47139f78c3da5e4b6a5bb5166dc66..2571b1a8be84e32e6fb081263e951436e10633ee 100644 (file)
@@ -49,7 +49,7 @@ static inline int reiserfs_acl_count(size_t size)
 
 #ifdef CONFIG_REISERFS_FS_POSIX_ACL
 struct posix_acl *reiserfs_get_acl(struct inode *inode, int type, bool rcu);
-int reiserfs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int reiserfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                     struct posix_acl *acl, int type);
 int reiserfs_acl_chmod(struct dentry *dentry);
 int reiserfs_inherit_default_acl(struct reiserfs_transaction_handle *th,
index 93fe414fed18657173a8d52c75b5e36b846065ea..186aeba6823c53b84ea06d088c2eb66d1ad0c82a 100644 (file)
@@ -18,7 +18,7 @@ static int __reiserfs_set_acl(struct reiserfs_transaction_handle *th,
 
 
 int
-reiserfs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+reiserfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                 struct posix_acl *acl, int type)
 {
        int error, error2;
@@ -407,5 +407,5 @@ int reiserfs_acl_chmod(struct dentry *dentry)
            !reiserfs_posixacl(inode->i_sb))
                return 0;
 
-       return posix_acl_chmod(&init_user_ns, dentry, inode->i_mode);
+       return posix_acl_chmod(&nop_mnt_idmap, dentry, inode->i_mode);
 }
index adab9a70b53688659889842938059313e6983814..e69a2935ef586cacf4a176e4311cfe44af19d79e 100644 (file)
@@ -892,7 +892,7 @@ removexattr(struct mnt_idmap *idmap, struct dentry *d,
                return error;
 
        if (is_posix_acl_xattr(kname))
-               return vfs_remove_acl(mnt_idmap_owner(idmap), d, kname);
+               return vfs_remove_acl(idmap, d, kname);
 
        return vfs_removexattr(mnt_idmap_owner(idmap), d, kname);
 }
index a05f44eb81782c6154ffabd0ec9b6272070bb1fe..a2d2c117a07675ce827978787c3ff21ed3fafe73 100644 (file)
@@ -242,9 +242,10 @@ xfs_acl_set_mode(
 }
 
 int
-xfs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+xfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
            struct posix_acl *acl, int type)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        umode_t mode;
        bool set_mode = false;
        int error = 0;
index dcd176149c7a7df3b607afcae293bb799ab4ca40..bf7f960997d36a774ae26f382a4c0fdeb09f449b 100644 (file)
@@ -11,7 +11,7 @@ struct posix_acl;
 
 #ifdef CONFIG_XFS_POSIX_ACL
 extern struct posix_acl *xfs_get_acl(struct inode *inode, int type, bool rcu);
-extern int xfs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+extern int xfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                       struct posix_acl *acl, int type);
 extern int __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
 void xfs_forget_acl(struct inode *inode, const char *name);
index 43e746167d616a3b2cb1258f994bca036988bc95..1323ac546e5ffc0e8ba0f571fcd7e5a50506e794 100644 (file)
@@ -764,7 +764,7 @@ xfs_setattr_nonsize(
         *           Posix ACL code seems to care about this issue either.
         */
        if (mask & ATTR_MODE) {
-               error = posix_acl_chmod(mnt_userns, dentry, inode->i_mode);
+               error = posix_acl_chmod(idmap, dentry, inode->i_mode);
                if (error)
                        return error;
        }
index 31a714377ba2bdbdd3214572e141274969a6836d..85d8e4bc779879997a3fefc97b30a59c25d271a6 100644 (file)
@@ -2166,7 +2166,7 @@ struct inode_operations {
                        struct file *, umode_t);
        struct posix_acl *(*get_acl)(struct mnt_idmap *, struct dentry *,
                                     int);
-       int (*set_acl)(struct user_namespace *, struct dentry *,
+       int (*set_acl)(struct mnt_idmap *, struct dentry *,
                       struct posix_acl *, int);
        int (*fileattr_set)(struct user_namespace *mnt_userns,
                            struct dentry *dentry, struct fileattr *fa);
index 042ef62f92760f55a74cdd2d7af1305dcf3d55e6..0282758ba400b5b48c2361c61ab72e737a26d482 100644 (file)
@@ -69,20 +69,20 @@ extern int __posix_acl_create(struct posix_acl **, gfp_t, umode_t *);
 extern int __posix_acl_chmod(struct posix_acl **, gfp_t, umode_t);
 
 extern struct posix_acl *get_posix_acl(struct inode *, int);
-int set_posix_acl(struct user_namespace *, struct dentry *, int,
+int set_posix_acl(struct mnt_idmap *, struct dentry *, int,
                  struct posix_acl *);
 
 struct posix_acl *get_cached_acl_rcu(struct inode *inode, int type);
 struct posix_acl *posix_acl_clone(const struct posix_acl *acl, gfp_t flags);
 
 #ifdef CONFIG_FS_POSIX_ACL
-int posix_acl_chmod(struct user_namespace *, struct dentry *, umode_t);
+int posix_acl_chmod(struct mnt_idmap *, struct dentry *, umode_t);
 extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **,
                struct posix_acl **);
 int posix_acl_update_mode(struct user_namespace *, struct inode *, umode_t *,
                          struct posix_acl **);
 
-int simple_set_acl(struct user_namespace *, struct dentry *,
+int simple_set_acl(struct mnt_idmap *, struct dentry *,
                   struct posix_acl *, int);
 extern int simple_acl_create(struct inode *, struct inode *);
 
@@ -100,14 +100,14 @@ static inline void cache_no_acl(struct inode *inode)
        inode->i_default_acl = NULL;
 }
 
-int vfs_set_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int vfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                const char *acl_name, struct posix_acl *kacl);
 struct posix_acl *vfs_get_acl(struct mnt_idmap *idmap,
                              struct dentry *dentry, const char *acl_name);
-int vfs_remove_acl(struct user_namespace *mnt_userns, struct dentry *dentry,
+int vfs_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
                   const char *acl_name);
 #else
-static inline int posix_acl_chmod(struct user_namespace *mnt_userns,
+static inline int posix_acl_chmod(struct mnt_idmap *idmap,
                                  struct dentry *dentry, umode_t mode)
 {
        return 0;
@@ -134,7 +134,7 @@ static inline void forget_all_cached_acls(struct inode *inode)
 {
 }
 
-static inline int vfs_set_acl(struct user_namespace *mnt_userns,
+static inline int vfs_set_acl(struct mnt_idmap *idmap,
                              struct dentry *dentry, const char *name,
                              struct posix_acl *acl)
 {
@@ -148,7 +148,7 @@ static inline struct posix_acl *vfs_get_acl(struct mnt_idmap *idmap,
        return ERR_PTR(-EOPNOTSUPP);
 }
 
-static inline int vfs_remove_acl(struct user_namespace *mnt_userns,
+static inline int vfs_remove_acl(struct mnt_idmap *idmap,
                                 struct dentry *dentry, const char *acl_name)
 {
        return -EOPNOTSUPP;
index ab289abe58270235bd145563ffe1d741172f5411..ad768241147c54aa49cab25697c132331365fbe4 100644 (file)
@@ -1131,7 +1131,7 @@ static int shmem_setattr(struct mnt_idmap *idmap,
 
        setattr_copy(&nop_mnt_idmap, inode, attr);
        if (attr->ia_valid & ATTR_MODE)
-               error = posix_acl_chmod(&init_user_ns, dentry, inode->i_mode);
+               error = posix_acl_chmod(&nop_mnt_idmap, dentry, inode->i_mode);
        if (!error && update_ctime) {
                inode->i_ctime = current_time(inode);
                if (update_mtime)