Unverified Commit 5ebb29be authored by Christian Brauner's avatar Christian Brauner Committed by Christian Brauner (Microsoft)
Browse files

fs: port ->mknod() to pass mnt_idmap



Convert to struct mnt_idmap.

Last cycle we merged the necessary infrastructure in
256c8aed ("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: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
parent c54bd91e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -63,7 +63,7 @@ prototypes::
	int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *);
	int (*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
	int (*rmdir) (struct inode *,struct dentry *);
	int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t);
	int (*mknod) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
	int (*rename) (struct inode *, struct dentry *,
			struct inode *, struct dentry *, unsigned int);
	int (*readlink) (struct dentry *, char __user *,int);
+1 −1
Original line number Diff line number Diff line
@@ -428,7 +428,7 @@ As of kernel 2.6.22, the following members are defined:
		int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *);
		int (*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
		int (*rmdir) (struct inode *,struct dentry *);
		int (*mknod) (struct user_namespace *, struct inode *,struct dentry *,umode_t,dev_t);
		int (*mknod) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
		int (*rename) (struct user_namespace *, struct inode *, struct dentry *,
			       struct inode *, struct dentry *, unsigned int);
		int (*readlink) (struct dentry *, char __user *,int);
+2 −2
Original line number Diff line number Diff line
@@ -1356,7 +1356,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,

/**
 * v9fs_vfs_mknod - create a special file
 * @mnt_userns: The user namespace of the mount
 * @idmap: idmap of the mount
 * @dir: inode destination for new link
 * @dentry: dentry for file
 * @mode: mode for creation
@@ -1365,7 +1365,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
 */

static int
v9fs_vfs_mknod(struct user_namespace *mnt_userns, struct inode *dir,
v9fs_vfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
	       struct dentry *dentry, umode_t mode, dev_t rdev)
{
	struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
+4 −5
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@
#include "acl.h"

static int
v9fs_vfs_mknod_dotl(struct user_namespace *mnt_userns, struct inode *dir,
v9fs_vfs_mknod_dotl(struct mnt_idmap *idmap, struct inode *dir,
		    struct dentry *dentry, umode_t omode, dev_t rdev);

/**
@@ -222,8 +222,7 @@ static int
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);
	return v9fs_vfs_mknod_dotl(idmap, dir, dentry, omode, 0);
}

static int
@@ -818,7 +817,7 @@ v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,

/**
 * v9fs_vfs_mknod_dotl - create a special file
 * @mnt_userns: The user namespace of the mount
 * @idmap: The idmap of the mount
 * @dir: inode destination for new link
 * @dentry: dentry for file
 * @omode: mode for creation
@@ -826,7 +825,7 @@ v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,
 *
 */
static int
v9fs_vfs_mknod_dotl(struct user_namespace *mnt_userns, struct inode *dir,
v9fs_vfs_mknod_dotl(struct mnt_idmap *idmap, struct inode *dir,
		    struct dentry *dentry, umode_t omode, dev_t rdev)
{
	int err;
+1 −1
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ static int bad_inode_rmdir (struct inode *dir, struct dentry *dentry)
	return -EIO;
}

static int bad_inode_mknod(struct user_namespace *mnt_userns, struct inode *dir,
static int bad_inode_mknod(struct mnt_idmap *idmap, struct inode *dir,
			   struct dentry *dentry, umode_t mode, dev_t rdev)
{
	return -EIO;
Loading