From: Ben Hutchings Date: Wed, 29 Dec 2010 14:55:03 +0000 (+0000) Subject: btrfs: Require CAP_SYS_ADMIN for filesystem rebalance X-Git-Tag: v2.6.35.14~195 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5e74595507c13d213d716475d9c9fa061cd263c;p=thirdparty%2Fkernel%2Fstable.git 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 Signed-off-by: Ben Hutchings Signed-off-by: Chris Mason Signed-off-by: Greg Kroah-Hartman Signed-off-by: Andi Kleen --- diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index d6e3af8be95b9..dc0dedfa8e0cf 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "compat.h" #include "ctree.h" @@ -1909,6 +1910,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;