aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/acl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/acl.c')
-rw-r--r--fs/btrfs/acl.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
index 6df6d6ed74fd..2222d161c7b6 100644
--- a/fs/btrfs/acl.c
+++ b/fs/btrfs/acl.c
@@ -22,6 +22,7 @@
22#include <linux/posix_acl_xattr.h> 22#include <linux/posix_acl_xattr.h>
23#include <linux/posix_acl.h> 23#include <linux/posix_acl.h>
24#include <linux/sched.h> 24#include <linux/sched.h>
25#include <linux/slab.h>
25 26
26#include "ctree.h" 27#include "ctree.h"
27#include "btrfs_inode.h" 28#include "btrfs_inode.h"
@@ -59,6 +60,8 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
59 size = __btrfs_getxattr(inode, name, value, size); 60 size = __btrfs_getxattr(inode, name, value, size);
60 if (size > 0) { 61 if (size > 0) {
61 acl = posix_acl_from_xattr(value, size); 62 acl = posix_acl_from_xattr(value, size);
63 if (IS_ERR(acl))
64 return acl;
62 set_cached_acl(inode, type, acl); 65 set_cached_acl(inode, type, acl);
63 } 66 }
64 kfree(value); 67 kfree(value);
@@ -159,6 +162,12 @@ static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name,
159 int ret; 162 int ret;
160 struct posix_acl *acl = NULL; 163 struct posix_acl *acl = NULL;
161 164
165 if (!is_owner_or_cap(dentry->d_inode))
166 return -EPERM;
167
168 if (!IS_POSIXACL(dentry->d_inode))
169 return -EOPNOTSUPP;
170
162 if (value) { 171 if (value) {
163 acl = posix_acl_from_xattr(value, size); 172 acl = posix_acl_from_xattr(value, size);
164 if (acl == NULL) { 173 if (acl == NULL) {
@@ -281,14 +290,14 @@ int btrfs_acl_chmod(struct inode *inode)
281 return ret; 290 return ret;
282} 291}
283 292
284struct xattr_handler btrfs_xattr_acl_default_handler = { 293const struct xattr_handler btrfs_xattr_acl_default_handler = {
285 .prefix = POSIX_ACL_XATTR_DEFAULT, 294 .prefix = POSIX_ACL_XATTR_DEFAULT,
286 .flags = ACL_TYPE_DEFAULT, 295 .flags = ACL_TYPE_DEFAULT,
287 .get = btrfs_xattr_acl_get, 296 .get = btrfs_xattr_acl_get,
288 .set = btrfs_xattr_acl_set, 297 .set = btrfs_xattr_acl_set,
289}; 298};
290 299
291struct xattr_handler btrfs_xattr_acl_access_handler = { 300const struct xattr_handler btrfs_xattr_acl_access_handler = {
292 .prefix = POSIX_ACL_XATTR_ACCESS, 301 .prefix = POSIX_ACL_XATTR_ACCESS,
293 .flags = ACL_TYPE_ACCESS, 302 .flags = ACL_TYPE_ACCESS,
294 .get = btrfs_xattr_acl_get, 303 .get = btrfs_xattr_acl_get,