fs: port ->create() to pass mnt_idmap

Convert to struct mnt_idmap.

Last cycle we merged the necessary infrastructure in
256c8aed2b ("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>
This commit is contained in:
Christian Brauner 2023-01-13 12:49:13 +01:00 committed by Christian Brauner (Microsoft)
parent b74d24f7a7
commit 6c960e68aa
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
54 changed files with 71 additions and 62 deletions

View File

@ -56,7 +56,7 @@ inode_operations
prototypes:: 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); struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
int (*link) (struct dentry *,struct inode *,struct dentry *); int (*link) (struct dentry *,struct inode *,struct dentry *);
int (*unlink) (struct inode *,struct dentry *); int (*unlink) (struct inode *,struct dentry *);

View File

@ -421,7 +421,7 @@ As of kernel 2.6.22, the following members are defined:
.. code-block:: c .. code-block:: c
struct inode_operations { 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); struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
int (*link) (struct dentry *,struct inode *,struct dentry *); int (*link) (struct dentry *,struct inode *,struct dentry *);
int (*unlink) (struct inode *,struct dentry *); int (*unlink) (struct inode *,struct dentry *);

View File

@ -672,7 +672,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
/** /**
* v9fs_vfs_create - VFS hook to create a regular file * 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 * @dir: The parent directory
* @dentry: The name of file to be created * @dentry: The name of file to be created
* @mode: The UNIX file mode to set * @mode: The UNIX file mode to set
@ -684,7 +684,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
*/ */
static int 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);

View 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. * 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 * @dir: directory inode that is being created
* @dentry: dentry that is being deleted * @dentry: dentry that is being deleted
* @omode: create permissions * @omode: create permissions
@ -219,9 +219,10 @@ int v9fs_open_to_dotl_flags(int flags)
* *
*/ */
static int 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 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); return v9fs_vfs_mknod_dotl(mnt_userns, dir, dentry, omode, 0);
} }

View 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 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 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_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); struct dentry *dentry, umode_t mode, bool);
extern int affs_mkdir(struct user_namespace *mnt_userns, struct inode *dir, extern int affs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
struct dentry *dentry, umode_t mode); struct dentry *dentry, umode_t mode);

View File

@ -242,7 +242,7 @@ affs_unlink(struct inode *dir, struct dentry *dentry)
} }
int 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct super_block *sb = dir->i_sb; struct super_block *sb = dir->i_sb;

View 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); loff_t fpos, u64 ino, unsigned dtype);
static bool afs_lookup_filldir(struct dir_context *ctx, const char *name, int nlen, static bool afs_lookup_filldir(struct dir_context *ctx, const char *name, int nlen,
loff_t fpos, u64 ino, unsigned dtype); 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); struct dentry *dentry, umode_t mode, bool excl);
static int afs_mkdir(struct user_namespace *mnt_userns, struct inode *dir, static int afs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
struct dentry *dentry, umode_t mode); 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 * 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct afs_operation *op; struct afs_operation *op;

View File

@ -27,7 +27,7 @@ static const struct file_operations bad_file_ops =
.open = bad_file_open, .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, struct inode *dir, struct dentry *dentry,
umode_t mode, bool excl) umode_t mode, bool excl)
{ {

View File

@ -75,7 +75,7 @@ const struct file_operations bfs_dir_operations = {
.llseek = generic_file_llseek, .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) struct dentry *dentry, umode_t mode, bool excl)
{ {
int err; int err;

View File

@ -6739,9 +6739,10 @@ static int btrfs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
return btrfs_create_common(dir, dentry, inode); 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
struct inode *inode; struct inode *inode;
inode = new_inode(dir->i_sb); inode = new_inode(dir->i_sb);

View File

@ -905,9 +905,10 @@ static int ceph_mknod(struct user_namespace *mnt_userns, struct inode *dir,
return err; 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 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); return ceph_mknod(mnt_userns, dir, dentry, mode, 0);
} }

View File

@ -49,7 +49,7 @@ extern void cifs_sb_deactive(struct super_block *sb);
/* Functions related to inodes */ /* Functions related to inodes */
extern const struct inode_operations cifs_dir_inode_ops; extern const struct inode_operations cifs_dir_inode_ops;
extern struct inode *cifs_root_iget(struct super_block *); 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); struct dentry *, umode_t, bool excl);
extern int cifs_atomic_open(struct inode *, struct dentry *, extern int cifs_atomic_open(struct inode *, struct dentry *,
struct file *, unsigned, umode_t); struct file *, unsigned, umode_t);

View File

