Skip to content

Commit

Permalink
btrfs: Require CAP_SYS_ADMIN for filesystem rebalance
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Ben Hutchings <[email protected]>
Signed-off-by: Chris Mason <[email protected]>
  • Loading branch information
bwhacks authored and chrismason-xx committed Jan 16, 2011
1 parent f690efb commit 6f88a44
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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"
Expand Down Expand Up @@ -2024,6 +2025,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;

Expand Down

0 comments on commit 6f88a44

Please sign in to comment.