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 18a257cdd0SAndreas Gruenbacher /* 19a257cdd0SAndreas Gruenbacher * NULL call. 20a257cdd0SAndreas Gruenbacher */ 217111c66eSAl Viro static __be32 22a6beb732SChristoph Hellwig nfsacld_proc_null(struct svc_rqst *rqstp) 23a257cdd0SAndreas Gruenbacher { 24a257cdd0SAndreas Gruenbacher return nfs_ok; 25a257cdd0SAndreas Gruenbacher } 26a257cdd0SAndreas Gruenbacher 27a257cdd0SAndreas Gruenbacher /* 28a257cdd0SAndreas Gruenbacher * Get the Access and/or Default ACL of a file. 29a257cdd0SAndreas Gruenbacher */ 30a6beb732SChristoph Hellwig static __be32 nfsacld_proc_getacl(struct svc_rqst *rqstp) 31a257cdd0SAndreas Gruenbacher { 32a6beb732SChristoph Hellwig struct nfsd3_getaclargs *argp = rqstp->rq_argp; 33a6beb732SChristoph Hellwig struct nfsd3_getaclres *resp = rqstp->rq_resp; 34a257cdd0SAndreas Gruenbacher struct posix_acl *acl; 354ac7249eSChristoph Hellwig struct inode *inode; 364ac7249eSChristoph Hellwig svc_fh *fh; 37a257cdd0SAndreas Gruenbacher 38a257cdd0SAndreas Gruenbacher dprintk("nfsd: GETACL(2acl) %s\n", SVCFH_fmt(&argp->fh)); 39a257cdd0SAndreas Gruenbacher 40a257cdd0SAndreas Gruenbacher fh = fh_copy(&resp->fh, &argp->fh); 41*f0af2210SChuck Lever resp->status = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); 42*f0af2210SChuck Lever if (resp->status != nfs_ok) 43*f0af2210SChuck Lever goto out; 44a257cdd0SAndreas Gruenbacher 452b0143b5SDavid Howells inode = d_inode(fh->fh_dentry); 464ac7249eSChristoph Hellwig 47*f0af2210SChuck Lever if (argp->mask & ~NFS_ACL_MASK) { 48*f0af2210SChuck Lever resp->status = nfserr_inval; 49*f0af2210SChuck Lever goto out; 50*f0af2210SChuck Lever } 51a257cdd0SAndreas Gruenbacher resp->mask = argp->mask; 52a257cdd0SAndreas Gruenbacher 53*f0af2210SChuck Lever resp->status = fh_getattr(fh, &resp->stat); 54*f0af2210SChuck Lever if (resp->status != nfs_ok) 55*f0af2210SChuck Lever goto out; 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)) { 64*f0af2210SChuck Lever resp->status = 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)) { 74*f0af2210SChuck Lever resp->status = 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. */ 81*f0af2210SChuck Lever out: 82*f0af2210SChuck Lever return resp->status; 83a257cdd0SAndreas Gruenbacher 84a257cdd0SAndreas Gruenbacher fail: 85a257cdd0SAndreas Gruenbacher posix_acl_release(resp->acl_access); 86a257cdd0SAndreas Gruenbacher posix_acl_release(resp->acl_default); 87*f0af2210SChuck Lever goto out; 88a257cdd0SAndreas Gruenbacher } 89a257cdd0SAndreas Gruenbacher 90a257cdd0SAndreas Gruenbacher /* 91a257cdd0SAndreas Gruenbacher * Set the Access and/or Default ACL of a file. 92a257cdd0SAndreas Gruenbacher */ 93a6beb732SChristoph Hellwig static __be32 nfsacld_proc_setacl(struct svc_rqst *rqstp) 94a257cdd0SAndreas Gruenbacher { 95a6beb732SChristoph Hellwig struct nfsd3_setaclargs *argp = rqstp->rq_argp; 96a6beb732SChristoph Hellwig struct nfsd_attrstat *resp = rqstp->rq_resp; 974ac7249eSChristoph Hellwig struct inode *inode; 98a257cdd0SAndreas Gruenbacher svc_fh *fh; 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); 104*f0af2210SChuck Lever resp->status = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR); 105*f0af2210SChuck Lever if (resp->status != nfs_ok) 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 127*f0af2210SChuck Lever resp->status = 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); 134*f0af2210SChuck Lever return resp->status; 135*f0af2210SChuck Lever 13699965378SBen Hutchings out_drop_lock: 13799965378SBen Hutchings fh_unlock(fh); 1384ac7249eSChristoph Hellwig fh_drop_write(fh); 1394ac7249eSChristoph Hellwig out_errno: 140*f0af2210SChuck Lever resp->status = nfserrno(error); 1414ac7249eSChristoph Hellwig goto out; 142a257cdd0SAndreas Gruenbacher } 143a257cdd0SAndreas Gruenbacher 144a257cdd0SAndreas Gruenbacher /* 145a257cdd0SAndreas Gruenbacher * Check file attributes 146a257cdd0SAndreas Gruenbacher */ 147a6beb732SChristoph Hellwig static __be32 nfsacld_proc_getattr(struct svc_rqst *rqstp) 148a257cdd0SAndreas Gruenbacher { 149a6beb732SChristoph Hellwig struct nfsd_fhandle *argp = rqstp->rq_argp; 150a6beb732SChristoph Hellwig struct nfsd_attrstat *resp = rqstp->rq_resp; 151*f0af2210SChuck Lever 152a257cdd0SAndreas Gruenbacher dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh)); 153a257cdd0SAndreas Gruenbacher 154a257cdd0SAndreas Gruenbacher fh_copy(&resp->fh, &argp->fh); 155*f0af2210SChuck Lever resp->status = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); 156*f0af2210SChuck Lever if (resp->status != nfs_ok) 157*f0af2210SChuck Lever goto out; 158*f0af2210SChuck Lever resp->status = fh_getattr(&resp->fh, &resp->stat); 159*f0af2210SChuck Lever out: 160*f0af2210SChuck Lever return resp->status; 161a257cdd0SAndreas Gruenbacher } 162a257cdd0SAndreas Gruenbacher 163a257cdd0SAndreas Gruenbacher /* 164a257cdd0SAndreas Gruenbacher * Check file access 165a257cdd0SAndreas Gruenbacher */ 166a6beb732SChristoph Hellwig static __be32 nfsacld_proc_access(struct svc_rqst *rqstp) 167a257cdd0SAndreas Gruenbacher { 168a6beb732SChristoph Hellwig struct nfsd3_accessargs *argp = rqstp->rq_argp; 169a6beb732SChristoph Hellwig struct nfsd3_accessres *resp = rqstp->rq_resp; 170a257cdd0SAndreas Gruenbacher 171a257cdd0SAndreas Gruenbacher dprintk("nfsd: ACCESS(2acl) %s 0x%x\n", 172a257cdd0SAndreas Gruenbacher SVCFH_fmt(&argp->fh), 173a257cdd0SAndreas Gruenbacher argp->access); 174a257cdd0SAndreas Gruenbacher 175a257cdd0SAndreas Gruenbacher fh_copy(&resp->fh, &argp->fh); 176a257cdd0SAndreas Gruenbacher resp->access = argp->access; 177*f0af2210SChuck Lever resp->status = nfsd_access(rqstp, &resp->fh, &resp->access, NULL); 178*f0af2210SChuck Lever if (resp->status != nfs_ok) 179*f0af2210SChuck Lever goto out; 180*f0af2210SChuck Lever resp->status = fh_getattr(&resp->fh, &resp->stat); 181*f0af2210SChuck Lever out: 182*f0af2210SChuck Lever return resp->status; 183a257cdd0SAndreas Gruenbacher } 184a257cdd0SAndreas Gruenbacher 185a257cdd0SAndreas Gruenbacher /* 186a257cdd0SAndreas Gruenbacher * XDR decode functions 187a257cdd0SAndreas Gruenbacher */ 188dcc46991SChuck Lever static int nfsaclsvc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p) 189dcc46991SChuck Lever { 190dcc46991SChuck Lever return 1; 191dcc46991SChuck Lever } 192dcc46991SChuck Lever 193026fec7eSChristoph Hellwig static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p) 194a257cdd0SAndreas Gruenbacher { 195026fec7eSChristoph Hellwig struct nfsd3_getaclargs *argp = rqstp->rq_argp; 196026fec7eSChristoph Hellwig 197d40aa337SBenoit Taine p = nfs2svc_decode_fh(p, &argp->fh); 198d40aa337SBenoit Taine if (!p) 199a257cdd0SAndreas Gruenbacher return 0; 200a257cdd0SAndreas Gruenbacher argp->mask = ntohl(*p); p++; 201a257cdd0SAndreas Gruenbacher 202a257cdd0SAndreas Gruenbacher return xdr_argsize_check(rqstp, p); 203a257cdd0SAndreas Gruenbacher } 204a257cdd0SAndreas Gruenbacher 205a257cdd0SAndreas Gruenbacher 206026fec7eSChristoph Hellwig static int nfsaclsvc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p) 207a257cdd0SAndreas Gruenbacher { 208026fec7eSChristoph Hellwig struct nfsd3_setaclargs *argp = rqstp->rq_argp; 209a257cdd0SAndreas Gruenbacher struct kvec *head = rqstp->rq_arg.head; 210a257cdd0SAndreas Gruenbacher unsigned int base; 211a257cdd0SAndreas Gruenbacher int n; 212a257cdd0SAndreas Gruenbacher 213d40aa337SBenoit Taine p = nfs2svc_decode_fh(p, &argp->fh); 214d40aa337SBenoit Taine if (!p) 215a257cdd0SAndreas Gruenbacher return 0; 216a257cdd0SAndreas Gruenbacher argp->mask = ntohl(*p++); 2177b8f4586SKinglong Mee if (argp->mask & ~NFS_ACL_MASK || 218a257cdd0SAndreas Gruenbacher !xdr_argsize_check(rqstp, p)) 219a257cdd0SAndreas Gruenbacher return 0; 220a257cdd0SAndreas Gruenbacher 221a257cdd0SAndreas Gruenbacher base = (char *)p - (char *)head->iov_base; 222a257cdd0SAndreas Gruenbacher n = nfsacl_decode(&rqstp->rq_arg, base, NULL, 223a257cdd0SAndreas Gruenbacher (argp->mask & NFS_ACL) ? 224a257cdd0SAndreas Gruenbacher &argp->acl_access : NULL); 225a257cdd0SAndreas Gruenbacher if (n > 0) 226a257cdd0SAndreas Gruenbacher n = nfsacl_decode(&rqstp->rq_arg, base + n, NULL, 227a257cdd0SAndreas Gruenbacher (argp->mask & NFS_DFACL) ? 228a257cdd0SAndreas Gruenbacher &argp->acl_default : NULL); 229a257cdd0SAndreas Gruenbacher return (n > 0); 230a257cdd0SAndreas Gruenbacher } 231a257cdd0SAndreas Gruenbacher 232026fec7eSChristoph Hellwig static int nfsaclsvc_decode_fhandleargs(struct svc_rqst *rqstp, __be32 *p) 233a257cdd0SAndreas Gruenbacher { 234026fec7eSChristoph Hellwig struct nfsd_fhandle *argp = rqstp->rq_argp; 235026fec7eSChristoph Hellwig 236d40aa337SBenoit Taine p = nfs2svc_decode_fh(p, &argp->fh); 237d40aa337SBenoit Taine if (!p) 238a257cdd0SAndreas Gruenbacher return 0; 239a257cdd0SAndreas Gruenbacher return xdr_argsize_check(rqstp, p); 240a257cdd0SAndreas Gruenbacher } 241a257cdd0SAndreas Gruenbacher 242026fec7eSChristoph Hellwig static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p) 243a257cdd0SAndreas Gruenbacher { 244026fec7eSChristoph Hellwig struct nfsd3_accessargs *argp = rqstp->rq_argp; 245026fec7eSChristoph Hellwig 246d40aa337SBenoit Taine p = nfs2svc_decode_fh(p, &argp->fh); 247d40aa337SBenoit Taine if (!p) 248a257cdd0SAndreas Gruenbacher return 0; 249a257cdd0SAndreas Gruenbacher argp->access = ntohl(*p++); 250a257cdd0SAndreas Gruenbacher 251a257cdd0SAndreas Gruenbacher return xdr_argsize_check(rqstp, p); 252a257cdd0SAndreas Gruenbacher } 253a257cdd0SAndreas Gruenbacher 254a257cdd0SAndreas Gruenbacher /* 255a257cdd0SAndreas Gruenbacher * XDR encode functions 256a257cdd0SAndreas Gruenbacher */ 257a257cdd0SAndreas Gruenbacher 2581b7e0403SPeter Staubach /* 2591b7e0403SPeter Staubach * There must be an encoding function for void results so svc_process 2601b7e0403SPeter Staubach * will work properly. 2611b7e0403SPeter Staubach */ 26263f8de37SChristoph Hellwig static int nfsaclsvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p) 2631b7e0403SPeter Staubach { 2641b7e0403SPeter Staubach return xdr_ressize_check(rqstp, p); 2651b7e0403SPeter Staubach } 2661b7e0403SPeter Staubach 267a257cdd0SAndreas Gruenbacher /* GETACL */ 26863f8de37SChristoph Hellwig static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p) 269a257cdd0SAndreas Gruenbacher { 27063f8de37SChristoph Hellwig struct nfsd3_getaclres *resp = rqstp->rq_resp; 271a257cdd0SAndreas Gruenbacher struct dentry *dentry = resp->fh.fh_dentry; 272aefa89d1SPrasad P struct inode *inode; 273a257cdd0SAndreas Gruenbacher struct kvec *head = rqstp->rq_res.head; 274a257cdd0SAndreas Gruenbacher unsigned int base; 275a257cdd0SAndreas Gruenbacher int n; 276cb65a5baSJesper Juhl int w; 277a257cdd0SAndreas Gruenbacher 278*f0af2210SChuck Lever if (resp->status != nfs_ok) 279*f0af2210SChuck Lever return xdr_ressize_check(rqstp, p); 280*f0af2210SChuck Lever 281aefa89d1SPrasad P /* 282aefa89d1SPrasad P * Since this is version 2, the check for nfserr in 283aefa89d1SPrasad P * nfsd_dispatch actually ensures the following cannot happen. 284aefa89d1SPrasad P * However, it seems fragile to depend on that. 285aefa89d1SPrasad P */ 2862b0143b5SDavid Howells if (dentry == NULL || d_really_is_negative(dentry)) 287a257cdd0SAndreas Gruenbacher return 0; 2882b0143b5SDavid Howells inode = d_inode(dentry); 289a257cdd0SAndreas Gruenbacher 2904f4a4fadSJ. Bruce Fields p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat); 291a257cdd0SAndreas Gruenbacher *p++ = htonl(resp->mask); 292a257cdd0SAndreas Gruenbacher if (!xdr_ressize_check(rqstp, p)) 293a257cdd0SAndreas Gruenbacher return 0; 294a257cdd0SAndreas Gruenbacher base = (char *)p - (char *)head->iov_base; 295a257cdd0SAndreas Gruenbacher 296cb65a5baSJesper Juhl rqstp->rq_res.page_len = w = nfsacl_size( 297cb65a5baSJesper Juhl (resp->mask & NFS_ACL) ? resp->acl_access : NULL, 298cb65a5baSJesper Juhl (resp->mask & NFS_DFACL) ? resp->acl_default : NULL); 299a257cdd0SAndreas Gruenbacher while (w > 0) { 300afc59400SJ. Bruce Fields if (!*(rqstp->rq_next_page++)) 301a257cdd0SAndreas Gruenbacher return 0; 302a257cdd0SAndreas Gruenbacher w -= PAGE_SIZE; 303a257cdd0SAndreas Gruenbacher } 304a257cdd0SAndreas Gruenbacher 305a257cdd0SAndreas Gruenbacher n = nfsacl_encode(&rqstp->rq_res, base, inode, 306a257cdd0SAndreas Gruenbacher resp->acl_access, 307a257cdd0SAndreas Gruenbacher resp->mask & NFS_ACL, 0); 308a257cdd0SAndreas Gruenbacher if (n > 0) 309a257cdd0SAndreas Gruenbacher n = nfsacl_encode(&rqstp->rq_res, base + n, inode, 310a257cdd0SAndreas Gruenbacher resp->acl_default, 311a257cdd0SAndreas Gruenbacher resp->mask & NFS_DFACL, 312a257cdd0SAndreas Gruenbacher NFS_ACL_DEFAULT); 3137b8f4586SKinglong Mee return (n > 0); 314a257cdd0SAndreas Gruenbacher } 315a257cdd0SAndreas Gruenbacher 31663f8de37SChristoph Hellwig static int nfsaclsvc_encode_attrstatres(struct svc_rqst *rqstp, __be32 *p) 317a257cdd0SAndreas Gruenbacher { 31863f8de37SChristoph Hellwig struct nfsd_attrstat *resp = rqstp->rq_resp; 31963f8de37SChristoph Hellwig 320*f0af2210SChuck Lever if (resp->status != nfs_ok) 321*f0af2210SChuck Lever return xdr_ressize_check(rqstp, p); 322*f0af2210SChuck Lever 3234f4a4fadSJ. Bruce Fields p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat); 324a257cdd0SAndreas Gruenbacher return xdr_ressize_check(rqstp, p); 325a257cdd0SAndreas Gruenbacher } 326a257cdd0SAndreas Gruenbacher 327a257cdd0SAndreas Gruenbacher /* ACCESS */ 32863f8de37SChristoph Hellwig static int nfsaclsvc_encode_accessres(struct svc_rqst *rqstp, __be32 *p) 329a257cdd0SAndreas Gruenbacher { 33063f8de37SChristoph Hellwig struct nfsd3_accessres *resp = rqstp->rq_resp; 33163f8de37SChristoph Hellwig 332*f0af2210SChuck Lever if (resp->status != nfs_ok) 333*f0af2210SChuck Lever return xdr_ressize_check(rqstp, p); 334*f0af2210SChuck Lever 3354f4a4fadSJ. Bruce Fields p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat); 336a257cdd0SAndreas Gruenbacher *p++ = htonl(resp->access); 337a257cdd0SAndreas Gruenbacher return xdr_ressize_check(rqstp, p); 338a257cdd0SAndreas Gruenbacher } 339a257cdd0SAndreas Gruenbacher 340a257cdd0SAndreas Gruenbacher /* 341a257cdd0SAndreas Gruenbacher * XDR release functions 342a257cdd0SAndreas Gruenbacher */ 3438537488bSChristoph Hellwig static void nfsaclsvc_release_getacl(struct svc_rqst *rqstp) 344a257cdd0SAndreas Gruenbacher { 3458537488bSChristoph Hellwig struct nfsd3_getaclres *resp = rqstp->rq_resp; 3468537488bSChristoph Hellwig 347a257cdd0SAndreas Gruenbacher fh_put(&resp->fh); 348a257cdd0SAndreas Gruenbacher posix_acl_release(resp->acl_access); 349a257cdd0SAndreas Gruenbacher posix_acl_release(resp->acl_default); 350a257cdd0SAndreas Gruenbacher } 351a257cdd0SAndreas Gruenbacher 3528537488bSChristoph Hellwig static void nfsaclsvc_release_attrstat(struct svc_rqst *rqstp) 353c9ce2283SGreg Banks { 3548537488bSChristoph Hellwig struct nfsd_attrstat *resp = rqstp->rq_resp; 3558537488bSChristoph Hellwig 356c9ce2283SGreg Banks fh_put(&resp->fh); 357c9ce2283SGreg Banks } 358c9ce2283SGreg Banks 3598537488bSChristoph Hellwig static void nfsaclsvc_release_access(struct svc_rqst *rqstp) 360a257cdd0SAndreas Gruenbacher { 3618537488bSChristoph Hellwig struct nfsd3_accessres *resp = rqstp->rq_resp; 3628537488bSChristoph Hellwig 363a257cdd0SAndreas Gruenbacher fh_put(&resp->fh); 364a257cdd0SAndreas Gruenbacher } 365a257cdd0SAndreas Gruenbacher 366a257cdd0SAndreas Gruenbacher struct nfsd3_voidargs { int dummy; }; 367a257cdd0SAndreas Gruenbacher 368a257cdd0SAndreas Gruenbacher #define ST 1 /* status*/ 369a257cdd0SAndreas Gruenbacher #define AT 21 /* attributes */ 370a257cdd0SAndreas Gruenbacher #define pAT (1+AT) /* post attributes - conditional */ 371a257cdd0SAndreas Gruenbacher #define ACL (1+NFS_ACL_MAX_ENTRIES*3) /* Access Control List */ 372a257cdd0SAndreas Gruenbacher 373ba1df797SChuck Lever static const struct svc_procedure nfsd_acl_procedures2[5] = { 374ba1df797SChuck Lever [ACLPROC2_NULL] = { 375ba1df797SChuck Lever .pc_func = nfsacld_proc_null, 376dcc46991SChuck Lever .pc_decode = nfsaclsvc_decode_voidarg, 377ba1df797SChuck Lever .pc_encode = nfsaclsvc_encode_voidres, 378ba1df797SChuck Lever .pc_argsize = sizeof(struct nfsd3_voidargs), 379ba1df797SChuck Lever .pc_ressize = sizeof(struct nfsd3_voidargs), 380ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 381ba1df797SChuck Lever .pc_xdrressize = ST, 382ba1df797SChuck Lever }, 383ba1df797SChuck Lever [ACLPROC2_GETACL] = { 384ba1df797SChuck Lever .pc_func = nfsacld_proc_getacl, 385ba1df797SChuck Lever .pc_decode = nfsaclsvc_decode_getaclargs, 386ba1df797SChuck Lever .pc_encode = nfsaclsvc_encode_getaclres, 387ba1df797SChuck Lever .pc_release = nfsaclsvc_release_getacl, 388ba1df797SChuck Lever .pc_argsize = sizeof(struct nfsd3_getaclargs), 389ba1df797SChuck Lever .pc_ressize = sizeof(struct nfsd3_getaclres), 390ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 391ba1df797SChuck Lever .pc_xdrressize = ST+1+2*(1+ACL), 392ba1df797SChuck Lever }, 393ba1df797SChuck Lever [ACLPROC2_SETACL] = { 394ba1df797SChuck Lever .pc_func = nfsacld_proc_setacl, 395ba1df797SChuck Lever .pc_decode = nfsaclsvc_decode_setaclargs, 396ba1df797SChuck Lever .pc_encode = nfsaclsvc_encode_attrstatres, 397ba1df797SChuck Lever .pc_release = nfsaclsvc_release_attrstat, 398ba1df797SChuck Lever .pc_argsize = sizeof(struct nfsd3_setaclargs), 399ba1df797SChuck Lever .pc_ressize = sizeof(struct nfsd_attrstat), 400ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 401ba1df797SChuck Lever .pc_xdrressize = ST+AT, 402ba1df797SChuck Lever }, 403ba1df797SChuck Lever [ACLPROC2_GETATTR] = { 404ba1df797SChuck Lever .pc_func = nfsacld_proc_getattr, 405ba1df797SChuck Lever .pc_decode = nfsaclsvc_decode_fhandleargs, 406ba1df797SChuck Lever .pc_encode = nfsaclsvc_encode_attrstatres, 407ba1df797SChuck Lever .pc_release = nfsaclsvc_release_attrstat, 408ba1df797SChuck Lever .pc_argsize = sizeof(struct nfsd_fhandle), 409ba1df797SChuck Lever .pc_ressize = sizeof(struct nfsd_attrstat), 410ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 411ba1df797SChuck Lever .pc_xdrressize = ST+AT, 412ba1df797SChuck Lever }, 413ba1df797SChuck Lever [ACLPROC2_ACCESS] = { 414ba1df797SChuck Lever .pc_func = nfsacld_proc_access, 415ba1df797SChuck Lever .pc_decode = nfsaclsvc_decode_accessargs, 416ba1df797SChuck Lever .pc_encode = nfsaclsvc_encode_accessres, 417ba1df797SChuck Lever .pc_release = nfsaclsvc_release_access, 418ba1df797SChuck Lever .pc_argsize = sizeof(struct nfsd3_accessargs), 419ba1df797SChuck Lever .pc_ressize = sizeof(struct nfsd3_accessres), 420ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 421ba1df797SChuck Lever .pc_xdrressize = ST+AT+1, 422ba1df797SChuck Lever }, 423a257cdd0SAndreas Gruenbacher }; 424a257cdd0SAndreas Gruenbacher 4257fd38af9SChristoph Hellwig static unsigned int nfsd_acl_count2[ARRAY_SIZE(nfsd_acl_procedures2)]; 426e9679189SChristoph Hellwig const struct svc_version nfsd_acl_version2 = { 427a257cdd0SAndreas Gruenbacher .vs_vers = 2, 428a257cdd0SAndreas Gruenbacher .vs_nproc = 5, 429a257cdd0SAndreas Gruenbacher .vs_proc = nfsd_acl_procedures2, 4307fd38af9SChristoph Hellwig .vs_count = nfsd_acl_count2, 431a257cdd0SAndreas Gruenbacher .vs_dispatch = nfsd_dispatch, 432a257cdd0SAndreas Gruenbacher .vs_xdrsize = NFS3_SVC_XDRSIZE, 433a257cdd0SAndreas Gruenbacher }; 434