diff options
Diffstat (limited to 'fs/btrfs/xattr.c')
| -rw-r--r-- | fs/btrfs/xattr.c | 24 | 
1 files changed, 22 insertions, 2 deletions
| diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c index 698fdd2c739..d779cefcfd7 100644 --- a/fs/btrfs/xattr.c +++ b/fs/btrfs/xattr.c @@ -316,6 +316,15 @@ ssize_t btrfs_getxattr(struct dentry *dentry, const char *name,  int btrfs_setxattr(struct dentry *dentry, const char *name, const void *value,  		   size_t size, int flags)  { +	struct btrfs_root *root = BTRFS_I(dentry->d_inode)->root; + +	/* +	 * The permission on security.* and system.* is not checked +	 * in permission(). +	 */ +	if (btrfs_root_readonly(root)) +		return -EROFS; +  	/*  	 * If this is a request for a synthetic attribute in the system.*  	 * namespace use the generic infrastructure to resolve a handler @@ -336,6 +345,15 @@ int btrfs_setxattr(struct dentry *dentry, const char *name, const void *value,  int btrfs_removexattr(struct dentry *dentry, const char *name)  { +	struct btrfs_root *root = BTRFS_I(dentry->d_inode)->root; + +	/* +	 * The permission on security.* and system.* is not checked +	 * in permission(). +	 */ +	if (btrfs_root_readonly(root)) +		return -EROFS; +  	/*  	 * If this is a request for a synthetic attribute in the system.*  	 * namespace use the generic infrastructure to resolve a handler @@ -352,7 +370,8 @@ int btrfs_removexattr(struct dentry *dentry, const char *name)  }  int btrfs_xattr_security_init(struct btrfs_trans_handle *trans, -			      struct inode *inode, struct inode *dir) +			      struct inode *inode, struct inode *dir, +			      const struct qstr *qstr)  {  	int err;  	size_t len; @@ -360,7 +379,8 @@ int btrfs_xattr_security_init(struct btrfs_trans_handle *trans,  	char *suffix;  	char *name; -	err = security_inode_init_security(inode, dir, &suffix, &value, &len); +	err = security_inode_init_security(inode, dir, qstr, &suffix, &value, +					   &len);  	if (err) {  		if (err == -EOPNOTSUPP)  			return 0; | 
