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 { 24cc028a10SChuck Lever return rpc_success; 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); 41f0af2210SChuck Lever resp->status = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); 42f0af2210SChuck Lever if (resp->status != nfs_ok) 43f0af2210SChuck Lever goto out; 44a257cdd0SAndreas Gruenbacher 452b0143b5SDavid Howells inode = d_inode(fh->fh_dentry); 464ac7249eSChristoph Hellwig 47f0af2210SChuck Lever if (argp->mask & ~NFS_ACL_MASK) { 48f0af2210SChuck Lever resp->status = nfserr_inval; 49f0af2210SChuck Lever goto out; 50f0af2210SChuck Lever } 51a257cdd0SAndreas Gruenbacher resp->mask = argp->mask; 52a257cdd0SAndreas Gruenbacher 53f0af2210SChuck Lever resp->status = fh_getattr(fh, &resp->stat); 54f0af2210SChuck Lever if (resp->status != nfs_ok) 55f0af2210SChuck 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)) { 64f0af2210SChuck 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)) { 74f0af2210SChuck 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. */ 81f0af2210SChuck Lever out: 82cc028a10SChuck Lever return rpc_success; 83a257cdd0SAndreas Gruenbacher 84a257cdd0SAndreas Gruenbacher fail: 85a257cdd0SAndreas Gruenbacher posix_acl_release(resp->acl_access); 86a257cdd0SAndreas Gruenbacher posix_acl_release(resp->acl_default); 87f0af2210SChuck 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); 104f0af2210SChuck Lever resp->status = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR); 105f0af2210SChuck 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 116*e65ce2a5SChristian Brauner error = set_posix_acl(&init_user_ns, inode, ACL_TYPE_ACCESS, 117*e65ce2a5SChristian Brauner argp->acl_access); 1184ac7249eSChristoph Hellwig if (error) 11999965378SBen Hutchings goto out_drop_lock; 120*e65ce2a5SChristian Brauner error = set_posix_acl(&init_user_ns, inode, ACL_TYPE_DEFAULT, 121*e65ce2a5SChristian Brauner argp->acl_default); 1224ac7249eSChristoph Hellwig if (error) 12399965378SBen Hutchings goto out_drop_lock; 12499965378SBen Hutchings 12599965378SBen Hutchings fh_unlock(fh); 1264ac7249eSChristoph Hellwig 1274ac7249eSChristoph Hellwig fh_drop_write(fh); 1284ac7249eSChristoph Hellwig 129f0af2210SChuck Lever resp->status = fh_getattr(fh, &resp->stat); 130a257cdd0SAndreas Gruenbacher 1314ac7249eSChristoph Hellwig out: 132a257cdd0SAndreas Gruenbacher /* argp->acl_{access,default} may have been allocated in 133a257cdd0SAndreas Gruenbacher nfssvc_decode_setaclargs. */ 134a257cdd0SAndreas Gruenbacher posix_acl_release(argp->acl_access); 135a257cdd0SAndreas Gruenbacher posix_acl_release(argp->acl_default); 136cc028a10SChuck Lever return rpc_success; 137f0af2210SChuck Lever 13899965378SBen Hutchings out_drop_lock: 13999965378SBen Hutchings fh_unlock(fh); 1404ac7249eSChristoph Hellwig fh_drop_write(fh); 1414ac7249eSChristoph Hellwig out_errno: 142f0af2210SChuck Lever resp->status = nfserrno(error); 1434ac7249eSChristoph Hellwig goto out; 144a257cdd0SAndreas Gruenbacher } 145a257cdd0SAndreas Gruenbacher 146a257cdd0SAndreas Gruenbacher /* 147a257cdd0SAndreas Gruenbacher * Check file attributes 148a257cdd0SAndreas Gruenbacher */ 149a6beb732SChristoph Hellwig static __be32 nfsacld_proc_getattr(struct svc_rqst *rqstp) 150a257cdd0SAndreas Gruenbacher { 151a6beb732SChristoph Hellwig struct nfsd_fhandle *argp = rqstp->rq_argp; 152a6beb732SChristoph Hellwig struct nfsd_attrstat *resp = rqstp->rq_resp; 153f0af2210SChuck Lever 154a257cdd0SAndreas Gruenbacher dprintk("nfsd: GETATTR %s\n", SVCFH_fmt(&argp->fh)); 155a257cdd0SAndreas Gruenbacher 156a257cdd0SAndreas Gruenbacher fh_copy(&resp->fh, &argp->fh); 157f0af2210SChuck Lever resp->status = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); 158f0af2210SChuck Lever if (resp->status != nfs_ok) 159f0af2210SChuck Lever goto out; 160f0af2210SChuck Lever resp->status = fh_getattr(&resp->fh, &resp->stat); 161f0af2210SChuck Lever out: 162cc028a10SChuck Lever return rpc_success; 163a257cdd0SAndreas Gruenbacher } 164a257cdd0SAndreas Gruenbacher 165a257cdd0SAndreas Gruenbacher /* 166a257cdd0SAndreas Gruenbacher * Check file access 167a257cdd0SAndreas Gruenbacher */ 168a6beb732SChristoph Hellwig static __be32 nfsacld_proc_access(struct svc_rqst *rqstp) 169a257cdd0SAndreas Gruenbacher { 170a6beb732SChristoph Hellwig struct nfsd3_accessargs *argp = rqstp->rq_argp; 171a6beb732SChristoph Hellwig struct nfsd3_accessres *resp = rqstp->rq_resp; 172a257cdd0SAndreas Gruenbacher 173a257cdd0SAndreas Gruenbacher dprintk("nfsd: ACCESS(2acl) %s 0x%x\n", 174a257cdd0SAndreas Gruenbacher SVCFH_fmt(&argp->fh), 175a257cdd0SAndreas Gruenbacher argp->access); 176a257cdd0SAndreas Gruenbacher 177a257cdd0SAndreas Gruenbacher fh_copy(&resp->fh, &argp->fh); 178a257cdd0SAndreas Gruenbacher resp->access = argp->access; 179f0af2210SChuck Lever resp->status = nfsd_access(rqstp, &resp->fh, &resp->access, NULL); 180f0af2210SChuck Lever if (resp->status != nfs_ok) 181f0af2210SChuck Lever goto out; 182f0af2210SChuck Lever resp->status = fh_getattr(&resp->fh, &resp->stat); 183f0af2210SChuck Lever out: 184cc028a10SChuck Lever return rpc_success; 185a257cdd0SAndreas Gruenbacher } 186a257cdd0SAndreas Gruenbacher 187a257cdd0SAndreas Gruenbacher /* 188a257cdd0SAndreas Gruenbacher * XDR decode functions 189a257cdd0SAndreas Gruenbacher */ 190dcc46991SChuck 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 256a257cdd0SAndreas Gruenbacher /* GETACL */ 25763f8de37SChristoph Hellwig static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p) 258a257cdd0SAndreas Gruenbacher { 25963f8de37SChristoph Hellwig struct nfsd3_getaclres *resp = rqstp->rq_resp; 260a257cdd0SAndreas Gruenbacher struct dentry *dentry = resp->fh.fh_dentry; 261aefa89d1SPrasad P struct inode *inode; 262a257cdd0SAndreas Gruenbacher struct kvec *head = rqstp->rq_res.head; 263a257cdd0SAndreas Gruenbacher unsigned int base; 264a257cdd0SAndreas Gruenbacher int n; 265cb65a5baSJesper Juhl int w; 266a257cdd0SAndreas Gruenbacher 267cc028a10SChuck Lever *p++ = resp->status; 268f0af2210SChuck Lever if (resp->status != nfs_ok) 269f0af2210SChuck Lever return xdr_ressize_check(rqstp, p); 270f0af2210SChuck Lever 271aefa89d1SPrasad P /* 272aefa89d1SPrasad P * Since this is version 2, the check for nfserr in 273aefa89d1SPrasad P * nfsd_dispatch actually ensures the following cannot happen. 274aefa89d1SPrasad P * However, it seems fragile to depend on that. 275aefa89d1SPrasad P */ 2762b0143b5SDavid Howells if (dentry == NULL || d_really_is_negative(dentry)) 277a257cdd0SAndreas Gruenbacher return 0; 2782b0143b5SDavid Howells inode = d_inode(dentry); 279a257cdd0SAndreas Gruenbacher 2804f4a4fadSJ. Bruce Fields p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat); 281a257cdd0SAndreas Gruenbacher *p++ = htonl(resp->mask); 282a257cdd0SAndreas Gruenbacher if (!xdr_ressize_check(rqstp, p)) 283a257cdd0SAndreas Gruenbacher return 0; 284a257cdd0SAndreas Gruenbacher base = (char *)p - (char *)head->iov_base; 285a257cdd0SAndreas Gruenbacher 286cb65a5baSJesper Juhl rqstp->rq_res.page_len = w = nfsacl_size( 287cb65a5baSJesper Juhl (resp->mask & NFS_ACL) ? resp->acl_access : NULL, 288cb65a5baSJesper Juhl (resp->mask & NFS_DFACL) ? resp->acl_default : NULL); 289a257cdd0SAndreas Gruenbacher while (w > 0) { 290afc59400SJ. Bruce Fields if (!*(rqstp->rq_next_page++)) 291a257cdd0SAndreas Gruenbacher return 0; 292a257cdd0SAndreas Gruenbacher w -= PAGE_SIZE; 293a257cdd0SAndreas Gruenbacher } 294a257cdd0SAndreas Gruenbacher 295a257cdd0SAndreas Gruenbacher n = nfsacl_encode(&rqstp->rq_res, base, inode, 296a257cdd0SAndreas Gruenbacher resp->acl_access, 297a257cdd0SAndreas Gruenbacher resp->mask & NFS_ACL, 0); 298a257cdd0SAndreas Gruenbacher if (n > 0) 299a257cdd0SAndreas Gruenbacher n = nfsacl_encode(&rqstp->rq_res, base + n, inode, 300a257cdd0SAndreas Gruenbacher resp->acl_default, 301a257cdd0SAndreas Gruenbacher resp->mask & NFS_DFACL, 302a257cdd0SAndreas Gruenbacher NFS_ACL_DEFAULT); 3037b8f4586SKinglong Mee return (n > 0); 304a257cdd0SAndreas Gruenbacher } 305a257cdd0SAndreas Gruenbacher 30663f8de37SChristoph Hellwig static int nfsaclsvc_encode_attrstatres(struct svc_rqst *rqstp, __be32 *p) 307a257cdd0SAndreas Gruenbacher { 30863f8de37SChristoph Hellwig struct nfsd_attrstat *resp = rqstp->rq_resp; 30963f8de37SChristoph Hellwig 310cc028a10SChuck Lever *p++ = resp->status; 311f0af2210SChuck Lever if (resp->status != nfs_ok) 312cc028a10SChuck Lever goto out; 313f0af2210SChuck Lever 3144f4a4fadSJ. Bruce Fields p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat); 315cc028a10SChuck Lever out: 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 324cc028a10SChuck Lever *p++ = resp->status; 325f0af2210SChuck Lever if (resp->status != nfs_ok) 326cc028a10SChuck Lever goto out; 327f0af2210SChuck Lever 3284f4a4fadSJ. Bruce Fields p = nfs2svc_encode_fattr(rqstp, p, &resp->fh, &resp->stat); 329a257cdd0SAndreas Gruenbacher *p++ = htonl(resp->access); 330cc028a10SChuck Lever out: 331a257cdd0SAndreas Gruenbacher return xdr_ressize_check(rqstp, p); 332a257cdd0SAndreas Gruenbacher } 333a257cdd0SAndreas Gruenbacher 334a257cdd0SAndreas Gruenbacher /* 335a257cdd0SAndreas Gruenbacher * XDR release functions 336a257cdd0SAndreas Gruenbacher */ 3378537488bSChristoph Hellwig static void nfsaclsvc_release_getacl(struct svc_rqst *rqstp) 338a257cdd0SAndreas Gruenbacher { 3398537488bSChristoph Hellwig struct nfsd3_getaclres *resp = rqstp->rq_resp; 3408537488bSChristoph Hellwig 341a257cdd0SAndreas Gruenbacher fh_put(&resp->fh); 342a257cdd0SAndreas Gruenbacher posix_acl_release(resp->acl_access); 343a257cdd0SAndreas Gruenbacher posix_acl_release(resp->acl_default); 344a257cdd0SAndreas Gruenbacher } 345a257cdd0SAndreas Gruenbacher 3468537488bSChristoph Hellwig static void nfsaclsvc_release_attrstat(struct svc_rqst *rqstp) 347c9ce2283SGreg Banks { 3488537488bSChristoph Hellwig struct nfsd_attrstat *resp = rqstp->rq_resp; 3498537488bSChristoph Hellwig 350c9ce2283SGreg Banks fh_put(&resp->fh); 351c9ce2283SGreg Banks } 352c9ce2283SGreg Banks 3538537488bSChristoph Hellwig static void nfsaclsvc_release_access(struct svc_rqst *rqstp) 354a257cdd0SAndreas Gruenbacher { 3558537488bSChristoph Hellwig struct nfsd3_accessres *resp = rqstp->rq_resp; 3568537488bSChristoph Hellwig 357a257cdd0SAndreas Gruenbacher fh_put(&resp->fh); 358a257cdd0SAndreas Gruenbacher } 359a257cdd0SAndreas Gruenbacher 360a257cdd0SAndreas Gruenbacher struct nfsd3_voidargs { int dummy; }; 361a257cdd0SAndreas Gruenbacher 362a257cdd0SAndreas Gruenbacher #define ST 1 /* status*/ 363a257cdd0SAndreas Gruenbacher #define AT 21 /* attributes */ 364a257cdd0SAndreas Gruenbacher #define pAT (1+AT) /* post attributes - conditional */ 365a257cdd0SAndreas Gruenbacher #define ACL (1+NFS_ACL_MAX_ENTRIES*3) /* Access Control List */ 366a257cdd0SAndreas Gruenbacher 367ba1df797SChuck Lever static const struct svc_procedure nfsd_acl_procedures2[5] = { 368ba1df797SChuck Lever [ACLPROC2_NULL] = { 369ba1df797SChuck Lever .pc_func = nfsacld_proc_null, 370788f7183SChuck Lever .pc_decode = nfssvc_decode_voidarg, 371788f7183SChuck Lever .pc_encode = nfssvc_encode_voidres, 372788f7183SChuck Lever .pc_argsize = sizeof(struct nfsd_voidargs), 373788f7183SChuck Lever .pc_ressize = sizeof(struct nfsd_voidres), 374ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 375ba1df797SChuck Lever .pc_xdrressize = ST, 376ba1df797SChuck Lever }, 377ba1df797SChuck Lever [ACLPROC2_GETACL] = { 378ba1df797SChuck Lever .pc_func = nfsacld_proc_getacl, 379ba1df797SChuck Lever .pc_decode = nfsaclsvc_decode_getaclargs, 380ba1df797SChuck Lever .pc_encode = nfsaclsvc_encode_getaclres, 381ba1df797SChuck Lever .pc_release = nfsaclsvc_release_getacl, 382ba1df797SChuck Lever .pc_argsize = sizeof(struct nfsd3_getaclargs), 383ba1df797SChuck Lever .pc_ressize = sizeof(struct nfsd3_getaclres), 384ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 385ba1df797SChuck Lever .pc_xdrressize = ST+1+2*(1+ACL), 386ba1df797SChuck Lever }, 387ba1df797SChuck Lever [ACLPROC2_SETACL] = { 388ba1df797SChuck Lever .pc_func = nfsacld_proc_setacl, 389ba1df797SChuck Lever .pc_decode = nfsaclsvc_decode_setaclargs, 390ba1df797SChuck Lever .pc_encode = nfsaclsvc_encode_attrstatres, 391ba1df797SChuck Lever .pc_release = nfsaclsvc_release_attrstat, 392ba1df797SChuck Lever .pc_argsize = sizeof(struct nfsd3_setaclargs), 393ba1df797SChuck Lever .pc_ressize = sizeof(struct nfsd_attrstat), 394ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 395ba1df797SChuck Lever .pc_xdrressize = ST+AT, 396ba1df797SChuck Lever }, 397ba1df797SChuck Lever [ACLPROC2_GETATTR] = { 398ba1df797SChuck Lever .pc_func = nfsacld_proc_getattr, 399ba1df797SChuck Lever .pc_decode = nfsaclsvc_decode_fhandleargs, 400ba1df797SChuck Lever .pc_encode = nfsaclsvc_encode_attrstatres, 401ba1df797SChuck Lever .pc_release = nfsaclsvc_release_attrstat, 402ba1df797SChuck Lever .pc_argsize = sizeof(struct nfsd_fhandle), 403ba1df797SChuck Lever .pc_ressize = sizeof(struct nfsd_attrstat), 404ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 405ba1df797SChuck Lever .pc_xdrressize = ST+AT, 406ba1df797SChuck Lever }, 407ba1df797SChuck Lever [ACLPROC2_ACCESS] = { 408ba1df797SChuck Lever .pc_func = nfsacld_proc_access, 409ba1df797SChuck Lever .pc_decode = nfsaclsvc_decode_accessargs, 410ba1df797SChuck Lever .pc_encode = nfsaclsvc_encode_accessres, 411ba1df797SChuck Lever .pc_release = nfsaclsvc_release_access, 412ba1df797SChuck Lever .pc_argsize = sizeof(struct nfsd3_accessargs), 413ba1df797SChuck Lever .pc_ressize = sizeof(struct nfsd3_accessres), 414ba1df797SChuck Lever .pc_cachetype = RC_NOCACHE, 415ba1df797SChuck Lever .pc_xdrressize = ST+AT+1, 416ba1df797SChuck Lever }, 417a257cdd0SAndreas Gruenbacher }; 418a257cdd0SAndreas Gruenbacher 4197fd38af9SChristoph Hellwig static unsigned int nfsd_acl_count2[ARRAY_SIZE(nfsd_acl_procedures2)]; 420e9679189SChristoph Hellwig const struct svc_version nfsd_acl_version2 = { 421a257cdd0SAndreas Gruenbacher .vs_vers = 2, 422a257cdd0SAndreas Gruenbacher .vs_nproc = 5, 423a257cdd0SAndreas Gruenbacher .vs_proc = nfsd_acl_procedures2, 4247fd38af9SChristoph Hellwig .vs_count = nfsd_acl_count2, 425a257cdd0SAndreas Gruenbacher .vs_dispatch = nfsd_dispatch, 426a257cdd0SAndreas Gruenbacher .vs_xdrsize = NFS3_SVC_XDRSIZE, 427a257cdd0SAndreas Gruenbacher }; 428