summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorChristian Brauner <brauner@kernel.org>2023-01-13 12:49:18 +0100
committerChristian Brauner (Microsoft) <brauner@kernel.org>2023-01-19 09:24:27 +0100
commit011e2b717b1b921d3706a9d48ff83a025563e826 (patch)
tree110d1a5d8e54ff5f5e2f3a9176fbe598594c9ee4 /fs
parente18275ae55e07a2937e48134589c2f4c1d99a369 (diff)
fs: port ->tmpfile() to pass mnt_idmap
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/bad_inode.c2
-rw-r--r--fs/btrfs/inode.c3
-rw-r--r--fs/ext2/namei.c2
-rw-r--r--fs/ext4/namei.c3
-rw-r--r--fs/f2fs/namei.c3
-rw-r--r--fs/fuse/dir.c2
-rw-r--r--fs/hugetlbfs/inode.c2
-rw-r--r--fs/minix/namei.c2
-rw-r--r--fs/namei.c2
-rw-r--r--fs/ramfs/inode.c2
-rw-r--r--fs/ubifs/dir.c2
-rw-r--r--fs/udf/namei.c2
-rw-r--r--fs/xfs/xfs_iops.c4
13 files changed, 18 insertions, 13 deletions
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 1e24ce889a15..4bdf40b187ff 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -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)
{
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index dbb6790d0268..c10157a5a6f8 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -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;
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 8b5dfa46bcc8..81808e3d11c1 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -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);
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index feb58508978e..74a2c3eae066 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2863,9 +2863,10 @@ retry:
return err;
}
-static int ext4_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
+static int ext4_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
+ struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
handle_t *handle;
struct inode *inode;
int err, retries = 0;
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index a87b9fcaf923..938032cbc1a8 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -911,9 +911,10 @@ out:
return err;
}
-static int f2fs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
+static int f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
+ struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
int err;
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index c95d610fa63f..ca07660a76a8 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -802,7 +802,7 @@ static int fuse_create(struct mnt_idmap *idmap, struct inode *dir,
return fuse_mknod(&nop_mnt_idmap, dir, entry, mode, 0);
}
-static int fuse_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
+static int fuse_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
struct fuse_conn *fc = get_fuse_conn(dir);
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index b37e29dc125d..e1acab15e70d 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -1050,7 +1050,7 @@ static int hugetlbfs_create(struct mnt_idmap *idmap,
return hugetlbfs_mknod(&nop_mnt_idmap, dir, dentry, mode | S_IFREG, 0);
}
-static int hugetlbfs_tmpfile(struct user_namespace *mnt_userns,
+static int hugetlbfs_tmpfile(struct mnt_idmap *idmap,
struct inode *dir, struct file *file,
umode_t mode)
{
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index aa308b12f40d..39ebe10d6a8b 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -52,7 +52,7 @@ static int minix_mknod(struct mnt_idmap *idmap, struct inode *dir,
return error;
}
-static int minix_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
+static int minix_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
int error;
diff --git a/fs/namei.c b/fs/namei.c
index 3be66e8b418f..34f020ae67ae 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3613,7 +3613,7 @@ static int vfs_tmpfile(struct mnt_idmap *idmap,
file->f_path.mnt = parentpath->mnt;
file->f_path.dentry = child;
mode = vfs_prepare_mode(mnt_userns, dir, mode, mode, mode);
- error = dir->i_op->tmpfile(mnt_userns, dir, file, mode);
+ error = dir->i_op->tmpfile(idmap, dir, file, mode);
dput(child);
if (error)
return error;
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 2ca68aa81895..ba14f18bd1e5 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -145,7 +145,7 @@ static int ramfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
return error;
}
-static int ramfs_tmpfile(struct user_namespace *mnt_userns,
+static int ramfs_tmpfile(struct mnt_idmap *idmap,
struct inode *dir, struct file *file, umode_t mode)
{
struct inode *inode;
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index e11a2d76fb0e..832e6adf9a92 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -426,7 +426,7 @@ static void unlock_2_inodes(struct inode *inode1, struct inode *inode2)
mutex_unlock(&ubifs_inode(inode1)->ui_mutex);
}
-static int ubifs_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
+static int ubifs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
struct dentry *dentry = file->f_path.dentry;
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index c93b10513bab..bdba2206a678 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -625,7 +625,7 @@ static int udf_create(struct mnt_idmap *idmap, struct inode *dir,
return udf_add_nondir(dentry, inode);
}
-static int udf_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,
+static int udf_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
struct inode *inode = udf_new_inode(dir, mode);
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index fd0c62e0ddd2..43e746167d61 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1098,11 +1098,13 @@ xfs_vn_fiemap(
STATIC int
xfs_vn_tmpfile(
- struct user_namespace *mnt_userns,
+ struct mnt_idmap *idmap,
struct inode *dir,
struct file *file,
umode_t mode)
{
+ struct user_namespace *mnt_userns = mnt_idmap_owner(idmap);
+
int err = xfs_generic_create(mnt_userns, dir, file->f_path.dentry, mode, 0, file);
return finish_open_simple(file, err);