fs: port ->create() to pass mnt_idmap
authorChristian Brauner <brauner@kernel.org>
Fri, 13 Jan 2023 11:49:13 +0000 (12:49 +0100)
committerChristian Brauner (Microsoft) <brauner@kernel.org>
Thu, 19 Jan 2023 08:24:25 +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>
54 files changed:
Documentation/filesystems/locking.rst
Documentation/filesystems/vfs.rst
fs/9p/vfs_inode.c
fs/9p/vfs_inode_dotl.c
fs/affs/affs.h
fs/affs/namei.c
fs/afs/dir.c
fs/bad_inode.c
fs/bfs/dir.c
fs/btrfs/inode.c
fs/ceph/dir.c
fs/cifs/cifsfs.h
fs/cifs/dir.c
fs/coda/dir.c
fs/ecryptfs/inode.c
fs/efivarfs/inode.c
fs/exfat/namei.c
fs/ext2/namei.c
fs/ext4/namei.c
fs/f2fs/namei.c
fs/fat/namei_msdos.c
fs/fat/namei_vfat.c
fs/fuse/dir.c
fs/gfs2/inode.c
fs/hfs/dir.c
fs/hfsplus/dir.c
fs/hostfs/hostfs_kern.c
fs/hpfs/namei.c
fs/hugetlbfs/inode.c
fs/jffs2/dir.c
fs/jfs/namei.c
fs/minix/namei.c
fs/namei.c
fs/nfs/dir.c
fs/nfs/internal.h
fs/nilfs2/namei.c
fs/ntfs3/namei.c
fs/ocfs2/dlmfs/dlmfs.c
fs/ocfs2/namei.c
fs/omfs/dir.c
fs/orangefs/namei.c
fs/overlayfs/dir.c
fs/ramfs/inode.c
fs/reiserfs/namei.c
fs/reiserfs/xattr.c
fs/sysv/namei.c
fs/ubifs/dir.c
fs/udf/namei.c
fs/ufs/namei.c
fs/vboxsf/dir.c
fs/xfs/xfs_iops.c
include/linux/fs.h
ipc/mqueue.c
mm/shmem.c

index 556a23af1edf69ed4a3b8c7056466303a58fb458..77830854ec677d1c4127ee65d32c97d9884ca810 100644 (file)
@@ -56,7 +56,7 @@ inode_operations
 
 prototypes::
 
-       int (*create) (struct inode *,struct dentry *,umode_t, bool);
+       int (*create) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t, bool);
        struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
        int (*link) (struct dentry *,struct inode *,struct dentry *);
        int (*unlink) (struct inode *,struct dentry *);
