aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xattr.c
diff options
context:
space:
mode:
authorGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
committerGlenn Elliott <gelliott@cs.unc.edu>2012-03-04 19:47:13 -0500
commitc71c03bda1e86c9d5198c5d83f712e695c4f2a1e (patch)
treeecb166cb3e2b7e2adb3b5e292245fefd23381ac8 /fs/xattr.c
parentea53c912f8a86a8567697115b6a0d8152beee5c8 (diff)
parent6a00f206debf8a5c8899055726ad127dbeeed098 (diff)
Merge branch 'mpi-master' into wip-k-fmlpwip-k-fmlp
Conflicts: litmus/sched_cedf.c
Diffstat (limited to 'fs/xattr.c')
-rw-r--r--fs/xattr.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/fs/xattr.c b/fs/xattr.c
index 01bb8135e14a..f060663ab70c 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -46,20 +46,24 @@ xattr_permission(struct inode *inode, const char *name, int mask)
46 return 0; 46 return 0;
47 47
48 /* 48 /*
49 * The trusted.* namespace can only be accessed by a privileged user. 49 * The trusted.* namespace can only be accessed by privileged users.
50 */ 50 */
51 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) 51 if (!strncmp(name, XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN)) {
52 return (capable(CAP_SYS_ADMIN) ? 0 : -EPERM); 52 if (!capable(CAP_SYS_ADMIN))
53 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
54 return 0;
55 }
53 56
54 /* In user.* namespace, only regular files and directories can have 57 /*
58 * In the user.* namespace, only regular files and directories can have
55 * extended attributes. For sticky directories, only the owner and 59 * extended attributes. For sticky directories, only the owner and
56 * privileged user can write attributes. 60 * privileged users can write attributes.
57 */ 61 */
58 if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) { 62 if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
59 if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode)) 63 if (!S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
60 return -EPERM; 64 return (mask & MAY_WRITE) ? -EPERM : -ENODATA;
61 if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) && 65 if (S_ISDIR(inode->i_mode) && (inode->i_mode & S_ISVTX) &&
62 (mask & MAY_WRITE) && !is_owner_or_cap(inode)) 66 (mask & MAY_WRITE) && !inode_owner_or_capable(inode))
63 return -EPERM; 67 return -EPERM;
64 } 68 }
65 69
@@ -87,7 +91,11 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const char *name,
87{ 91{
88 struct inode *inode = dentry->d_inode; 92 struct inode *inode = dentry->d_inode;
89 int error = -EOPNOTSUPP; 93 int error = -EOPNOTSUPP;
94 int issec = !strncmp(name, XATTR_SECURITY_PREFIX,
95 XATTR_SECURITY_PREFIX_LEN);
90 96
97 if (issec)
98 inode->i_flags &= ~S_NOSEC;
91 if (inode->i_op->setxattr) { 99 if (inode->i_op->setxattr) {
92 error = inode->i_op->setxattr(dentry, name, value, size, flags); 100 error = inode->i_op->setxattr(dentry, name, value, size, flags);
93 if (!error) { 101 if (!error) {
@@ -95,8 +103,7 @@ int __vfs_setxattr_noperm(struct dentry *dentry, const char *name,
95 security_inode_post_setxattr(dentry, name, value, 103 security_inode_post_setxattr(dentry, name, value,
96 size, flags); 104 size, flags);
97 } 105 }
98 } else if (!strncmp(name, XATTR_SECURITY_PREFIX, 106 } else if (issec) {
99 XATTR_SECURITY_PREFIX_LEN)) {
100 const char *suffix = name + XATTR_SECURITY_PREFIX_LEN; 107 const char *suffix = name + XATTR_SECURITY_PREFIX_LEN;
101 error = security_inode_setsecurity(inode, suffix, value, 108 error = security_inode_setsecurity(inode, suffix, value,
102 size, flags); 109 size, flags);
@@ -666,7 +673,7 @@ generic_setxattr(struct dentry *dentry, const char *name, const void *value, siz
666 handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name); 673 handler = xattr_resolve_name(dentry->d_sb->s_xattr, &name);
667 if (!handler) 674 if (!handler)
668 return -EOPNOTSUPP; 675 return -EOPNOTSUPP;
669 return handler->set(dentry, name, value, size, 0, handler->flags); 676 return handler->set(dentry, name, value, size, flags, handler->flags);
670} 677}
671 678
672/* 679/*