@ -529,7 +529,7 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,
return rc; 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) struct dentry *direntry, umode_t mode, bool excl)
{ {
int rc; int rc;

View File

@ -133,7 +133,7 @@ static inline void coda_dir_drop_nlink(struct inode *dir)
} }
/* creation routines: create, mknod, mkdir, link, symlink */ /* 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) struct dentry *de, umode_t mode, bool excl)
{ {
int error; int error;

View File

@ -253,7 +253,7 @@ int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry,
* Returns zero on success; non-zero on error condition * Returns zero on success; non-zero on error condition
*/ */
static int static int
ecryptfs_create(struct user_namespace *mnt_userns, ecryptfs_create(struct mnt_idmap *idmap,
struct inode *directory_inode, struct dentry *ecryptfs_dentry, struct inode *directory_inode, struct dentry *ecryptfs_dentry,
umode_t mode, bool excl) umode_t mode, bool excl)
{ {

View File

@ -70,7 +70,7 @@ bool efivarfs_valid_name(const char *str, int len)
return uuid_is_valid(s); 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct inode *inode = NULL; struct inode *inode = NULL;

View File

@ -551,7 +551,7 @@ static int exfat_add_entry(struct inode *inode, const char *path,
return ret; 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct super_block *sb = dir->i_sb; struct super_block *sb = dir->i_sb;

View File

@ -99,7 +99,7 @@ struct dentry *ext2_get_parent(struct dentry *child)
* If the create succeeds, we fill in the inode information * If the create succeeds, we fill in the inode information
* with d_instantiate(). * 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, struct inode * dir, struct dentry * dentry,
umode_t mode, bool excl) umode_t mode, bool excl)
{ {

View File

@ -2792,9 +2792,10 @@ static int ext4_add_nondir(handle_t *handle,
* If the create succeeds, we fill in the inode information * If the create succeeds, we fill in the inode information
* with d_instantiate(). * 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
handle_t *handle; handle_t *handle;
struct inode *inode; struct inode *inode;
int err, credits, retries = 0; int err, credits, retries = 0;

View File

@ -333,9 +333,10 @@ static struct inode *f2fs_new_inode(struct user_namespace *mnt_userns,
return ERR_PTR(err); 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 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 f2fs_sb_info *sbi = F2FS_I_SB(dir);
struct inode *inode; struct inode *inode;
nid_t ino = 0; nid_t ino = 0;

View File

@ -261,7 +261,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name,
} }
/***** Create a file */ /***** 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct super_block *sb = dir->i_sb; struct super_block *sb = dir->i_sb;

View File

@ -756,7 +756,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
return ERR_PTR(err); 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct super_block *sb = dir->i_sb; struct super_block *sb = dir->i_sb;

View 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); 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) struct dentry *entry, umode_t mode, bool excl)
{ {
return fuse_mknod(&init_user_ns, dir, entry, mode, 0); return fuse_mknod(&init_user_ns, dir, entry, mode, 0);

View File

@ -843,7 +843,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
/** /**
* gfs2_create - Create a file * 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 * @dir: The directory in which to create the file
* @dentry: The dentry of the new file * @dentry: The dentry of the new file
* @mode: The mode of the new file * @mode: The mode of the new file
@ -852,7 +852,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
* Returns: errno * 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) struct dentry *dentry, umode_t mode, bool excl)
{ {
return gfs2_create_inode(dir, dentry, NULL, S_IFREG | mode, 0, NULL, 0, excl); return gfs2_create_inode(dir, dentry, NULL, S_IFREG | mode, 0, NULL, 0, excl);

View 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 * a directory and return a corresponding inode, given the inode for
* the directory and the name (and its length) of the new file. * 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct inode *inode; struct inode *inode;

View File

@ -517,7 +517,7 @@ static int hfsplus_mknod(struct user_namespace *mnt_userns, struct inode *dir,
return res; 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) struct dentry *dentry, umode_t mode, bool excl)
{ {
return hfsplus_mknod(&init_user_ns, dir, dentry, mode, 0); return hfsplus_mknod(&init_user_ns, dir, dentry, mode, 0);

View File

@ -559,7 +559,7 @@ static int read_name(struct inode *ino, char *name)
return 0; 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct inode *inode; struct inode *inode;

View File

@ -129,7 +129,7 @@ static int hpfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
return err; 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) struct dentry *dentry, umode_t mode, bool excl)
{ {
const unsigned char *name = dentry->d_name.name; const unsigned char *name = dentry->d_name.name;

View File

@ -1043,7 +1043,7 @@ static int hugetlbfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
return retval; 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, struct inode *dir, struct dentry *dentry,
umode_t mode, bool excl) umode_t mode, bool excl)
{ {

View File

@ -24,7 +24,7 @@
static int jffs2_readdir (struct file *, struct dir_context *); 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); struct dentry *, umode_t, bool);
static struct dentry *jffs2_lookup (struct inode *,struct dentry *, static struct dentry *jffs2_lookup (struct inode *,struct dentry *,
unsigned int); 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct jffs2_raw_inode *ri; struct jffs2_raw_inode *ri;

View File

@ -59,7 +59,7 @@ static inline void free_ea_wmap(struct inode *inode)
* RETURN: Errors from subroutines * 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) struct dentry *dentry, umode_t mode, bool excl)
{ {
int rc = 0; int rc = 0;

View File

@ -65,10 +65,10 @@ static int minix_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
return finish_open_simple(file, error); 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) 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, static int minix_symlink(struct user_namespace *mnt_userns, struct inode *dir,

View File

@ -3115,7 +3115,7 @@ int vfs_create(struct mnt_idmap *idmap, struct inode *dir,
error = security_inode_create(dir, dentry, mode); error = security_inode_create(dir, dentry, mode);
if (error) if (error)
return 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) if (!error)
fsnotify_create(dir, dentry); fsnotify_create(dir, dentry);
return error; return error;
@ -3322,6 +3322,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
const struct open_flags *op, const struct open_flags *op,
bool got_write) bool got_write)
{ {
struct mnt_idmap *idmap;
struct user_namespace *mnt_userns; struct user_namespace *mnt_userns;
struct dentry *dir = nd->path.dentry; struct dentry *dir = nd->path.dentry;
struct inode *dir_inode = dir->d_inode; 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)) if (unlikely(!got_write))
open_flag &= ~O_TRUNC; 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_CREAT) {
if (open_flag & O_EXCL) if (open_flag & O_EXCL)
open_flag &= ~O_TRUNC; open_flag &= ~O_TRUNC;
@ -3413,7 +3415,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
goto out_dput; 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); mode, open_flag & O_EXCL);
if (error) if (error)
goto out_dput; goto out_dput;

View File

@ -2296,7 +2296,7 @@ EXPORT_SYMBOL_GPL(nfs_instantiate);
* that the operation succeeded on the server, but an error in the * that the operation succeeded on the server, but an error in the
* reply path made it appear to have failed. * 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct iattr attr; struct iattr attr;

View File

@ -384,7 +384,7 @@ extern unsigned long nfs_access_cache_scan(struct shrinker *shrink,
struct shrink_control *sc); struct shrink_control *sc);
struct dentry *nfs_lookup(struct inode *, struct dentry *, unsigned int); struct dentry *nfs_lookup(struct inode *, struct dentry *, unsigned int);
void nfs_d_prune_case_insensitive_aliases(struct inode *inode); 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); umode_t, bool);
int nfs_mkdir(struct user_namespace *, struct inode *, struct dentry *, int nfs_mkdir(struct user_namespace *, struct inode *, struct dentry *,
umode_t); umode_t);

View 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 * If the create succeeds, we fill in the inode information
* with d_instantiate(). * 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct inode *inode; struct inode *inode;

View File

@ -94,9 +94,10 @@ static struct dentry *ntfs_lookup(struct inode *dir, struct dentry *dentry,
/* /*
* ntfs_create - inode_operations::create * 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
struct inode *inode; struct inode *inode;
inode = ntfs_create_inode(mnt_userns, dir, dentry, NULL, S_IFREG | mode, inode = ntfs_create_inode(mnt_userns, dir, dentry, NULL, S_IFREG | mode,

View File

@ -451,7 +451,7 @@ static int dlmfs_mkdir(struct user_namespace * mnt_userns,
return status; return status;
} }
static int dlmfs_create(struct user_namespace *mnt_userns, static int dlmfs_create(struct mnt_idmap *idmap,
struct inode *dir, struct inode *dir,
struct dentry *dentry, struct dentry *dentry,
umode_t mode, umode_t mode,

View File

@ -658,7 +658,7 @@ static int ocfs2_mkdir(struct user_namespace *mnt_userns,
return ret; return ret;
} }
static int ocfs2_create(struct user_namespace *mnt_userns, static int ocfs2_create(struct mnt_idmap *idmap,
struct inode *dir, struct inode *dir,
struct dentry *dentry, struct dentry *dentry,
umode_t mode, umode_t mode,

View 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); 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) struct dentry *dentry, umode_t mode, bool excl)
{ {
return omfs_add_node(dir, dentry, mode | S_IFREG); return omfs_add_node(dir, dentry, mode | S_IFREG);

View File

@ -15,7 +15,7 @@
/* /*
* Get a newly allocated inode to go with a negative dentry. * 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 inode *dir,
struct dentry *dentry, struct dentry *dentry,
umode_t mode, umode_t mode,

View File

@ -655,7 +655,7 @@ static int ovl_create_object(struct dentry *dentry, int mode, dev_t rdev,
return err; 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) struct dentry *dentry, umode_t mode, bool excl)
{ {
return ovl_create_object(dentry, (mode & 07777) | S_IFREG, 0, NULL); return ovl_create_object(dentry, (mode & 07777) | S_IFREG, 0, NULL);

View File

@ -119,7 +119,7 @@ static int ramfs_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
return retval; 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) struct dentry *dentry, umode_t mode, bool excl)
{ {
return ramfs_mknod(&init_user_ns, dir, dentry, mode | S_IFREG, 0); return ramfs_mknod(&init_user_ns, dir, dentry, mode | S_IFREG, 0);

View File

@ -620,7 +620,7 @@ static int new_inode_init(struct inode *inode, struct inode *dir, umode_t mode)
return dquot_initialize(inode); 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) struct dentry *dentry, umode_t mode, bool excl)
{ {
int retval; int retval;

View File

@ -66,7 +66,7 @@
static int xattr_create(struct inode *dir, struct dentry *dentry, int mode) static int xattr_create(struct inode *dir, struct dentry *dentry, int mode)
{ {
BUG_ON(!inode_is_locked(dir)); 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 #endif

View File

@ -61,7 +61,7 @@ static int sysv_mknod(struct user_namespace *mnt_userns, struct inode *dir,
return err; 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) struct dentry *dentry, umode_t mode, bool excl)
{ {
return sysv_mknod(&init_user_ns, dir, dentry, mode, 0); return sysv_mknod(&init_user_ns, dir, dentry, mode, 0);

View 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); 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct inode *inode; struct inode *inode;

View File

@ -606,7 +606,7 @@ static int udf_add_nondir(struct dentry *dentry, struct inode *inode)
return 0; 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 dentry *dentry, umode_t mode, bool excl)
{ {
struct inode *inode = udf_new_inode(dir, mode); struct inode *inode = udf_new_inode(dir, mode);

View 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 * If the create succeeds, we fill in the inode information
* with d_instantiate(). * 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, struct inode * dir, struct dentry * dentry, umode_t mode,
bool excl) bool excl)
{ {

View File

@ -294,7 +294,7 @@ static int vboxsf_dir_create(struct inode *parent, struct dentry *dentry,
return err; 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, struct inode *parent, struct dentry *dentry,
umode_t mode, bool excl) umode_t mode, bool excl)
{ {

View File

@ -266,12 +266,13 @@ xfs_vn_mknod(
STATIC int STATIC int
xfs_vn_create( xfs_vn_create(
struct user_namespace *mnt_userns, struct mnt_idmap *idmap,
struct inode *dir, struct inode *dir,
struct dentry *dentry, struct dentry *dentry,
umode_t mode, umode_t mode,
bool flags) bool flags)
{ {
struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
return xfs_generic_create(mnt_userns, dir, dentry, mode, 0, NULL); return xfs_generic_create(mnt_userns, dir, dentry, mode, 0, NULL);
} }

View File

@ -2139,7 +2139,7 @@ struct inode_operations {
int (*readlink) (struct dentry *, char __user *,int); 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); umode_t, bool);
int (*link) (struct dentry *,struct inode *,struct dentry *); int (*link) (struct dentry *,struct inode *,struct dentry *);
int (*unlink) (struct inode *,struct dentry *); int (*unlink) (struct inode *,struct dentry *);

View File

@ -608,7 +608,7 @@ static int mqueue_create_attr(struct dentry *dentry, umode_t mode, void *arg)
return error; 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) struct dentry *dentry, umode_t mode, bool excl)
{ {
return mqueue_create_attr(dentry, mode, NULL); return mqueue_create_attr(dentry, mode, NULL);

View File

@ -2982,7 +2982,7 @@ static int shmem_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
return 0; 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) struct dentry *dentry, umode_t mode, bool excl)
{ {
return shmem_mknod(&init_user_ns, dir, dentry, mode | S_IFREG, 0); return shmem_mknod(&init_user_ns, dir, dentry, mode | S_IFREG, 0);