This was commit 2f26afba46f0ebf155cf9be746496a0304a5b7cf.

>From 2f26afba46f0ebf155cf9be746496a0304a5b7cf Mon Sep 17 00:00:00 2001
From: Shi Weihua <sh...@cn.fujitsu.com>
Date: Tue, 18 May 2010 00:50:32 +0000
Subject: [PATCH] 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 <sh...@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.ma...@oracle.com>
---
 fs/btrfs/acl.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
index 6ef7b26..6b4d0cc 100644
--- a/fs/btrfs/acl.c
+++ b/fs/btrfs/acl.c
@@ -160,6 +160,9 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const 
char *name,
        int ret;
        struct posix_acl *acl = NULL;
 
+       if (!is_owner_or_cap(dentry->d_inode))
+               return -EPERM;
+
        if (value) {
                acl = posix_acl_from_xattr(value, size);
                if (acl == NULL) {
-- 
1.7.1



-- 
To UNSUBSCRIBE, email to debian-kernel-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/20100620163021.ga21...@wavehammer.waldi.eu.org

Reply via email to