xref: /openbmc/linux/fs/9p/acl.c (revision 0cad6246621b5887d5b33fea84219d2a71f2f99a)
185ff872dSAneesh Kumar K.V /*
285ff872dSAneesh Kumar K.V  * Copyright IBM Corporation, 2010
385ff872dSAneesh Kumar K.V  * Author Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
485ff872dSAneesh Kumar K.V  *
585ff872dSAneesh Kumar K.V  * This program is free software; you can redistribute it and/or modify it
685ff872dSAneesh Kumar K.V  * under the terms of version 2.1 of the GNU Lesser General Public License
785ff872dSAneesh Kumar K.V  * as published by the Free Software Foundation.
885ff872dSAneesh Kumar K.V  *
985ff872dSAneesh Kumar K.V  * This program is distributed in the hope that it would be useful, but
1085ff872dSAneesh Kumar K.V  * WITHOUT ANY WARRANTY; without even the implied warranty of
1185ff872dSAneesh Kumar K.V  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
1285ff872dSAneesh Kumar K.V  *
1385ff872dSAneesh Kumar K.V  */
1485ff872dSAneesh Kumar K.V 
1585ff872dSAneesh Kumar K.V #include <linux/module.h>
1685ff872dSAneesh Kumar K.V #include <linux/fs.h>
1785ff872dSAneesh Kumar K.V #include <net/9p/9p.h>
1885ff872dSAneesh Kumar K.V #include <net/9p/client.h>
1985ff872dSAneesh Kumar K.V #include <linux/slab.h>
2022d8dcdfSAneesh Kumar K.V #include <linux/sched.h>
2185ff872dSAneesh Kumar K.V #include <linux/posix_acl_xattr.h>
2285ff872dSAneesh Kumar K.V #include "xattr.h"
2385ff872dSAneesh Kumar K.V #include "acl.h"
2476381a42SAneesh Kumar K.V #include "v9fs.h"
255ffc0cb3SAneesh Kumar K.V #include "v9fs_vfs.h"
260f235caeSAl Viro #include "fid.h"
2785ff872dSAneesh Kumar K.V 
2885ff872dSAneesh Kumar K.V static struct posix_acl *__v9fs_get_acl(struct p9_fid *fid, char *name)
2985ff872dSAneesh Kumar K.V {
3085ff872dSAneesh Kumar K.V 	ssize_t size;
3185ff872dSAneesh Kumar K.V 	void *value = NULL;
32009ca389SJoe Perches 	struct posix_acl *acl = NULL;
3385ff872dSAneesh Kumar K.V 
3485ff872dSAneesh Kumar K.V 	size = v9fs_fid_xattr_get(fid, name, NULL, 0);
3585ff872dSAneesh Kumar K.V 	if (size > 0) {
3685ff872dSAneesh Kumar K.V 		value = kzalloc(size, GFP_NOFS);
3785ff872dSAneesh Kumar K.V 		if (!value)
3885ff872dSAneesh Kumar K.V 			return ERR_PTR(-ENOMEM);
3985ff872dSAneesh Kumar K.V 		size = v9fs_fid_xattr_get(fid, name, value, size);
4085ff872dSAneesh Kumar K.V 		if (size > 0) {
415f3a4a28SEric W. Biederman 			acl = posix_acl_from_xattr(&init_user_ns, value, size);
4285ff872dSAneesh Kumar K.V 			if (IS_ERR(acl))
4385ff872dSAneesh Kumar K.V 				goto err_out;
4485ff872dSAneesh Kumar K.V 		}
4585ff872dSAneesh Kumar K.V 	} else if (size == -ENODATA || size == 0 ||
4685ff872dSAneesh Kumar K.V 		   size == -ENOSYS || size == -EOPNOTSUPP) {
4785ff872dSAneesh Kumar K.V 		acl = NULL;
4885ff872dSAneesh Kumar K.V 	} else
4985ff872dSAneesh Kumar K.V 		acl = ERR_PTR(-EIO);
5085ff872dSAneesh Kumar K.V 
5185ff872dSAneesh Kumar K.V err_out:
5285ff872dSAneesh Kumar K.V 	kfree(value);
5385ff872dSAneesh Kumar K.V 	return acl;
5485ff872dSAneesh Kumar K.V }
5585ff872dSAneesh Kumar K.V 
5685ff872dSAneesh Kumar K.V int v9fs_get_acl(struct inode *inode, struct p9_fid *fid)
5785ff872dSAneesh Kumar K.V {
5885ff872dSAneesh Kumar K.V 	int retval = 0;
5985ff872dSAneesh Kumar K.V 	struct posix_acl *pacl, *dacl;
6076381a42SAneesh Kumar K.V 	struct v9fs_session_info *v9ses;
6185ff872dSAneesh Kumar K.V 
6276381a42SAneesh Kumar K.V 	v9ses = v9fs_inode2v9ses(inode);
63e782ef71SVenkateswararao Jujjuri (JV) 	if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) ||
64e782ef71SVenkateswararao Jujjuri (JV) 			((v9ses->flags & V9FS_ACL_MASK) != V9FS_POSIX_ACL)) {
6576381a42SAneesh Kumar K.V 		set_cached_acl(inode, ACL_TYPE_DEFAULT, NULL);
6676381a42SAneesh Kumar K.V 		set_cached_acl(inode, ACL_TYPE_ACCESS, NULL);
6776381a42SAneesh Kumar K.V 		return 0;
6876381a42SAneesh Kumar K.V 	}
6985ff872dSAneesh Kumar K.V 	/* get the default/access acl values and cache them */
7097d79299SAndreas Gruenbacher 	dacl = __v9fs_get_acl(fid, XATTR_NAME_POSIX_ACL_DEFAULT);
7197d79299SAndreas Gruenbacher 	pacl = __v9fs_get_acl(fid, XATTR_NAME_POSIX_ACL_ACCESS);
7285ff872dSAneesh Kumar K.V 
7385ff872dSAneesh Kumar K.V 	if (!IS_ERR(dacl) && !IS_ERR(pacl)) {
7485ff872dSAneesh Kumar K.V 		set_cached_acl(inode, ACL_TYPE_DEFAULT, dacl);
7585ff872dSAneesh Kumar K.V 		set_cached_acl(inode, ACL_TYPE_ACCESS, pacl);
7685ff872dSAneesh Kumar K.V 	} else
7785ff872dSAneesh Kumar K.V 		retval = -EIO;
7885ff872dSAneesh Kumar K.V 
79c61fa0d6SVenkateswararao Jujjuri (JV) 	if (!IS_ERR(dacl))
80c61fa0d6SVenkateswararao Jujjuri (JV) 		posix_acl_release(dacl);
81c61fa0d6SVenkateswararao Jujjuri (JV) 
82c61fa0d6SVenkateswararao Jujjuri (JV) 	if (!IS_ERR(pacl))
83c61fa0d6SVenkateswararao Jujjuri (JV) 		posix_acl_release(pacl);
84c61fa0d6SVenkateswararao Jujjuri (JV) 
8585ff872dSAneesh Kumar K.V 	return retval;
8685ff872dSAneesh Kumar K.V }
8785ff872dSAneesh Kumar K.V 
8885ff872dSAneesh Kumar K.V static struct posix_acl *v9fs_get_cached_acl(struct inode *inode, int type)
8985ff872dSAneesh Kumar K.V {
9085ff872dSAneesh Kumar K.V 	struct posix_acl *acl;
9185ff872dSAneesh Kumar K.V 	/*
9285ff872dSAneesh Kumar K.V 	 * 9p Always cache the acl value when
9385ff872dSAneesh Kumar K.V 	 * instantiating the inode (v9fs_inode_from_fid)
9485ff872dSAneesh Kumar K.V 	 */
9585ff872dSAneesh Kumar K.V 	acl = get_cached_acl(inode, type);
96b8a7a3a6SAndreas Gruenbacher 	BUG_ON(is_uncached_acl(acl));
9785ff872dSAneesh Kumar K.V 	return acl;
9885ff872dSAneesh Kumar K.V }
9985ff872dSAneesh Kumar K.V 
100*0cad6246SMiklos Szeredi struct posix_acl *v9fs_iop_get_acl(struct inode *inode, int type, bool rcu)
10185ff872dSAneesh Kumar K.V {
10276381a42SAneesh Kumar K.V 	struct v9fs_session_info *v9ses;
10376381a42SAneesh Kumar K.V 
104*0cad6246SMiklos Szeredi 	if (rcu)
105*0cad6246SMiklos Szeredi 		return ERR_PTR(-ECHILD);
106*0cad6246SMiklos Szeredi 
10776381a42SAneesh Kumar K.V 	v9ses = v9fs_inode2v9ses(inode);
108e782ef71SVenkateswararao Jujjuri (JV) 	if (((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT) ||
109e782ef71SVenkateswararao Jujjuri (JV) 			((v9ses->flags & V9FS_ACL_MASK) != V9FS_POSIX_ACL)) {
11076381a42SAneesh Kumar K.V 		/*
111e782ef71SVenkateswararao Jujjuri (JV) 		 * On access = client  and acl = on mode get the acl
11276381a42SAneesh Kumar K.V 		 * values from the server
11376381a42SAneesh Kumar K.V 		 */
1144e34e719SChristoph Hellwig 		return NULL;
11576381a42SAneesh Kumar K.V 	}
1164e34e719SChristoph Hellwig 	return v9fs_get_cached_acl(inode, type);
11785ff872dSAneesh Kumar K.V 
11885ff872dSAneesh Kumar K.V }
1197a4566b0SAneesh Kumar K.V 
1200f235caeSAl Viro static int v9fs_set_acl(struct p9_fid *fid, int type, struct posix_acl *acl)
1216e8dc555SAneesh Kumar K.V {
1226e8dc555SAneesh Kumar K.V 	int retval;
1236e8dc555SAneesh Kumar K.V 	char *name;
1246e8dc555SAneesh Kumar K.V 	size_t size;
1256e8dc555SAneesh Kumar K.V 	void *buffer;
126d344b0fbSVenkateswararao Jujjuri (JV) 	if (!acl)
127d344b0fbSVenkateswararao Jujjuri (JV) 		return 0;
128d344b0fbSVenkateswararao Jujjuri (JV) 
1296e8dc555SAneesh Kumar K.V 	/* Set a setxattr request to server */
1306e8dc555SAneesh Kumar K.V 	size = posix_acl_xattr_size(acl->a_count);
1316e8dc555SAneesh Kumar K.V 	buffer = kmalloc(size, GFP_KERNEL);
1326e8dc555SAneesh Kumar K.V 	if (!buffer)
1336e8dc555SAneesh Kumar K.V 		return -ENOMEM;
1345f3a4a28SEric W. Biederman 	retval = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
1356e8dc555SAneesh Kumar K.V 	if (retval < 0)
1366e8dc555SAneesh Kumar K.V 		goto err_free_out;
1376e8dc555SAneesh Kumar K.V 	switch (type) {
1386e8dc555SAneesh Kumar K.V 	case ACL_TYPE_ACCESS:
13997d79299SAndreas Gruenbacher 		name = XATTR_NAME_POSIX_ACL_ACCESS;
1406e8dc555SAneesh Kumar K.V 		break;
1416e8dc555SAneesh Kumar K.V 	case ACL_TYPE_DEFAULT:
14297d79299SAndreas Gruenbacher 		name = XATTR_NAME_POSIX_ACL_DEFAULT;
1436e8dc555SAneesh Kumar K.V 		break;
1446e8dc555SAneesh Kumar K.V 	default:
1456e8dc555SAneesh Kumar K.V 		BUG();
1466e8dc555SAneesh Kumar K.V 	}
1470f235caeSAl Viro 	retval = v9fs_fid_xattr_set(fid, name, buffer, size, 0);
1486e8dc555SAneesh Kumar K.V err_free_out:
1496e8dc555SAneesh Kumar K.V 	kfree(buffer);
1506e8dc555SAneesh Kumar K.V 	return retval;
1516e8dc555SAneesh Kumar K.V }
1526e8dc555SAneesh Kumar K.V 
153be308f07SAl Viro int v9fs_acl_chmod(struct inode *inode, struct p9_fid *fid)
1546e8dc555SAneesh Kumar K.V {
1556e8dc555SAneesh Kumar K.V 	int retval = 0;
156bc26ab5fSAl Viro 	struct posix_acl *acl;
1576e8dc555SAneesh Kumar K.V 
1586e8dc555SAneesh Kumar K.V 	if (S_ISLNK(inode->i_mode))
1596e8dc555SAneesh Kumar K.V 		return -EOPNOTSUPP;
1606e8dc555SAneesh Kumar K.V 	acl = v9fs_get_cached_acl(inode, ACL_TYPE_ACCESS);
1616e8dc555SAneesh Kumar K.V 	if (acl) {
1625bf3258fSChristoph Hellwig 		retval = __posix_acl_chmod(&acl, GFP_KERNEL, inode->i_mode);
163bc26ab5fSAl Viro 		if (retval)
164bc26ab5fSAl Viro 			return retval;
1657f165aaaSAl Viro 		set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
1660f235caeSAl Viro 		retval = v9fs_set_acl(fid, ACL_TYPE_ACCESS, acl);
1676e8dc555SAneesh Kumar K.V 		posix_acl_release(acl);
1686e8dc555SAneesh Kumar K.V 	}
1696e8dc555SAneesh Kumar K.V 	return retval;
1706e8dc555SAneesh Kumar K.V }
1716e8dc555SAneesh Kumar K.V 
1723592ac44SAl Viro int v9fs_set_create_acl(struct inode *inode, struct p9_fid *fid,
1735fa6300aSAl Viro 			struct posix_acl *dacl, struct posix_acl *acl)
174ad77dbceSAneesh Kumar K.V {
1753592ac44SAl Viro 	set_cached_acl(inode, ACL_TYPE_DEFAULT, dacl);
1763592ac44SAl Viro 	set_cached_acl(inode, ACL_TYPE_ACCESS, acl);
1775fa6300aSAl Viro 	v9fs_set_acl(fid, ACL_TYPE_DEFAULT, dacl);
1785fa6300aSAl Viro 	v9fs_set_acl(fid, ACL_TYPE_ACCESS, acl);
179ad77dbceSAneesh Kumar K.V 	return 0;
180ad77dbceSAneesh Kumar K.V }
181ad77dbceSAneesh Kumar K.V 
1825fa6300aSAl Viro void v9fs_put_acl(struct posix_acl *dacl,
1835fa6300aSAl Viro 		  struct posix_acl *acl)
1845fa6300aSAl Viro {
1855fa6300aSAl Viro 	posix_acl_release(dacl);
1865fa6300aSAl Viro 	posix_acl_release(acl);
1875fa6300aSAl Viro }
1885fa6300aSAl Viro 
189d3fb6120SAl Viro int v9fs_acl_mode(struct inode *dir, umode_t *modep,
190ad77dbceSAneesh Kumar K.V 		  struct posix_acl **dpacl, struct posix_acl **pacl)
191ad77dbceSAneesh Kumar K.V {
192ad77dbceSAneesh Kumar K.V 	int retval = 0;
193d3fb6120SAl Viro 	umode_t mode = *modep;
194ad77dbceSAneesh Kumar K.V 	struct posix_acl *acl = NULL;
195ad77dbceSAneesh Kumar K.V 
196ad77dbceSAneesh Kumar K.V 	if (!S_ISLNK(mode)) {
197ad77dbceSAneesh Kumar K.V 		acl = v9fs_get_cached_acl(dir, ACL_TYPE_DEFAULT);
198ad77dbceSAneesh Kumar K.V 		if (IS_ERR(acl))
199ad77dbceSAneesh Kumar K.V 			return PTR_ERR(acl);
200ad77dbceSAneesh Kumar K.V 		if (!acl)
201ad77dbceSAneesh Kumar K.V 			mode &= ~current_umask();
202ad77dbceSAneesh Kumar K.V 	}
203ad77dbceSAneesh Kumar K.V 	if (acl) {
204ad77dbceSAneesh Kumar K.V 		if (S_ISDIR(mode))
2051ec95bf3SAl Viro 			*dpacl = posix_acl_dup(acl);
20637bc1539SChristoph Hellwig 		retval = __posix_acl_create(&acl, GFP_NOFS, &mode);
207826cae2fSAl Viro 		if (retval < 0)
208826cae2fSAl Viro 			return retval;
209ad77dbceSAneesh Kumar K.V 		if (retval > 0)
210826cae2fSAl Viro 			*pacl = acl;
2111ec95bf3SAl Viro 		else
212826cae2fSAl Viro 			posix_acl_release(acl);
213ad77dbceSAneesh Kumar K.V 	}
214ad77dbceSAneesh Kumar K.V 	*modep  = mode;
215ad77dbceSAneesh Kumar K.V 	return 0;
216ad77dbceSAneesh Kumar K.V }
217ad77dbceSAneesh Kumar K.V 
218d9a82a04SAndreas Gruenbacher static int v9fs_xattr_get_acl(const struct xattr_handler *handler,
219b296821aSAl Viro 			      struct dentry *dentry, struct inode *inode,
220b296821aSAl Viro 			      const char *name, void *buffer, size_t size)
2217a4566b0SAneesh Kumar K.V {
22276381a42SAneesh Kumar K.V 	struct v9fs_session_info *v9ses;
2237a4566b0SAneesh Kumar K.V 	struct posix_acl *acl;
2247a4566b0SAneesh Kumar K.V 	int error;
2257a4566b0SAneesh Kumar K.V 
22642869c8aSAneesh Kumar K.V 	v9ses = v9fs_dentry2v9ses(dentry);
22776381a42SAneesh Kumar K.V 	/*
22876381a42SAneesh Kumar K.V 	 * We allow set/get/list of acl when access=client is not specified
22976381a42SAneesh Kumar K.V 	 */
23076381a42SAneesh Kumar K.V 	if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
23198e9cb57SAndreas Gruenbacher 		return v9fs_xattr_get(dentry, handler->name, buffer, size);
23276381a42SAneesh Kumar K.V 
233b296821aSAl Viro 	acl = v9fs_get_cached_acl(inode, handler->flags);
2347a4566b0SAneesh Kumar K.V 	if (IS_ERR(acl))
2357a4566b0SAneesh Kumar K.V 		return PTR_ERR(acl);
2367a4566b0SAneesh Kumar K.V 	if (acl == NULL)
2377a4566b0SAneesh Kumar K.V 		return -ENODATA;
2385f3a4a28SEric W. Biederman 	error = posix_acl_to_xattr(&init_user_ns, acl, buffer, size);
2397a4566b0SAneesh Kumar K.V 	posix_acl_release(acl);
2407a4566b0SAneesh Kumar K.V 
2417a4566b0SAneesh Kumar K.V 	return error;
2427a4566b0SAneesh Kumar K.V }
2437a4566b0SAneesh Kumar K.V 
244d9a82a04SAndreas Gruenbacher static int v9fs_xattr_set_acl(const struct xattr_handler *handler,
245e65ce2a5SChristian Brauner 			      struct user_namespace *mnt_userns,
24659301226SAl Viro 			      struct dentry *dentry, struct inode *inode,
24759301226SAl Viro 			      const char *name, const void *value,
24859301226SAl Viro 			      size_t size, int flags)
2497a4566b0SAneesh Kumar K.V {
25022d8dcdfSAneesh Kumar K.V 	int retval;
25122d8dcdfSAneesh Kumar K.V 	struct posix_acl *acl;
25276381a42SAneesh Kumar K.V 	struct v9fs_session_info *v9ses;
25322d8dcdfSAneesh Kumar K.V 
25442869c8aSAneesh Kumar K.V 	v9ses = v9fs_dentry2v9ses(dentry);
25576381a42SAneesh Kumar K.V 	/*
25676381a42SAneesh Kumar K.V 	 * set the attribute on the remote. Without even looking at the
25776381a42SAneesh Kumar K.V 	 * xattr value. We leave it to the server to validate
25876381a42SAneesh Kumar K.V 	 */
25976381a42SAneesh Kumar K.V 	if ((v9ses->flags & V9FS_ACCESS_MASK) != V9FS_ACCESS_CLIENT)
26098e9cb57SAndreas Gruenbacher 		return v9fs_xattr_set(dentry, handler->name, value, size,
261e409de99SAndreas Gruenbacher 				      flags);
26276381a42SAneesh Kumar K.V 
26322d8dcdfSAneesh Kumar K.V 	if (S_ISLNK(inode->i_mode))
26422d8dcdfSAneesh Kumar K.V 		return -EOPNOTSUPP;
26521cb47beSChristian Brauner 	if (!inode_owner_or_capable(&init_user_ns, inode))
26622d8dcdfSAneesh Kumar K.V 		return -EPERM;
26722d8dcdfSAneesh Kumar K.V 	if (value) {
26822d8dcdfSAneesh Kumar K.V 		/* update the cached acl value */
2695f3a4a28SEric W. Biederman 		acl = posix_acl_from_xattr(&init_user_ns, value, size);
27022d8dcdfSAneesh Kumar K.V 		if (IS_ERR(acl))
27122d8dcdfSAneesh Kumar K.V 			return PTR_ERR(acl);
27222d8dcdfSAneesh Kumar K.V 		else if (acl) {
2730d4d717fSEric W. Biederman 			retval = posix_acl_valid(inode->i_sb->s_user_ns, acl);
27422d8dcdfSAneesh Kumar K.V 			if (retval)
27522d8dcdfSAneesh Kumar K.V 				goto err_out;
27622d8dcdfSAneesh Kumar K.V 		}
27722d8dcdfSAneesh Kumar K.V 	} else
27822d8dcdfSAneesh Kumar K.V 		acl = NULL;
27922d8dcdfSAneesh Kumar K.V 
280d9a82a04SAndreas Gruenbacher 	switch (handler->flags) {
28122d8dcdfSAneesh Kumar K.V 	case ACL_TYPE_ACCESS:
28222d8dcdfSAneesh Kumar K.V 		if (acl) {
283e02a53d9SDominique Martinet 			struct iattr iattr = { 0 };
284b5c66babSCong Wang 			struct posix_acl *old_acl = acl;
28507393101SJan Kara 
286549c7297SChristian Brauner 			retval = posix_acl_update_mode(&init_user_ns, inode,
287e65ce2a5SChristian Brauner 						       &iattr.ia_mode, &acl);
28807393101SJan Kara 			if (retval)
28907393101SJan Kara 				goto err_out;
29007393101SJan Kara 			if (!acl) {
29122d8dcdfSAneesh Kumar K.V 				/*
29222d8dcdfSAneesh Kumar K.V 				 * ACL can be represented
29322d8dcdfSAneesh Kumar K.V 				 * by the mode bits. So don't
29422d8dcdfSAneesh Kumar K.V 				 * update ACL.
29522d8dcdfSAneesh Kumar K.V 				 */
296b5c66babSCong Wang 				posix_acl_release(old_acl);
29722d8dcdfSAneesh Kumar K.V 				value = NULL;
29822d8dcdfSAneesh Kumar K.V 				size = 0;
29922d8dcdfSAneesh Kumar K.V 			}
30022d8dcdfSAneesh Kumar K.V 			iattr.ia_valid = ATTR_MODE;
30122d8dcdfSAneesh Kumar K.V 			/* FIXME should we update ctime ?
30222d8dcdfSAneesh Kumar K.V 			 * What is the following setxattr update the
30322d8dcdfSAneesh Kumar K.V 			 * mode ?
30422d8dcdfSAneesh Kumar K.V 			 */
305549c7297SChristian Brauner 			v9fs_vfs_setattr_dotl(&init_user_ns, dentry, &iattr);
30622d8dcdfSAneesh Kumar K.V 		}
30722d8dcdfSAneesh Kumar K.V 		break;
30822d8dcdfSAneesh Kumar K.V 	case ACL_TYPE_DEFAULT:
30922d8dcdfSAneesh Kumar K.V 		if (!S_ISDIR(inode->i_mode)) {
3106f81c115SAneesh Kumar K.V 			retval = acl ? -EINVAL : 0;
31122d8dcdfSAneesh Kumar K.V 			goto err_out;
31222d8dcdfSAneesh Kumar K.V 		}
31322d8dcdfSAneesh Kumar K.V 		break;
31422d8dcdfSAneesh Kumar K.V 	default:
31522d8dcdfSAneesh Kumar K.V 		BUG();
31622d8dcdfSAneesh Kumar K.V 	}
31798e9cb57SAndreas Gruenbacher 	retval = v9fs_xattr_set(dentry, handler->name, value, size, flags);
31822d8dcdfSAneesh Kumar K.V 	if (!retval)
319d9a82a04SAndreas Gruenbacher 		set_cached_acl(inode, handler->flags, acl);
32022d8dcdfSAneesh Kumar K.V err_out:
32122d8dcdfSAneesh Kumar K.V 	posix_acl_release(acl);
32222d8dcdfSAneesh Kumar K.V 	return retval;
3237a4566b0SAneesh Kumar K.V }
3247a4566b0SAneesh Kumar K.V 
3257a4566b0SAneesh Kumar K.V const struct xattr_handler v9fs_xattr_acl_access_handler = {
32698e9cb57SAndreas Gruenbacher 	.name	= XATTR_NAME_POSIX_ACL_ACCESS,
3277a4566b0SAneesh Kumar K.V 	.flags	= ACL_TYPE_ACCESS,
3287a4566b0SAneesh Kumar K.V 	.get	= v9fs_xattr_get_acl,
3297a4566b0SAneesh Kumar K.V 	.set	= v9fs_xattr_set_acl,
3307a4566b0SAneesh Kumar K.V };
3317a4566b0SAneesh Kumar K.V 
3327a4566b0SAneesh Kumar K.V const struct xattr_handler v9fs_xattr_acl_default_handler = {
33398e9cb57SAndreas Gruenbacher 	.name	= XATTR_NAME_POSIX_ACL_DEFAULT,
3347a4566b0SAneesh Kumar K.V 	.flags	= ACL_TYPE_DEFAULT,
3357a4566b0SAneesh Kumar K.V 	.get	= v9fs_xattr_get_acl,
3367a4566b0SAneesh Kumar K.V 	.set	= v9fs_xattr_set_acl,
3377a4566b0SAneesh Kumar K.V };
338