summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorBen Hutchings <ben@decadent.org.uk>2010-12-29 14:55:03 +0000
committerGreg Kroah-Hartman <gregkh@suse.de>2011-05-09 15:55:35 -0700
commit84daae5dc885913953823b1303e1fbbbb38a5a53 (patch)
tree939ea0dd6c267fe4f1524be25968517b9715f2ca /fs
parent4c8478ffa104fa9df0765dd05f395cce3d7a96b4 (diff)
btrfs: Require CAP_SYS_ADMIN for filesystem rebalance
commit 6f88a4403def422bd8e276ddf6863d6ac71435d2 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/volumes.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 41ecbb2347f2..5d56a8dab69b 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -21,6 +21,7 @@
#include <linux/blkdev.h>
#include <linux/random.h>
#include <linux/iocontext.h>
+#include <linux/capability.h>
#include <asm/div64.h>
#include "compat.h"
#include "ctree.h"
@@ -1900,6 +1901,9 @@ int btrfs_balance(struct btrfs_root *dev_root)
if (dev_root->fs_info->sb->s_flags & MS_RDONLY)
return -EROFS;
+ if (!capable(CAP_SYS_ADMIN))
+ return -EPERM;
+
mutex_lock(&dev_root->fs_info->volume_mutex);
dev_root = dev_root->fs_info->dev_root;