diff options
author | Sage Weil <sage@newdream.net> | 2010-10-29 15:46:43 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2010-10-29 21:42:10 -0400 |
commit | 4260f7c7516f4c209cf0ca34fda99cc9a0847772 (patch) | |
tree | 7feb5ab81d074b17a7c5b12bcc019c2e1bb010e2 /fs/btrfs/super.c | |
parent | 531cb13f1e417c060b54f979e1659ecd69bea650 (diff) |
Btrfs: allow subvol deletion by unprivileged user with -o user_subvol_rm_allowed
Add a mount option user_subvol_rm_allowed that allows users to delete a
(potentially non-empty!) subvol when they would otherwise we allowed to do
an rmdir(2). We duplicate the may_delete() checks from the core VFS code
to implement identical security checks (minus the directory size check).
We additionally require that the user has write+exec permission on the
subvol root inode.
Signed-off-by: Sage Weil <sage@newdream.net>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r-- | fs/btrfs/super.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 0002e6d1a16f..718b10de2049 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -71,6 +71,7 @@ enum { | |||
71 | Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, Opt_compress, | 71 | Opt_nossd, Opt_ssd_spread, Opt_thread_pool, Opt_noacl, Opt_compress, |
72 | Opt_compress_force, Opt_notreelog, Opt_ratio, Opt_flushoncommit, | 72 | Opt_compress_force, Opt_notreelog, Opt_ratio, Opt_flushoncommit, |
73 | Opt_discard, Opt_space_cache, Opt_clear_cache, Opt_err, | 73 | Opt_discard, Opt_space_cache, Opt_clear_cache, Opt_err, |
74 | Opt_user_subvol_rm_allowed, | ||
74 | }; | 75 | }; |
75 | 76 | ||
76 | static match_table_t tokens = { | 77 | static match_table_t tokens = { |
@@ -96,6 +97,7 @@ static match_table_t tokens = { | |||
96 | {Opt_discard, "discard"}, | 97 | {Opt_discard, "discard"}, |
97 | {Opt_space_cache, "space_cache"}, | 98 | {Opt_space_cache, "space_cache"}, |
98 | {Opt_clear_cache, "clear_cache"}, | 99 | {Opt_clear_cache, "clear_cache"}, |
100 | {Opt_user_subvol_rm_allowed, "user_subvol_rm_allowed"}, | ||
99 | {Opt_err, NULL}, | 101 | {Opt_err, NULL}, |
100 | }; | 102 | }; |
101 | 103 | ||
@@ -246,6 +248,9 @@ int btrfs_parse_options(struct btrfs_root *root, char *options) | |||
246 | printk(KERN_INFO "btrfs: force clearing of disk cache\n"); | 248 | printk(KERN_INFO "btrfs: force clearing of disk cache\n"); |
247 | btrfs_set_opt(info->mount_opt, CLEAR_CACHE); | 249 | btrfs_set_opt(info->mount_opt, CLEAR_CACHE); |
248 | break; | 250 | break; |
251 | case Opt_user_subvol_rm_allowed: | ||
252 | btrfs_set_opt(info->mount_opt, USER_SUBVOL_RM_ALLOWED); | ||
253 | break; | ||
249 | case Opt_err: | 254 | case Opt_err: |
250 | printk(KERN_INFO "btrfs: unrecognized mount option " | 255 | printk(KERN_INFO "btrfs: unrecognized mount option " |
251 | "'%s'\n", p); | 256 | "'%s'\n", p); |