Unverified Commit 011e2b71 authored by Christian Brauner's avatar Christian Brauner Committed by Christian Brauner (Microsoft)
Browse files

fs: port ->tmpfile() 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 e18275ae
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ prototypes::
	int (*atomic_open)(struct inode *, struct dentry *,
				struct file *, unsigned open_flag,
				umode_t create_mode);
	int (*tmpfile) (struct user_namespace *, struct inode *,
	int (*tmpfile) (struct mnt_idmap *, struct inode *,
			struct file *, umode_t);
	int (*fileattr_set)(struct user_namespace *mnt_userns,
			    struct dentry *dentry, struct fileattr *fa);
+1 −1
Original line number Diff line number Diff line
@@ -442,7 +442,7 @@ As of kernel 2.6.22, the following members are defined:
		void (*update_time)(struct inode *, struct timespec *, int);
		int (*atomic_open)(struct inode *, struct dentry *, struct file *,
				   unsigned open_flag, umode_t create_mode);
		int (*tmpfile) (struct user_namespace *, struct inode *, struct file *, umode_t);
		int (*tmpfile) (struct mnt_idmap *, struct inode *, struct file *, umode_t);
		struct posix_acl * (*get_acl)(struct user_namespace *, struct dentry *, int);
	        int (*set_acl)(struct user_namespace *, struct dentry *, struct posix_acl *, int);
		int (*fileattr_set)(struct user_namespace *mnt_userns,
+1 −1
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ static int bad_inode_atomic_open(struct inode *inode, struct dentry *dentry,
	return -EIO;
}

static int bad_inode_tmpfile(struct user_namespace *mnt_userns,
static int bad_inode_tmpfile(struct mnt_idmap *idmap,
			     struct inode *inode, struct file *file,
			     umode_t mode)
{
+2 −1
Original line number Diff line number Diff line
@@ -10095,9 +10095,10 @@ static int btrfs_permission(struct user_namespace *mnt_userns,
	return generic_permission(mnt_userns, inode, mask);
}

static int btrfs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
static int btrfs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
			 struct file *file, umode_t mode)
{
	struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
	struct btrfs_fs_info *fs_info = btrfs_sb(dir->i_sb);
	struct btrfs_trans_handle *trans;
	struct btrfs_root *root = BTRFS_I(dir)->root;
+1 −1
Original line number Diff line number Diff line
@@ -119,7 +119,7 @@ static int ext2_create (struct mnt_idmap * idmap,
	return ext2_add_nondir(dentry, inode);
}

static int ext2_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
static int ext2_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
			struct file *file, umode_t mode)
{
	struct inode *inode = ext2_new_inode(dir, mode, NULL);
Loading