浏览代码

Btrfs: should add a permission check for setfacl

On btrfs, do the following
------------------
# su user1
# cd btrfs-part/
# touch aaa
# getfacl aaa
  # file: aaa
  # owner: user1
  # group: user1
  user::rw-
  group::rw-
  other::r--
# su user2
# cd btrfs-part/
# setfacl -m u::rwx aaa
# getfacl aaa
  # file: aaa
  # owner: user1
  # group: user1
  user::rwx           <- successed to setfacl
  group::rw-
  other::r--
------------------
but we should prohibit it that user2 changing user1's acl.
In fact, on ext3 and other fs, a message occurs:
  setfacl: aaa: Operation not permitted

This patch fixed it.
Signed-off-by: Shi Weihua <shiwh@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Shi Weihua 15 年之前
父节点
当前提交
2f26afba46
共有 1 个文件被更改,包括 3 次插入0 次删除
  1. 3 0
      fs/btrfs/acl.c

+ 3 - 0
fs/btrfs/acl.c

@@ -160,6 +160,9 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name,
 	int ret;
 	int ret;
 	struct posix_acl *acl = NULL;
 	struct posix_acl *acl = NULL;
 
 
+	if (!is_owner_or_cap(dentry->d_inode))
+		return -EPERM;
+
 	if (value) {
 	if (value) {
 		acl = posix_acl_from_xattr(value, size);
 		acl = posix_acl_from_xattr(value, size);
 		if (acl == NULL) {
 		if (acl == NULL) {