summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/inode.c
diff options
context:
space:
mode:
authorChristian Brauner <christian.brauner@ubuntu.com>2021-07-27 12:48:52 +0200
committerDavid Sterba <dsterba@suse.com>2021-08-23 13:19:14 +0200
commit4d4340c912ccc351da5578f73c68f1109dcc8e2d (patch)
tree420c14a486646beff24cd18f199a7ae3eae0ad93 /fs/btrfs/inode.c
parent5474bf400f16bd1f930627ea65b698bca09dcfc6 (diff)
downloadlinux-4d4340c912ccc351da5578f73c68f1109dcc8e2d.tar.bz2
btrfs: allow idmapped SNAP_CREATE/SUBVOL_CREATE ioctls
Creating subvolumes and snapshots is one of the core features of btrfs and is even available to unprivileged users. Make it possible to use subvolume and snapshot creation on idmapped mounts. This is a fairly straightforward operation since all the permission checking helpers are already capable of handling idmapped mounts. So we just need to pass down the mount's userns. Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r--fs/btrfs/inode.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 6ef2448a9937..2aa9646bce56 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9028,7 +9028,8 @@ out:
*/
int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
struct btrfs_root *new_root,
- struct btrfs_root *parent_root)
+ struct btrfs_root *parent_root,
+ struct user_namespace *mnt_userns)
{
struct inode *inode;
int err;
@@ -9039,7 +9040,7 @@ int btrfs_create_subvol_root(struct btrfs_trans_handle *trans,
if (err < 0)
return err;
- inode = btrfs_new_inode(trans, new_root, &init_user_ns, NULL, "..", 2,
+ inode = btrfs_new_inode(trans, new_root, mnt_userns, NULL, "..", 2,
ino, ino,
S_IFDIR | (~current_umask() & S_IRWXUGO),
&index);