diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2010-12-29 09:55:03 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-01-16 11:30:20 -0500 |
commit | 6f88a4403def422bd8e276ddf6863d6ac71435d2 (patch) | |
tree | 8fe01d61977e0113cc0a4fa77b7df7f8dfeecad9 /fs | |
parent | f690efb1aa2a961dd6655529c1797fcac60ad6d9 (diff) |
btrfs: Require CAP_SYS_ADMIN for filesystem rebalance
Filesystem rebalancing (BTRFS_IOC_BALANCE) affects the entire
filesystem and may run uninterruptibly for a long time. This does not
seem to be something that an unprivileged user should be able to do.
Reported-by: Aron Xu <happyaron.xu@gmail.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/volumes.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index e8be478178aa..f2d2f4ccc738 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/blkdev.h> | 22 | #include <linux/blkdev.h> |
23 | #include <linux/random.h> | 23 | #include <linux/random.h> |
24 | #include <linux/iocontext.h> | 24 | #include <linux/iocontext.h> |
25 | #include <linux/capability.h> | ||
25 | #include <asm/div64.h> | 26 | #include <asm/div64.h> |
26 | #include "compat.h" | 27 | #include "compat.h" |
27 | #include "ctree.h" | 28 | #include "ctree.h" |
@@ -2024,6 +2025,9 @@ int btrfs_balance(struct btrfs_root *dev_root) | |||
2024 | if (dev_root->fs_info->sb->s_flags & MS_RDONLY) | 2025 | if (dev_root->fs_info->sb->s_flags & MS_RDONLY) |
2025 | return -EROFS; | 2026 | return -EROFS; |
2026 | 2027 | ||
2028 | if (!capable(CAP_SYS_ADMIN)) | ||
2029 | return -EPERM; | ||
2030 | |||
2027 | mutex_lock(&dev_root->fs_info->volume_mutex); | 2031 | mutex_lock(&dev_root->fs_info->volume_mutex); |
2028 | dev_root = dev_root->fs_info->dev_root; | 2032 | dev_root = dev_root->fs_info->dev_root; |
2029 | 2033 | ||