index 09184d98fc8cc73328aa0d352fa98119ac3b9850..6cf8d7d239b0b131983fe511934aae9598beecff 100644 (file)
@@ -421,7 +421,7 @@ As of kernel 2.6.22, the following members are defined:
 .. code-block:: c
 
        struct inode_operations {
-               int (*create) (struct user_namespace *, struct inode *,struct dentry *, umode_t, bool);
+               int (*create) (struct mnt_idmap *, struct inode *,struct dentry *, umode_t, bool);
                struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
                int (*link) (struct dentry *,struct inode *,struct dentry *);
                int (*unlink) (struct inode *,struct dentry *);
index ee47b2bb3712e3fbbe254c8df73b0f5d9c394ec6..693afb66c0c16def8272837d69541e836214af2b 100644 (file)
@@ -672,7 +672,7 @@ error:
 
 /**
  * v9fs_vfs_create - VFS hook to create a regular file
- * @mnt_userns: The user namespace of the mount
+ * @idmap: idmap of the mount
  * @dir: The parent directory
  * @dentry: The name of file to be created
  * @mode: The UNIX file mode to set
@@ -684,7 +684,7 @@ error:
  */
 
 static int
-v9fs_vfs_create(struct user_namespace *mnt_userns, struct inode *dir,
+v9fs_vfs_create(struct mnt_idmap *idmap, struct inode *dir,
                struct dentry *dentry, umode_t mode, bool excl)
 {
        struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
index 08ec5e7b628d978c0ad31ef81f076d4d0e3d165a..6f651d5757a5364b37c558585ddc58be9868876a 100644 (file)
@@ -211,7 +211,7 @@ int v9fs_open_to_dotl_flags(int flags)
 
 /**
  * v9fs_vfs_create_dotl - VFS hook to create files for 9P2000.L protocol.
- * @mnt_userns: The user namespace of the mount
+ * @idmap: The user namespace of the mount
  * @dir: directory inode that is being created
  * @dentry:  dentry that is being deleted
  * @omode: create permissions
@@ -219,9 +219,10 @@ int v9fs_open_to_dotl_flags(int flags)
  *
  */
 static int
-v9fs_vfs_create_dotl(struct user_namespace *mnt_userns, struct inode *dir,
+v9fs_vfs_create_dotl(struct mnt_idmap *idmap, struct inode *dir,
                     struct dentry *dentry, umode_t omode, bool excl)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        return v9fs_vfs_mknod_dotl(mnt_userns, dir, dentry, omode, 0);
 }
 
index 8c98e2644a5e7f6cd8348d704e7955d5936812e5..31a56a461c9f13ef967701e3ac3f719187c99ffa 100644 (file)
@@ -167,7 +167,7 @@ extern const struct export_operations affs_export_ops;
 extern int     affs_hash_name(struct super_block *sb, const u8 *name, unsigned int len);
 extern struct dentry *affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int);
 extern int     affs_unlink(struct inode *dir, struct dentry *dentry);
-extern int     affs_create(struct user_namespace *mnt_userns, struct inode *dir,
+extern int     affs_create(struct mnt_idmap *idmap, struct inode *dir,
                        struct dentry *dentry, umode_t mode, bool);
 extern int     affs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
                        struct dentry *dentry, umode_t mode);
index bcab18956b4f939f06fc474ea45eed4cc53b5dfa..661852c95c5a267ed794801fe8ce6c36f64b7bf8 100644 (file)
@@ -242,7 +242,7 @@ affs_unlink(struct inode *dir, struct dentry *dentry)
 }
 
 int
-affs_create(struct user_namespace *mnt_userns, struct inode *dir,
+affs_create(struct mnt_idmap *idmap, struct inode *dir,
            struct dentry *dentry, umode_t mode, bool excl)
 {
        struct super_block *sb = dir->i_sb;
index b7c1f8c84b38aa038c636d2916bf1c8ee8f8a572..a70495fd08866d73e4624fee37b9bd0751598e7f 100644 (file)
@@ -28,7 +28,7 @@ static bool afs_lookup_one_filldir(struct dir_context *ctx, const char *name, in
                                  loff_t fpos, u64 ino, unsigned dtype);
 static bool afs_lookup_filldir(struct dir_context *ctx, const char *name, int nlen,
                              loff_t fpos, u64 ino, unsigned dtype);
-static int afs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int afs_create(struct mnt_idmap *idmap, struct inode *dir,
                      struct dentry *dentry, umode_t mode, bool excl);
 static int afs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
                     struct dentry *dentry, umode_t mode);
@@ -1630,7 +1630,7 @@ static const struct afs_operation_ops afs_create_operation = {
 /*
  * create a regular file on an AFS filesystem
  */
-static int afs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int afs_create(struct mnt_idmap *idmap, struct inode *dir,
                      struct dentry *dentry, umode_t mode, bool excl)
 {
        struct afs_operation *op;
index 63006ca5b581839eb36077e05b537a6f1fcb88f5..8712fc1b3ff1019846c4d92d3ba1df0877300b1a 100644 (file)
@@ -27,7 +27,7 @@ static const struct file_operations bad_file_ops =
        .open           = bad_file_open,
 };
 
-static int bad_inode_create(struct user_namespace *mnt_userns,
+static int bad_inode_create(struct mnt_idmap *idmap,
                            struct inode *dir, struct dentry *dentry,
                            umode_t mode, bool excl)
 {
index 34d4f68f786b79571b88751b31e41b10b96c578a..f9d4ce5fff9faa156905dd85b1d0be76abfd1fad 100644 (file)
@@ -75,7 +75,7 @@ const struct file_operations bfs_dir_operations = {
        .llseek         = generic_file_llseek,
 };
 
-static int bfs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int bfs_create(struct mnt_idmap *idmap, struct inode *dir,
                      struct dentry *dentry, umode_t mode, bool excl)
 {
        int err;
index 8ba37e4c36fe4d753bb695f363eda037cbd10d26..3621e9a131d10108d8e501a4cde7c5d89b588274 100644 (file)
@@ -6739,9 +6739,10 @@ static int btrfs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
        return btrfs_create_common(dir, dentry, inode);
 }
 
-static int btrfs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int btrfs_create(struct mnt_idmap *idmap, struct inode *dir,
                        struct dentry *dentry, umode_t mode, bool excl)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        struct inode *inode;
 
        inode = new_inode(dir->i_sb);
index 6c7026cc8988ead1afbc4b73cebd1e64a417e382..cf4f70e558de17867895cac88b5f9deff215813a 100644 (file)
@@ -905,9 +905,10 @@ out:
        return err;
 }
 
-static int ceph_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int ceph_create(struct mnt_idmap *idmap, struct inode *dir,
                       struct dentry *dentry, umode_t mode, bool excl)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        return ceph_mknod(mnt_userns, dir, dentry, mode, 0);
 }
 
index 6c42137f9499252ec1b038dde7956c8b80eab344..0d4b3bfa1c3a62e29820587dcb79c07109cbe24d 100644 (file)
@@ -49,7 +49,7 @@ extern void cifs_sb_deactive(struct super_block *sb);
 /* Functions related to inodes */
 extern const struct inode_operations cifs_dir_inode_ops;
 extern struct inode *cifs_root_iget(struct super_block *);
-extern int cifs_create(struct user_namespace *, struct inode *,
+extern int cifs_create(struct mnt_idmap *, struct inode *,
                       struct dentry *, umode_t, bool excl);
 extern int cifs_atomic_open(struct inode *, struct dentry *,
                            struct file *, unsigned, umode_t);
index ad4208bf1e321127a6d7c300c3f5adcd16ea76ff..bc78af260fc91e5a64e24c39cd82b98f02fcca41 100644 (file)
@@ -529,7 +529,7 @@ out_free_xid:
        return rc;
 }
 
-int cifs_create(struct user_namespace *mnt_userns, struct inode *inode,
+int cifs_create(struct mnt_idmap *idmap, struct inode *inode,
                struct dentry *direntry, umode_t mode, bool excl)
 {
        int rc;
index 328d7a684b6347671157825c4118f3bb267a9b42..480bca167928f2fabb0d19d48938e38e98c987fb 100644 (file)
@@ -133,7 +133,7 @@ static inline void coda_dir_drop_nlink(struct inode *dir)
 }
 
 /* creation routines: create, mknod, mkdir, link, symlink */
-static int coda_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int coda_create(struct mnt_idmap *idmap, struct inode *dir,
                       struct dentry *de, umode_t mode, bool excl)
 {
        int error;
index 7854b71c769f357a041f2771f6190f455f5d076d..afc49ab46c5fb0097f690499294ac57ace1f61e3 100644 (file)
@@ -253,7 +253,7 @@ out:
  * Returns zero on success; non-zero on error condition
  */
 static int
-ecryptfs_create(struct user_namespace *mnt_userns,
+ecryptfs_create(struct mnt_idmap *idmap,
                struct inode *directory_inode, struct dentry *ecryptfs_dentry,
                umode_t mode, bool excl)
 {
index 617f3ad2485e8ce154883bbda8f66ba7413eec42..80369872815f66e7a03cb93c2bfbd19beebb9805 100644 (file)
@@ -70,7 +70,7 @@ bool efivarfs_valid_name(const char *str, int len)
        return uuid_is_valid(s);
 }
 
-static int efivarfs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int efivarfs_create(struct mnt_idmap *idmap, struct inode *dir,
                           struct dentry *dentry, umode_t mode, bool excl)
 {
        struct inode *inode = NULL;
index 5f995eba5dbbe78c007400e1d9ed6e2fb66bdf2a..f40cc11016adcd05c65d6c6f3ae8bd4880eea1e4 100644 (file)
@@ -551,7 +551,7 @@ out:
        return ret;
 }
 
-static int exfat_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int exfat_create(struct mnt_idmap *idmap, struct inode *dir,
                        struct dentry *dentry, umode_t mode, bool excl)
 {
        struct super_block *sb = dir->i_sb;
index c056957221a22563cd90f8c1e30dc8bec44d736f..1d4d807e09345cd6ea695d62ac9176bdaf3fc7a5 100644 (file)
@@ -99,7 +99,7 @@ struct dentry *ext2_get_parent(struct dentry *child)
  * If the create succeeds, we fill in the inode information
  * with d_instantiate(). 
  */
-static int ext2_create (struct user_namespace * mnt_userns,
+static int ext2_create (struct mnt_idmap * idmap,
                        struct inode * dir, struct dentry * dentry,
                        umode_t mode, bool excl)
 {
index dd28453d6ea3221038afd85cf8e8c566f4e93c8f..0bb43e4a28d57561f22ac2a5161dced40ae02bd3 100644 (file)
@@ -2792,9 +2792,10 @@ static int ext4_add_nondir(handle_t *handle,
  * If the create succeeds, we fill in the inode information
  * with d_instantiate().
  */
-static int ext4_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int ext4_create(struct mnt_idmap *idmap, struct inode *dir,
                       struct dentry *dentry, umode_t mode, bool excl)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        handle_t *handle;
        struct inode *inode;
        int err, credits, retries = 0;
index e634529ab6adf0ad60672aaa0a4959192384e417..aacf4e2764d2c40423255b1fbec80ee2224aaae9 100644 (file)
@@ -333,9 +333,10 @@ fail_drop:
        return ERR_PTR(err);
 }
 
-static int f2fs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int f2fs_create(struct mnt_idmap *idmap, struct inode *dir,
                       struct dentry *dentry, umode_t mode, bool excl)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
        struct inode *inode;
        nid_t ino = 0;
index efba301d68aec8c7bb2428e70ce767fbf83112c2..353ca26b3ea4ef31f007cca25905ae20013a99fb 100644 (file)
@@ -261,7 +261,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name,
 }
 
 /***** Create a file */
-static int msdos_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int msdos_create(struct mnt_idmap *idmap, struct inode *dir,
                        struct dentry *dentry, umode_t mode, bool excl)
 {
        struct super_block *sb = dir->i_sb;
index 21620054e1c44e61654d12f687c3789205fddfe2..de5ee606ae5fb6d204515bfe3069fe6231fface6 100644 (file)
@@ -756,7 +756,7 @@ error:
        return ERR_PTR(err);
 }
 
-static int vfat_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int vfat_create(struct mnt_idmap *idmap, struct inode *dir,
                       struct dentry *dentry, umode_t mode, bool excl)
 {
        struct super_block *sb = dir->i_sb;
index b1d89ba2d4c725b649d61b064a74f33ded18ede7..b748246862290527d9e7ab1467f7f22663ed405d 100644 (file)
@@ -796,7 +796,7 @@ static int fuse_mknod(struct user_namespace *mnt_userns, struct inode *dir,
        return create_new_entry(fm, &args, dir, entry, mode);
 }
 
-static int fuse_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int fuse_create(struct mnt_idmap *idmap, struct inode *dir,
                       struct dentry *entry, umode_t mode, bool excl)
 {
        return fuse_mknod(&init_user_ns, dir, entry, mode, 0);
index 30ec02ab1d0eca487a4c5f077d4f6e608421a80e..f58b13a2d8958f1512862d3d91984292baee7c70 100644 (file)
@@ -843,7 +843,7 @@ fail:
 
 /**
  * gfs2_create - Create a file
- * @mnt_userns: User namespace of the mount the inode was found from
+ * @idmap: idmap of the mount the inode was found from
  * @dir: The directory in which to create the file
  * @dentry: The dentry of the new file
  * @mode: The mode of the new file
@@ -852,7 +852,7 @@ fail:
  * Returns: errno
  */
 
-static int gfs2_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int gfs2_create(struct mnt_idmap *idmap, struct inode *dir,
                       struct dentry *dentry, umode_t mode, bool excl)
 {
        return gfs2_create_inode(dir, dentry, NULL, S_IFREG | mode, 0, NULL, 0, excl);
index 527f6e46cbe8128f1ea01b8ecd072c850bccf236..17fd7c3914b06a29ee6a2664312780355af60a7b 100644 (file)
@@ -189,7 +189,7 @@ static int hfs_dir_release(struct inode *inode, struct file *file)
  * a directory and return a corresponding inode, given the inode for
  * the directory and the name (and its length) of the new file.
  */
-static int hfs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int hfs_create(struct mnt_idmap *idmap, struct inode *dir,
                      struct dentry *dentry, umode_t mode, bool excl)
 {
        struct inode *inode;
index 84714bbccc1238a28a841faffe2ea53cd5930d4f..2ce051fb2d14cd1bf22f4ef2064ddb9ad67a9418 100644 (file)
@@ -517,7 +517,7 @@ out:
        return res;
 }
 
-static int hfsplus_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int hfsplus_create(struct mnt_idmap *idmap, struct inode *dir,
                          struct dentry *dentry, umode_t mode, bool excl)
 {
        return hfsplus_mknod(&init_user_ns, dir, dentry, mode, 0);
index f8742b7390b8ece3f10f46598c80a8892dcc00b8..d6174206a12320e544e93b8f488268ec9308fbe4 100644 (file)
@@ -559,7 +559,7 @@ static int read_name(struct inode *ino, char *name)
        return 0;
 }
 
-static int hostfs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int hostfs_create(struct mnt_idmap *idmap, struct inode *dir,
                         struct dentry *dentry, umode_t mode, bool excl)
 {
        struct inode *inode;
index 15fc63276caae17bbea509083dae6141cdae0755..f6cbd4a4b94dc216c1f08846c44883942492b8ed 100644 (file)
@@ -129,7 +129,7 @@ bail:
        return err;
 }
 
-static int hpfs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int hpfs_create(struct mnt_idmap *idmap, struct inode *dir,
                       struct dentry *dentry, umode_t mode, bool excl)
 {
        const unsigned char *name = dentry->d_name.name;
index b2f8884ed7415eee2f26bd8d9f5f47fd2cafdd5d..7ffcf4b18685b2dee838990b950ed1b5f96918d0 100644 (file)
@@ -1043,7 +1043,7 @@ static int hugetlbfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
        return retval;
 }
 
-static int hugetlbfs_create(struct user_namespace *mnt_userns,
+static int hugetlbfs_create(struct mnt_idmap *idmap,
                            struct inode *dir, struct dentry *dentry,
                            umode_t mode, bool excl)
 {
index f399b390b5f6067cb51897aafd1e932bdeacee17..7494563f04fa72f6e812fafe1d45e6d45147938b 100644 (file)
@@ -24,7 +24,7 @@
 
 static int jffs2_readdir (struct file *, struct dir_context *);
 
-static int jffs2_create (struct user_namespace *, struct inode *,
+static int jffs2_create (struct mnt_idmap *, struct inode *,
                         struct dentry *, umode_t, bool);
 static struct dentry *jffs2_lookup (struct inode *,struct dentry *,
                                    unsigned int);
@@ -160,7 +160,7 @@ static int jffs2_readdir(struct file *file, struct dir_context *ctx)
 /***********************************************************************/
 
 
-static int jffs2_create(struct user_namespace *mnt_userns, struct inode *dir_i,
+static int jffs2_create(struct mnt_idmap *idmap, struct inode *dir_i,
                        struct dentry *dentry, umode_t mode, bool excl)
 {
        struct jffs2_raw_inode *ri;
index a38d14eed047e8d5fd5ae2c6fd80e170d996eb47..9d06479e549e018120500886bde7dcf9a147a059 100644 (file)
@@ -59,7 +59,7 @@ static inline void free_ea_wmap(struct inode *inode)
  * RETURN:     Errors from subroutines
  *
  */
-static int jfs_create(struct user_namespace *mnt_userns, struct inode *dip,
+static int jfs_create(struct mnt_idmap *idmap, struct inode *dip,
                      struct dentry *dentry, umode_t mode, bool excl)
 {
        int rc = 0;
index 8afdc408ca4fd5f893959a007cebae6f443691cd..b8621cf9c933038af061b7c0cda41539c91f2831 100644 (file)
@@ -65,10 +65,10 @@ static int minix_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
        return finish_open_simple(file, error);
 }
 
-static int minix_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int minix_create(struct mnt_idmap *idmap, struct inode *dir,
                        struct dentry *dentry, umode_t mode, bool excl)
 {
-       return minix_mknod(mnt_userns, dir, dentry, mode, 0);
+       return minix_mknod(&init_user_ns, dir, dentry, mode, 0);
 }
 
 static int minix_symlink(struct user_namespace *mnt_userns, struct inode *dir,
index 3e727efed860ef76f554a064732657f612dffdce..f356719c24136a13e6c3b68c822ff7e1e8085ef1 100644 (file)
@@ -3115,7 +3115,7 @@ int vfs_create(struct mnt_idmap *idmap, struct inode *dir,
        error = security_inode_create(dir, dentry, mode);
        if (error)
                return error;
-       error = dir->i_op->create(mnt_userns, dir, dentry, mode, want_excl);
+       error = dir->i_op->create(idmap, dir, dentry, mode, want_excl);
        if (!error)
                fsnotify_create(dir, dentry);
        return error;
@@ -3322,6 +3322,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
                                  const struct open_flags *op,
                                  bool got_write)
 {
+       struct mnt_idmap *idmap;
        struct user_namespace *mnt_userns;
        struct dentry *dir = nd->path.dentry;
        struct inode *dir_inode = dir->d_inode;
@@ -3370,7 +3371,8 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
         */
        if (unlikely(!got_write))
                open_flag &= ~O_TRUNC;
-       mnt_userns = mnt_user_ns(nd->path.mnt);
+       idmap = mnt_idmap(nd->path.mnt);
+       mnt_userns = mnt_idmap_owner(idmap);
        if (open_flag & O_CREAT) {
                if (open_flag & O_EXCL)
                        open_flag &= ~O_TRUNC;
@@ -3413,7 +3415,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
                        goto out_dput;
                }
 
-               error = dir_inode->i_op->create(mnt_userns, dir_inode, dentry,
+               error = dir_inode->i_op->create(idmap, dir_inode, dentry,
                                                mode, open_flag & O_EXCL);
                if (error)
                        goto out_dput;
index ea1ceffa1d3aa78ee4ccaeb385df5d6c910c6921..a54337c181fee282729d725e0fcd41ba7f993d4f 100644 (file)
@@ -2296,7 +2296,7 @@ EXPORT_SYMBOL_GPL(nfs_instantiate);
  * that the operation succeeded on the server, but an error in the
  * reply path made it appear to have failed.
  */
-int nfs_create(struct user_namespace *mnt_userns, struct inode *dir,
+int nfs_create(struct mnt_idmap *idmap, struct inode *dir,
               struct dentry *dentry, umode_t mode, bool excl)
 {
        struct iattr attr;
index ae7d4a8c728c2fa78f04457cc19224bdbe60d619..988a1553286f33a5483d44191ae596b9aac82893 100644 (file)
@@ -384,7 +384,7 @@ extern unsigned long nfs_access_cache_scan(struct shrinker *shrink,
                                           struct shrink_control *sc);
 struct dentry *nfs_lookup(struct inode *, struct dentry *, unsigned int);
 void nfs_d_prune_case_insensitive_aliases(struct inode *inode);
-int nfs_create(struct user_namespace *, struct inode *, struct dentry *,
+int nfs_create(struct mnt_idmap *, struct inode *, struct dentry *,
               umode_t, bool);
 int nfs_mkdir(struct user_namespace *, struct inode *, struct dentry *,
              umode_t);
index 23899e0ae850916b7f01b32d2fdcf5311d999f89..4be5d9d340032ab97366ba41a1136e70a9eae269 100644 (file)
@@ -72,7 +72,7 @@ nilfs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
  * If the create succeeds, we fill in the inode information
  * with d_instantiate().
  */
-static int nilfs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int nilfs_create(struct mnt_idmap *idmap, struct inode *dir,
                        struct dentry *dentry, umode_t mode, bool excl)
 {
        struct inode *inode;
index c8db35e2ae17255265cd3cd60122ffb85d6e06af..8e46372a7ab71a2fd9fe28cd8db755de8f0513ac 100644 (file)
@@ -94,9 +94,10 @@ static struct dentry *ntfs_lookup(struct inode *dir, struct dentry *dentry,
 /*
  * ntfs_create - inode_operations::create
  */
-static int ntfs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int ntfs_create(struct mnt_idmap *idmap, struct inode *dir,
                       struct dentry *dentry, umode_t mode, bool excl)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        struct inode *inode;
 
        inode = ntfs_create_inode(mnt_userns, dir, dentry, NULL, S_IFREG | mode,
index 2d907ac864097047ae6df5f04383a59bfa710e83..812ff62e65603c235d2080cedd29408346bc5e22 100644 (file)
@@ -451,7 +451,7 @@ bail:
        return status;
 }
 
-static int dlmfs_create(struct user_namespace *mnt_userns,
+static int dlmfs_create(struct mnt_idmap *idmap,
                        struct inode *dir,
                        struct dentry *dentry,
                        umode_t mode,
index a8fd51afb794b6e5d7ffcb9927e0ac4a82195a51..c931ddb41e94ac7322b1d0a7304708075693d6a8 100644 (file)
@@ -658,7 +658,7 @@ static int ocfs2_mkdir(struct user_namespace *mnt_userns,
        return ret;
 }
 
-static int ocfs2_create(struct user_namespace *mnt_userns,
+static int ocfs2_create(struct mnt_idmap *idmap,
                        struct inode *dir,
                        struct dentry *dentry,
                        umode_t mode,
index c219f91f44e90146bf5ca99f53d9778a3de867c5..28590755c1d35f1ed91e60ea8f127f45f57e5410 100644 (file)
@@ -285,7 +285,7 @@ static int omfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
        return omfs_add_node(dir, dentry, mode | S_IFDIR);
 }
 
-static int omfs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int omfs_create(struct mnt_idmap *idmap, struct inode *dir,
                       struct dentry *dentry, umode_t mode, bool excl)
 {
        return omfs_add_node(dir, dentry, mode | S_IFREG);
index 75c1a3dcf68ca2318e4d0a7245222b83b48ab8d9..a47e73f564e4ce904a884a1e6c5c24dc46f58259 100644 (file)
@@ -15,7 +15,7 @@
 /*
  * Get a newly allocated inode to go with a negative dentry.
  */
-static int orangefs_create(struct user_namespace *mnt_userns,
+static int orangefs_create(struct mnt_idmap *idmap,
                        struct inode *dir,
                        struct dentry *dentry,
                        umode_t mode,
index f61e37f4c8ff4cbaea30826c4aea8fa0891140a8..fc372658672219c0f0237f9e7840b196c68590cd 100644 (file)
@@ -655,7 +655,7 @@ out:
        return err;
 }
 
-static int ovl_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int ovl_create(struct mnt_idmap *idmap, struct inode *dir,
                      struct dentry *dentry, umode_t mode, bool excl)
 {
        return ovl_create_object(dentry, (mode & 07777) | S_IFREG, 0, NULL);
index b3257e852820031e4bc90da51aa2fa88260571c6..77fd43f847abdcc3c5b1ff573a5a9442e230780e 100644 (file)
@@ -119,7 +119,7 @@ static int ramfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
        return retval;
 }
 
-static int ramfs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int ramfs_create(struct mnt_idmap *idmap, struct inode *dir,
                        struct dentry *dentry, umode_t mode, bool excl)
 {
        return ramfs_mknod(&init_user_ns, dir, dentry, mode | S_IFREG, 0);
index 0b8aa99749f150a0a2134b90b41c4bc4bd593254..c1b91a9656403812a2caa76df2ee03c47640f125 100644 (file)
@@ -620,7 +620,7 @@ static int new_inode_init(struct inode *inode, struct inode *dir, umode_t mode)
        return dquot_initialize(inode);
 }
 
-static int reiserfs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int reiserfs_create(struct mnt_idmap *idmap, struct inode *dir,
                           struct dentry *dentry, umode_t mode, bool excl)
 {
        int retval;
index af6137f53cf839269066a1e11f1325137ff145a1..7f5ca335b97b565d7872c2457bd72fbddcca1639 100644 (file)
@@ -66,7 +66,7 @@
 static int xattr_create(struct inode *dir, struct dentry *dentry, int mode)
 {
        BUG_ON(!inode_is_locked(dir));
-       return dir->i_op->create(&init_user_ns, dir, dentry, mode, true);
+       return dir->i_op->create(&nop_mnt_idmap, dir, dentry, mode, true);
 }
 #endif
 
index b2e6abc06a2d990dcd31f4547d53b9a53100436b..f862fb8584c0117046cb75b3d59a3412bbc51fcf 100644 (file)
@@ -61,7 +61,7 @@ static int sysv_mknod(struct user_namespace *mnt_userns, struct inode *dir,
        return err;
 }
 
-static int sysv_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int sysv_create(struct mnt_idmap *idmap, struct inode *dir,
                       struct dentry *dentry, umode_t mode, bool excl)
 {
        return sysv_mknod(&init_user_ns, dir, dentry, mode, 0);
index b034f66c6ea8a7bacfc4c6d0b30b8aef794cdc28..43a1d9c0e9e03b124d65b48200fd71eb0a803de7 100644 (file)
@@ -283,7 +283,7 @@ static int ubifs_prepare_create(struct inode *dir, struct dentry *dentry,
        return fscrypt_setup_filename(dir, &dentry->d_name, 0, nm);
 }
 
-static int ubifs_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int ubifs_create(struct mnt_idmap *idmap, struct inode *dir,
                        struct dentry *dentry, umode_t mode, bool excl)
 {
        struct inode *inode;
index 7c95c549dd64e255f922a62c57ac5ad35e9612c6..91921a3838fa51a449e6021b5ac58474c059e35a 100644 (file)
@@ -606,7 +606,7 @@ static int udf_add_nondir(struct dentry *dentry, struct inode *inode)
        return 0;
 }
 
-static int udf_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int udf_create(struct mnt_idmap *idmap, struct inode *dir,
                      struct dentry *dentry, umode_t mode, bool excl)
 {
        struct inode *inode = udf_new_inode(dir, mode);
index 29d5a0e0c8f0bfd9938804d77d915e879e296aa9..6904ce95a143374ceb2cae506dd36e6644504d0c 100644 (file)
@@ -69,7 +69,7 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, unsi
  * If the create succeeds, we fill in the inode information
  * with d_instantiate(). 
  */
-static int ufs_create (struct user_namespace * mnt_userns,
+static int ufs_create (struct mnt_idmap * idmap,
                struct inode * dir, struct dentry * dentry, umode_t mode,
                bool excl)
 {
index c4769a9396c50422377d7055ec9aa65cd973956a..0a9e76c87066e3585785d1c7975dd309816d6ff7 100644 (file)
@@ -294,7 +294,7 @@ out:
        return err;
 }
 
-static int vboxsf_dir_mkfile(struct user_namespace *mnt_userns,
+static int vboxsf_dir_mkfile(struct mnt_idmap *idmap,
                             struct inode *parent, struct dentry *dentry,
                             umode_t mode, bool excl)
 {
index 737211879a0927b92c808ae67a2a6ec42ed7e673..969074864328c3f76264cbde3ca03562f4b03b1a 100644 (file)
@@ -266,12 +266,13 @@ xfs_vn_mknod(
 
 STATIC int
 xfs_vn_create(
-       struct user_namespace   *mnt_userns,
+       struct mnt_idmap        *idmap,
        struct inode            *dir,
        struct dentry           *dentry,
        umode_t                 mode,
        bool                    flags)
 {
+       struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
        return xfs_generic_create(mnt_userns, dir, dentry, mode, 0, NULL);
 }
 
index 0214aee3324eaa166dc293d5df52b38b8291c62d..fddfacf2583ad4f4607b794ff5cd6998c8c7940c 100644 (file)
@@ -2139,7 +2139,7 @@ struct inode_operations {
 
        int (*readlink) (struct dentry *, char __user *,int);
 
-       int (*create) (struct user_namespace *, struct inode *,struct dentry *,
+       int (*create) (struct mnt_idmap *, struct inode *,struct dentry *,
                       umode_t, bool);
        int (*link) (struct dentry *,struct inode *,struct dentry *);
        int (*unlink) (struct inode *,struct dentry *);
index 4b78095fe77930bb9bd55c7a3265acc0029bf078..0031bd0337b2d5c4a66dd9e4dd82128102c5809b 100644 (file)
@@ -608,7 +608,7 @@ out_unlock:
        return error;
 }
 
-static int mqueue_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int mqueue_create(struct mnt_idmap *idmap, struct inode *dir,
                         struct dentry *dentry, umode_t mode, bool excl)
 {
        return mqueue_create_attr(dentry, mode, NULL);
index ae259636af7670185412b557f0f812c4a96e834e..8c2969494bc598e56024492bac17a19861ec2886 100644 (file)
@@ -2982,7 +2982,7 @@ static int shmem_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
        return 0;
 }
 
-static int shmem_create(struct user_namespace *mnt_userns, struct inode *dir,
+static int shmem_create(struct mnt_idmap *idmap, struct inode *dir,
                        struct dentry *dentry, umode_t mode, bool excl)
 {
        return shmem_mknod(&init_user_ns, dir, dentry, mode | S_IFREG, 0);