1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 2a257cdd0SAndreas Gruenbacher /* 3a257cdd0SAndreas Gruenbacher * Process version 2 NFSACL requests. 4a257cdd0SAndreas Gruenbacher * 5a257cdd0SAndreas Gruenbacher * Copyright (C) 2002-2003 Andreas Gruenbacher <agruen@suse.de> 6a257cdd0SAndreas Gruenbacher */ 7a257cdd0SAndreas Gruenbacher 89a74af21SBoaz Harrosh #include "nfsd.h" 99a74af21SBoaz Harrosh /* FIXME: nfsacl.h is a broken header */ 10a257cdd0SAndreas Gruenbacher #include <linux/nfsacl.h> 115a0e3ad6STejun Heo #include <linux/gfp.h> 129a74af21SBoaz Harrosh #include "cache.h" 139a74af21SBoaz Harrosh #include "xdr3.h" 140a3adadeSJ. Bruce Fields #include "vfs.h" 15a257cdd0SAndreas Gruenbacher 16a257cdd0SAndreas Gruenbacher #define NFSDDBG_FACILITY NFSDDBG_PROC 17a257cdd0SAndreas Gruenbacher #define RETURN_STATUS(st) { resp->status = (st); return (st); } 18a257cdd0SAndreas Gruenbacher 19a257cdd0SAndreas Gruenbacher /* 20a257cdd0SAndreas Gruenbacher * NULL call. 21a257cdd0SAndreas Gruenbacher */ 227111c66eSAl Viro static __be32 23a6beb732SChristoph Hellwig nfsacld_proc_null(struct svc_rqst *rqstp) 24a257cdd0SAndreas Gruenbacher { 25a257cdd0SAndreas Gruenbacher return nfs_ok; 26a257cdd0SAndreas Gruenbacher } 27a257cdd0SAndreas Gruenbacher 28a257cdd0SAndreas Gruenbacher /* 29a257cdd0SAndreas Gruenbacher * Get the Access and/or Default ACL of a file. 30a257cdd0SAndreas Gruenbacher */ 31a6beb732SChristoph Hellwig static __be32 nfsacld_proc_getacl(struct svc_rqst *rqstp) 32a257cdd0SAndreas Gruenbacher { 33a6beb732SChristoph Hellwig struct nfsd3_getaclargs *argp = rqstp->rq_argp; 34a6beb732SChristoph Hellwig struct nfsd3_getaclres *resp = rqstp->rq_resp; 35a257cdd0SAndreas Gruenbacher struct posix_acl *acl; 364ac7249eSChristoph Hellwig struct inode *inode; 374ac7249eSChristoph Hellwig svc_fh *fh; 38c4d987baSAl Viro __be32 nfserr = 0; 39a257cdd0SAndreas Gruenbacher 40a257cdd0SAndreas Gruenbacher dprintk("nfsd: GETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); 41a257cdd0SAndreas Gruenbacher 42a257cdd0SAndreas Gruenbacher fh = fh_copy(&resp->fh, &argp->fh); 438837abcaSMiklos Szeredi nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); 448837abcaSMiklos Szeredi if (nfserr) 45ac8587dcSJ. Bruce Fields RETURN_STATUS(nfserr); 46a257cdd0SAndreas Gruenbacher 472b0143b5SDavid Howells inode = d_inode(fh->fh_dentry); 484ac7249eSChristoph Hellwig 497b8f4586SKinglong Mee if (argp->mask & ~NFS_ACL_MASK) 50a257cdd0SAndreas Gruenbacher RETURN_STATUS(nfserr_inval); 51a257cdd0SAndreas Gruenbacher resp->mask = argp->mask; 52a257cdd0SAndreas Gruenbacher 534f4a4fadSJ. Bruce Fields nfserr = fh_getattr(fh, &resp->stat); 544f4a4fadSJ. Bruce Fields if (nfserr) 557b8f4586SKinglong Mee RETURN_STATUS(nfserr); 564f4a4fadSJ. Bruce Fields 57a257cdd0SAndreas Gruenbacher if (resp->mask & (NFS_ACL|NFS_ACLCNT)) { 584ac7249eSChristoph Hellwig acl = get_acl(inode, ACL_TYPE_ACCESS); 59a257cdd0SAndreas Gruenbacher if (acl == NULL) { 60a257cdd0SAndreas Gruenbacher /* Solaris returns the inode's minimum ACL. */ 61a257cdd0SAndreas Gruenbacher acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); 62a257cdd0SAndreas Gruenbacher } 6335e634b8SKinglong Mee if (IS_ERR(acl)) { 6435e634b8SKinglong Mee nfserr = nfserrno(PTR_ERR(acl)); 6535e634b8SKinglong Mee goto fail; 6635e634b8SKinglong Mee } 67a257cdd0SAndreas Gruenbacher resp->acl_access = acl; 68a257cdd0SAndreas Gruenbacher } 69a257cdd0SAndreas Gruenbacher if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) { 70a257cdd0SAndreas Gruenbacher /* Check how Solaris handles requests for the Default ACL 71a257cdd0SAndreas Gruenbacher of a non-directory! */ 724ac7249eSChristoph Hellwig acl = get_acl(inode, ACL_TYPE_DEFAULT); 73a257cdd0SAndreas Gruenbacher if (IS_ERR(acl)) { 744ac7249eSChristoph Hellwig nfserr = nfserrno(PTR_ERR(acl)); 75a257cdd0SAndreas Gruenbacher goto fail; 76a257cdd0SAndreas Gruenbacher } 77a257cdd0SAndreas Gruenbacher resp->acl_default = acl; 78a257cdd0SAndreas Gruenbacher } 79a257cdd0SAndreas Gruenbacher 80a257cdd0SAndreas Gruenbacher /* resp->acl_{access,default} are released in nfssvc_release_getacl. */ 81a257cdd0SAndreas Gruenbacher RETURN_STATUS(0); 82a257cdd0SAndreas Gruenbacher 83a257cdd0SAndreas Gruenbacher fail: 84a257cdd0SAndreas Gruenbacher posix_acl_release(resp->acl_access); 85a257cdd0SAndreas Gruenbacher posix_acl_release(resp->acl_default); 86a257cdd0SAndreas Gruenbacher RETURN_STATUS(nfserr); 87a257cdd0SAndreas Gruenbacher } 88a257cdd0SAndreas Gruenbacher 89a257cdd0SAndreas Gruenbacher /* 90a257cdd0SAndreas Gruenbacher * Set the Access and/or Default ACL of a file. 91a257cdd0SAndreas Gruenbacher */ 92a6beb732SChristoph Hellwig static __be32 nfsacld_proc_setacl(struct svc_rqst *rqstp) 93a257cdd0SAndreas Gruenbacher { 94a6beb732SChristoph Hellwig struct nfsd3_setaclargs *argp = rqstp->rq_argp; 95a6beb732SChristoph Hellwig struct nfsd_attrstat *resp = rqstp->rq_resp; 964ac7249eSChristoph Hellwig struct inode *inode; 97a257cdd0SAndreas Gruenbacher svc_fh *fh; 98c4d987baSAl Viro __be32 nfserr = 0; 994ac7249eSChristoph Hellwig int error; 100a257cdd0SAndreas Gruenbacher 101a257cdd0SAndreas Gruenbacher dprintk("nfsd: SETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); 102a257cdd0SAndreas Gruenbacher 103a257cdd0SAndreas Gruenbacher fh = fh_copy(&resp->fh, &argp->fh); 1048837abcaSMiklos Szeredi nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR); 1054ac7249eSChristoph Hellwig if (nfserr) 1064ac7249eSChristoph Hellwig goto out; 107a257cdd0SAndreas Gruenbacher 1082b0143b5SDavid Howells inode = d_inode(fh->fh_dentry); 1094ac7249eSChristoph Hellwig 1104ac7249eSChristoph Hellwig error = fh_want_write(fh); 1114ac7249eSChristoph Hellwig if (error) 1124ac7249eSChristoph Hellwig goto out_errno; 1134ac7249eSChristoph Hellwig 11499965378SBen Hutchings fh_lock(fh); 11599965378SBen Hutchings 11699965378SBen Hutchings error = set_posix_acl(inode, ACL_TYPE_ACCESS, argp->acl_access); 1174ac7249eSChristoph Hellwig if (error) 11899965378SBen Hutchings goto out_drop_lock; 11999965378SBen Hutchings error = set_posix_acl(inode, ACL_TYPE_DEFAULT, argp->acl_default); 1204ac7249eSChristoph Hellwig if (error) 12199965378SBen Hutchings goto out_drop_lock; 12299965378SBen Hutchings 12399965378SBen Hutchings fh_unlock(fh); 1244ac7249eSChristoph Hellwig 1254ac7249eSChristoph Hellwig fh_drop_write(fh); 1264ac7249eSChristoph Hellwig 1274f4a4fadSJ. Bruce Fields nfserr = fh_getattr(fh, &resp->stat); 128a257cdd0SAndreas Gruenbacher 1294ac7249eSChristoph Hellwig out: 130a257cdd0SAndreas Gruenbacher /* argp->acl_{access,default} may have been allocated in 131a257cdd0SAndreas Gruenbacher nfssvc_decode_setaclargs. */ 132a257cdd0SAndreas Gruenbacher posix_acl_release(argp->acl_access); 133a257cdd0SAndreas Gruenbacher posix_acl_release(argp->acl_default); 134a257cdd0SAndreas Gruenbacher return nfserr; 13599965378SBen Hutchings out_drop_lock: 13699965378SBen Hutchings fh_unlock(fh); 1374ac7249eSChristoph Hellwig fh_drop_write(fh); 1384ac7249eSChristoph Hellwig out_errno: 1394ac7249eSChristoph Hellwig nfserr = nfserrno(error); 1404ac7249eSChristoph Hellwig goto out; 141a257cdd0SAndreas Gruenbacher } 142a257cdd0SAndreas Gruenbacher 143a257cdd0SAndreas Gruenbacher /* 144a257cdd0SAndreas Gruenbacher * Check file attributes 145a257cdd0SAndreas Gruenbacher */ 146a6beb732SChristoph Hellwig static __be32 nfsacld_proc_getattr(struct svc_rqst *rqstp) 147a257cdd0SAndreas Gruenbacher { 148a6beb732SChristoph Hellwig struct nfsd_fhandle *argp = rqstp->rq_argp; 149a6beb732SChristoph Hellwig struct nfsd_attrstat *resp = rqstp->rq_resp; 1504f4a4fadSJ. Bruce Fields __be32 nfserr; 151a257cdd0SAndreas Gruenbacher dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh)); 152a257cdd0SAndreas Gruenbacher 153a257cdd0SAndreas Gruenbacher fh_copy(&resp->fh, &argp->fh); 1544f4a4fadSJ. Bruce Fields nfserr = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); 1554f4a4fadSJ. Bruce Fields if (nfserr) 1564f4a4fadSJ. Bruce Fields return nfserr; 1574f4a4fadSJ. Bruce Fields nfserr = fh_getattr(&resp->fh, &resp->stat); 1584f4a4fadSJ. Bruce Fields return nfserr; 159a257cdd0SAndreas Gruenbacher } 160a257cdd0SAndreas Gruenbacher 161a257cdd0SAndreas Gruenbacher /* 162a257cdd0SAndreas Gruenbacher * Check file access 163a257cdd0SAndreas Gruenbacher */ 164a6beb732SChristoph Hellwig static __be32 nfsacld_proc_access(struct svc_rqst *rqstp) 165a257cdd0SAndreas Gruenbacher { 166a6beb732SChristoph Hellwig struct nfsd3_accessargs *argp = rqstp->rq_argp; 167a6beb732SChristoph Hellwig struct nfsd3_accessres *resp = rqstp->rq_resp; 168c4d987baSAl Viro __be32 nfserr; 169a257cdd0SAndreas Gruenbacher 170a257cdd0SAndreas Gruenbacher dprintk("nfsd: ACCESS(2acl) %s 0x%x\n", 171a257cdd0SAndreas Gruenbacher SVCFH_fmt(&argp->fh), 172a257cdd0SAndreas Gruenbacher argp->access); 173a257cdd0SAndreas Gruenbacher 174a257cdd0SAndreas Gruenbacher fh_copy(&resp->fh, &argp->fh); 175a257cdd0SAndreas Gruenbacher resp->access = argp->access; 176a257cdd0SAndreas Gruenbacher nfserr = nfsd_access(rqstp, &resp->fh, &resp->access, NULL); 1774f4a4fadSJ. Bruce Fields if (nfserr) 1784f4a4fadSJ. Bruce Fields return nfserr; 1794f4a4fadSJ. Bruce Fields nfserr = fh_getattr(&resp->fh, &resp->stat); 180a257cdd0SAndreas Gruenbacher return nfserr; 181a257cdd0SAndreas Gruenbacher } 182a257cdd0SAndreas Gruenbacher 183a257cdd0SAndreas Gruenbacher /* 184a257cdd0SAndreas Gruenbacher * XDR decode functions 185a257cdd0SAndreas Gruenbacher */ 186*dcc46991SChuck Lever static int nfsaclsvc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p) 187*dcc46991SChuck Lever { 188*dcc46991SChuck Lever return 1; 189*dcc46991SChuck Lever } 190*dcc46991SChuck Lever 191026fec7eSChristoph Hellwig static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p) 192a257cdd0SAndreas Gruenbacher { 193026fec7eSChristoph Hellwig struct nfsd3_getaclargs *argp = rqstp->rq_argp; 194026fec7eSChristoph Hellwig 195d40aa337SBenoit Taine p = nfs2svc_decode_fh(p, &argp->fh); 196d40aa337SBenoit Taine if (!p) 197a257cdd0SAndreas Gruenbacher return 0; 198a257cdd0SAndreas Gruenbacher argp->mask = ntohl(*p); p++; 199a257cdd0SAndreas Gruenbacher 200a257cdd0SAndreas Gruenbacher return xdr_argsize_check(rqstp, p); 201a257cdd0SAndreas Gruenbacher } 202a257cdd0SAndreas Gruenbacher 203a257cdd0SAndreas Gruenbacher 204026fec7eSChristoph Hellwig static int nfsaclsvc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p) 205a257cdd0SAndreas Gruenbacher { 206026fec7eSChristoph Hellwig struct nfsd3_setaclargs *argp = rqstp->rq_argp; 207a257cdd0SAndreas Gruenbacher struct kvec *head = rqstp->rq_arg.head; 208a257cdd0SAndreas Gruenbacher unsigned int base; 209a257cdd0SAndreas Gruenbacher int n; 210a257cdd0SAndreas Gruenbacher 211d40aa337SBenoit Taine p = nfs2svc_decode_fh(p, &argp->fh); 212d40aa337SBenoit Taine if (!p) 213a257cdd0SAndreas Gruenbacher return 0; 214a257cdd0SAndreas Gruenbacher argp->mask = ntohl(*p++); 2157b8f4586SKinglong Mee if (argp->mask & ~NFS_ACL_MASK || 216a257cdd0SAndreas Gruenbacher !xdr_argsize_check(rqstp, p)) 217a257cdd0SAndreas Gruenbacher return 0; 218a257cdd0SAndreas Gruenbacher 219a257cdd0SAndreas Gruenbacher base = (char *)p - (char *)head->iov_base; 220a257cdd0SAndreas Gruenbacher n = nfsacl_decode(&rqstp->rq_arg, base, NULL, 221a257cdd0SAndreas Gruenbacher (argp->mask & NFS_ACL) ? 222a257cdd0SAndreas Gruenbacher &argp->acl_access : NULL); 223a257cdd0SAndreas Gruenbacher if (n > 0) 224a257cdd0SAndreas Gruenbacher n = nfsacl_decode(&rqstp->rq_arg, base + n, NULL, 225a257cdd0SAndreas Gruenbacher (argp->mask & NFS_DFACL) ? 226a257cdd0SAndreas Gruenbacher &argp->acl_default : NULL); 227a257cdd0SAndreas Gruenbacher return (n > 0); 228a257cdd0SAndreas Gruenbacher } 229a257cdd0SAndreas Gruenbacher 230026fec7eSChristoph Hellwig static int nfsaclsvc_decode_fhandleargs(struct svc_rqst *rqstp, __be32 *p) 231a257cdd0SAndreas Gruenbacher { 232026fec7eSChristoph Hellwig struct nfsd_fhandle *argp = rqstp->rq_argp; 233026fec7eSChristoph Hellwig 234d40aa337SBenoit Taine p = nfs2svc_decode_fh(p, &argp->fh); 235d40aa337SBenoit Taine if (!p) 236a257cdd0SAndreas Gruenbacher return 0; 237a257cdd0SAndreas Gruenbacher return xdr_argsize_check(rqstp, p); 238a257cdd0SAndreas Gruenbacher } 239a257cdd0SAndreas Gruenbacher 240026fec7eSChristoph Hellwig static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p) 241a257cdd0SAndreas Gruenbacher { 242026fec7eSChristoph Hellwig struct nfsd3_accessargs *argp = rqstp->rq_argp; 243026fec7eSChristoph Hellwig 244d40aa337SBenoit Taine p = nfs2svc_decode_fh(p, &argp->fh); 245d40aa337SBenoit Taine if (!p) 246a257cdd0SAndreas Gruenbacher return 0; 247a257cdd0SAndreas Gruenbacher argp->access = ntohl(*p++); 248a257cdd0SAndreas Gruenbacher 249a257cdd0SAndreas Gruenbacher return xdr_argsize_check(rqstp, p); 250a257cdd0SAndreas Gruenbacher } 251a257cdd0SAndreas Gruenbacher 252a257cdd0SAndreas Gruenbacher /* 253a257cdd0SAndreas Gruenbacher * XDR encode functions 254a257cdd0SAndreas Gruenbacher */ 255a257cdd0SAndreas Gruenbacher 2561b7e0403SPeter Staubach /* 2571b7e0403SPeter Staubach * There must be an encoding function for void results so svc_process 2581b7e0403SPeter Staubach * will work properly. 2591b7e0403SPeter Staubach */ 26063f8de37SChristoph Hellwig static int nfsaclsvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p) 2611b7e0403SPeter Staubach { 2621b7e0403SPeter Staubach return xdr_ressize_check(rqstp, p); 2631b7e0403SPeter Staubach } 2641b7e0403SPeter Staubach 265a257cdd0SAndreas Gruenbacher /* GETACL */ 26663f8de37SChristoph Hellwig static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p) 267a257cdd0SAndreas Gruenbacher { 26863f8de37SChristoph Hellwig struct nfsd3_getaclres *resp = rqstp->rq_resp; 269a257cdd0SAndreas Gruenbacher struct dentry *dentry = resp->fh.fh_dentry; 270aefa89d1SPrasad P struct inode *inode; 271a257cdd0SAndreas Gruenbacher struct kvec *head = rqstp->rq_res.head; 272a257cdd0SAndreas Gruenbacher unsigned int base; 273a257cdd0SAndreas Gruenbacher int n; 274cb65a5baSJesper Juhl int w; 275a257cdd0SAndreas Gruenbacher 276aefa89d1SPrasad P /* 277aefa89d1SPrasad P * Since this is version 2, the check for nfserr in 278aefa89d1SPrasad P * nfsd_dispatch actually ensures the following cannot happen. 279aefa89d1SPrasad P * However, it seems fragile to depend on that. 280aefa89d1SPrasad P */ 2812b0143b5SDavid Howells if (dentry == NULL || d_really_is_negative(dentry)) 282a257cdd0SAndreas Gruenbacher return 0; 2832b0143b5SDavid Howells inode = d_inode(dentry); 284a257cdd0SAndreas Gruenbacher 2854f4a4fadSJ. Bruce Fields p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat); 286a257cdd0SAndreas Gruenbacher *p++ = htonl(resp->mask); 287a257cdd0SAndreas Gruenbacher if (!xdr_ressize_check(rqstp, p)) 288a257cdd0SAndreas Gruenbacher return 0; 289a257cdd0SAndreas Gruenbacher base = (char *)p - (char *)head->iov_base; 290a257cdd0SAndreas Gruenbacher 291cb65a5baSJesper Juhl rqstp->rq_res.page_len = w = nfsacl_size( 292cb65a5baSJesper Juhl (resp->mask & NFS_ACL) ? resp->acl_access : NULL, 293cb65a5baSJesper Juhl (resp->mask & NFS_DFACL) ? resp->acl_default : NULL); 294a257cdd0SAndreas Gruenbacher while (w > 0) { 295afc59400SJ. Bruce Fields if (!*(rqstp->rq_next_page++)) 296a257cdd0SAndreas Gruenbacher return 0; 297a257cdd0SAndreas Gruenbacher w -= PAGE_SIZE; 298a257cdd0SAndreas Gruenbacher } 299a257cdd0SAndreas Gruenbacher 300a257cdd0SAndreas Gruenbacher n = nfsacl_encode(&rqstp->rq_res, base, inode, 301a257cdd0SAndreas Gruenbacher resp->acl_access, 302a257cdd0SAndreas Gruenbacher resp->mask & NFS_ACL, 0); 303a257cdd0SAndreas Gruenbacher if (n > 0) 304a257cdd0SAndreas Gruenbacher n = nfsacl_encode(&rqstp->rq_res, base + n, inode, 305a257cdd0SAndreas Gruenbacher resp->acl_default, 306a257cdd0SAndreas Gruenbacher resp->mask & NFS_DFACL, 307a257cdd0SAndreas Gruenbacher NFS_ACL_DEFAULT); 3087b8f4586SKinglong Mee return (n > 0); 309a257cdd0SAndreas Gruenbacher } 310a257cdd0SAndreas Gruenbacher 31163f8de37SChristoph Hellwig static int nfsaclsvc_encode_attrstatres(struct svc_rqst *rqstp, __be32 *p) 312a257cdd0SAndreas Gruenbacher { 31363f8de37SChristoph Hellwig struct nfsd_attrstat *resp = rqstp->rq_resp; 31463f8de37SChristoph Hellwig 3154f4a4fadSJ. Bruce Fields p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat); 316a257cdd0SAndreas Gruenbacher return xdr_ressize_check(rqstp, p); 317a257cdd0SAndreas Gruenbacher } 318a257cdd0SAndreas Gruenbacher 319a257cdd0SAndreas Gruenbacher /* ACCESS */ 32063f8de37SChristoph Hellwig static int nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, __be32 *p) 321a257cdd0SAndreas Gruenbacher { 32263f8de37SChristoph Hellwig struct nfsd3_accessres *resp = rqstp->rq_resp; 32363f8de37SChristoph Hellwig 3244f4a4fadSJ. Bruce Fields p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat); 325a257cdd0SAndreas Gruenbacher *p++ = htonl(resp->access); 326a257cdd0SAndreas Gruenbacher return xdr_ressize_check(rqstp, p); 327a257cdd0SAndreas Gruenbacher } 328a257cdd0SAndreas Gruenbacher 329a257cdd0SAndreas Gruenbacher /* 330a257cdd0SAndreas Gruenbacher * XDR release functions 331a257cdd0SAndreas Gruenbacher */ 3328537488bSChristoph Hellwig static void nfsaclsvc_release_getacl(struct svc_rqst *rqstp) 333a257cdd0SAndreas Gruenbacher { 3348537488bSChristoph Hellwig struct nfsd3_getaclres *resp = rqstp->rq_resp; 3358537488bSChristoph Hellwig 336a257cdd0SAndreas Gruenbacher fh_put(&resp->fh); 337a257cdd0SAndreas Gruenbacher posix_acl_release(resp->acl_access); 338a257cdd0SAndreas Gruenbacher posix_acl_release(resp->acl_default); 339a257cdd0SAndreas Gruenbacher } 340a257cdd0SAndreas Gruenbacher 3418537488bSChristoph Hellwig static void nfsaclsvc_release_attrstat(struct svc_rqst *rqstp) 342c9ce2283SGreg Banks { 3438537488bSChristoph Hellwig struct nfsd_attrstat *resp = rqstp->rq_resp; 3448537488bSChristoph Hellwig 345c9ce2283SGreg Banks fh_put(&resp->fh); 346c9ce2283SGreg Banks } 347c9ce2283SGreg Banks 3488537488bSChristoph Hellwig static void nfsaclsvc_release_access(struct svc_rqst *rqstp) 349a257cdd0SAndreas Gruenbacher { 3508537488bSChristoph Hellwig struct nfsd3_accessres *resp = rqstp->rq_resp; 3518537488bSChristoph Hellwig 352a257cdd0SAndreas Gruenbacher fh_put(&resp->fh); 353a257cdd0SAndreas Gruenbacher } 354a257cdd0SAndreas Gruenbacher 355a257cdd0SAndreas Gruenbacher struct nfsd3_voidargs { int dummy; }; 356a257cdd0SAndreas Gruenbacher 357a257cdd0SAndreas Gruenbacher #define ST 1 /* status*/ 358a257cdd0SAndreas Gruenbacher #define AT 21 /* attributes */ 359a257cdd0SAndreas Gruenbacher #define pAT (1+AT) /* post attributes - conditional */ 360a257cdd0SAndreas Gruenbacher #define ACL (1+NFS_ACL_MAX_ENTRIES*3) /* Access Control List */ 361a257cdd0SAndreas Gruenbacher 362ba1df797SChuck Lever static const struct svc_procedure nfsd_acl_procedures2[5] = { 363ba1df797SChuck Lever [ACLPROC2_NULL] = { 364ba1df797SChuck Lever .pc_func = nfsacld_proc_null, 365*dcc46991SChuck Lever .pc_decode = nfsaclsvc_decode_voidarg, 366ba1df797SChuck Lever .pc_encode = nfsaclsvc_encode_voidres, 367ba1df797SChuck Lever .pc_argsize = sizeof(struct nfsd3_voidargs), 368ba1df797SChuck Lever .pc_ressize = sizeof(struct nfsd3_voidargs), 369ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 370ba1df797SChuck Lever .pc_xdrressize = ST, 371ba1df797SChuck Lever }, 372ba1df797SChuck Lever [ACLPROC2_GETACL] = { 373ba1df797SChuck Lever .pc_func = nfsacld_proc_getacl, 374ba1df797SChuck Lever .pc_decode = nfsaclsvc_decode_getaclargs, 375ba1df797SChuck Lever .pc_encode = nfsaclsvc_encode_getaclres, 376ba1df797SChuck Lever .pc_release = nfsaclsvc_release_getacl, 377ba1df797SChuck Lever .pc_argsize = sizeof(struct nfsd3_getaclargs), 378ba1df797SChuck Lever .pc_ressize = sizeof(struct nfsd3_getaclres), 379ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 380ba1df797SChuck Lever .pc_xdrressize = ST+1+2*(1+ACL), 381ba1df797SChuck Lever }, 382ba1df797SChuck Lever [ACLPROC2_SETACL] = { 383ba1df797SChuck Lever .pc_func = nfsacld_proc_setacl, 384ba1df797SChuck Lever .pc_decode = nfsaclsvc_decode_setaclargs, 385ba1df797SChuck Lever .pc_encode = nfsaclsvc_encode_attrstatres, 386ba1df797SChuck Lever .pc_release = nfsaclsvc_release_attrstat, 387ba1df797SChuck Lever .pc_argsize = sizeof(struct nfsd3_setaclargs), 388ba1df797SChuck Lever .pc_ressize = sizeof(struct nfsd_attrstat), 389ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 390ba1df797SChuck Lever .pc_xdrressize = ST+AT, 391ba1df797SChuck Lever }, 392ba1df797SChuck Lever [ACLPROC2_GETATTR] = { 393ba1df797SChuck Lever .pc_func = nfsacld_proc_getattr, 394ba1df797SChuck Lever .pc_decode = nfsaclsvc_decode_fhandleargs, 395ba1df797SChuck Lever .pc_encode = nfsaclsvc_encode_attrstatres, 396ba1df797SChuck Lever .pc_release = nfsaclsvc_release_attrstat, 397ba1df797SChuck Lever .pc_argsize = sizeof(struct nfsd_fhandle), 398ba1df797SChuck Lever .pc_ressize = sizeof(struct nfsd_attrstat), 399ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 400ba1df797SChuck Lever .pc_xdrressize = ST+AT, 401ba1df797SChuck Lever }, 402ba1df797SChuck Lever [ACLPROC2_ACCESS] = { 403ba1df797SChuck Lever .pc_func = nfsacld_proc_access, 404ba1df797SChuck Lever .pc_decode = nfsaclsvc_decode_accessargs, 405ba1df797SChuck Lever .pc_encode = nfsaclsvc_encode_accessres, 406ba1df797SChuck Lever .pc_release = nfsaclsvc_release_access, 407ba1df797SChuck Lever .pc_argsize = sizeof(struct nfsd3_accessargs), 408ba1df797SChuck Lever .pc_ressize = sizeof(struct nfsd3_accessres), 409ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 410ba1df797SChuck Lever .pc_xdrressize = ST+AT+1, 411ba1df797SChuck Lever }, 412a257cdd0SAndreas Gruenbacher }; 413a257cdd0SAndreas Gruenbacher 4147fd38af9SChristoph Hellwig static unsigned int nfsd_acl_count2[ARRAY_SIZE(nfsd_acl_procedures2)]; 415e9679189SChristoph Hellwig const struct svc_version nfsd_acl_version2 = { 416a257cdd0SAndreas Gruenbacher .vs_vers = 2, 417a257cdd0SAndreas Gruenbacher .vs_nproc = 5, 418a257cdd0SAndreas Gruenbacher .vs_proc = nfsd_acl_procedures2, 4197fd38af9SChristoph Hellwig .vs_count = nfsd_acl_count2, 420a257cdd0SAndreas Gruenbacher .vs_dispatch = nfsd_dispatch, 421a257cdd0SAndreas Gruenbacher .vs_xdrsize = NFS3_SVC_XDRSIZE, 422a257cdd0SAndreas Gruenbacher }; 423