Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 2 | /* |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 3 | * Process version 3 NFSACL requests. |
| 4 | * |
| 5 | * Copyright (C) 2002-2003 Andreas Gruenbacher <agruen@suse.de> |
| 6 | */ |
| 7 | |
Boaz Harrosh | 9a74af2 | 2009-12-03 20:30:56 +0200 | [diff] [blame] | 8 | #include "nfsd.h" |
| 9 | /* FIXME: nfsacl.h is a broken header */ |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 10 | #include <linux/nfsacl.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 11 | #include <linux/gfp.h> |
Boaz Harrosh | 9a74af2 | 2009-12-03 20:30:56 +0200 | [diff] [blame] | 12 | #include "cache.h" |
| 13 | #include "xdr3.h" |
J. Bruce Fields | 0a3adad | 2009-11-04 18:12:35 -0500 | [diff] [blame] | 14 | #include "vfs.h" |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 15 | |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 16 | /* |
| 17 | * NULL call. |
| 18 | */ |
Al Viro | 7111c66 | 2006-10-19 23:28:45 -0700 | [diff] [blame] | 19 | static __be32 |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 20 | nfsd3_proc_null(struct svc_rqst *rqstp) |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 21 | { |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 22 | return rpc_success; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 23 | } |
| 24 | |
| 25 | /* |
| 26 | * Get the Access and/or Default ACL of a file. |
| 27 | */ |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 28 | static __be32 nfsd3_proc_getacl(struct svc_rqst *rqstp) |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 29 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 30 | struct nfsd3_getaclargs *argp = rqstp->rq_argp; |
| 31 | struct nfsd3_getaclres *resp = rqstp->rq_resp; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 32 | struct posix_acl *acl; |
Christoph Hellwig | 4ac7249 | 2013-12-20 05:16:55 -0800 | [diff] [blame] | 33 | struct inode *inode; |
| 34 | svc_fh *fh; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 35 | |
| 36 | fh = fh_copy(&resp->fh, &argp->fh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 37 | resp->status = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_NOP); |
| 38 | if (resp->status != nfs_ok) |
| 39 | goto out; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 40 | |
David Howells | 2b0143b | 2015-03-17 22:25:59 +0000 | [diff] [blame] | 41 | inode = d_inode(fh->fh_dentry); |
Christoph Hellwig | 4ac7249 | 2013-12-20 05:16:55 -0800 | [diff] [blame] | 42 | |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 43 | if (argp->mask & ~NFS_ACL_MASK) { |
| 44 | resp->status = nfserr_inval; |
| 45 | goto out; |
| 46 | } |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 47 | resp->mask = argp->mask; |
| 48 | |
| 49 | if (resp->mask & (NFS_ACL|NFS_ACLCNT)) { |
Christoph Hellwig | 4ac7249 | 2013-12-20 05:16:55 -0800 | [diff] [blame] | 50 | acl = get_acl(inode, ACL_TYPE_ACCESS); |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 51 | if (acl == NULL) { |
| 52 | /* Solaris returns the inode's minimum ACL. */ |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 53 | acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL); |
| 54 | } |
Kinglong Mee | 35e634b | 2014-07-09 21:54:16 +0800 | [diff] [blame] | 55 | if (IS_ERR(acl)) { |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 56 | resp->status = nfserrno(PTR_ERR(acl)); |
Kinglong Mee | 35e634b | 2014-07-09 21:54:16 +0800 | [diff] [blame] | 57 | goto fail; |
| 58 | } |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 59 | resp->acl_access = acl; |
| 60 | } |
| 61 | if (resp->mask & (NFS_DFACL|NFS_DFACLCNT)) { |
| 62 | /* Check how Solaris handles requests for the Default ACL |
| 63 | of a non-directory! */ |
Christoph Hellwig | 4ac7249 | 2013-12-20 05:16:55 -0800 | [diff] [blame] | 64 | acl = get_acl(inode, ACL_TYPE_DEFAULT); |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 65 | if (IS_ERR(acl)) { |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 66 | resp->status = nfserrno(PTR_ERR(acl)); |
Christoph Hellwig | 4ac7249 | 2013-12-20 05:16:55 -0800 | [diff] [blame] | 67 | goto fail; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 68 | } |
| 69 | resp->acl_default = acl; |
| 70 | } |
| 71 | |
| 72 | /* resp->acl_{access,default} are released in nfs3svc_release_getacl. */ |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 73 | out: |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 74 | return rpc_success; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 75 | |
| 76 | fail: |
| 77 | posix_acl_release(resp->acl_access); |
| 78 | posix_acl_release(resp->acl_default); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 79 | goto out; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 80 | } |
| 81 | |
| 82 | /* |
| 83 | * Set the Access and/or Default ACL of a file. |
| 84 | */ |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 85 | static __be32 nfsd3_proc_setacl(struct svc_rqst *rqstp) |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 86 | { |
Christoph Hellwig | a6beb73 | 2017-05-08 17:35:49 +0200 | [diff] [blame] | 87 | struct nfsd3_setaclargs *argp = rqstp->rq_argp; |
| 88 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
Christoph Hellwig | 4ac7249 | 2013-12-20 05:16:55 -0800 | [diff] [blame] | 89 | struct inode *inode; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 90 | svc_fh *fh; |
Christoph Hellwig | 4ac7249 | 2013-12-20 05:16:55 -0800 | [diff] [blame] | 91 | int error; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 92 | |
| 93 | fh = fh_copy(&resp->fh, &argp->fh); |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 94 | resp->status = fh_verify(rqstp, &resp->fh, 0, NFSD_MAY_SATTR); |
| 95 | if (resp->status != nfs_ok) |
Christoph Hellwig | 4ac7249 | 2013-12-20 05:16:55 -0800 | [diff] [blame] | 96 | goto out; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 97 | |
David Howells | 2b0143b | 2015-03-17 22:25:59 +0000 | [diff] [blame] | 98 | inode = d_inode(fh->fh_dentry); |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 99 | |
Christoph Hellwig | 4ac7249 | 2013-12-20 05:16:55 -0800 | [diff] [blame] | 100 | error = fh_want_write(fh); |
| 101 | if (error) |
| 102 | goto out_errno; |
| 103 | |
Ben Hutchings | 9996537 | 2016-06-22 19:43:35 +0100 | [diff] [blame] | 104 | fh_lock(fh); |
Christoph Hellwig | 4ac7249 | 2013-12-20 05:16:55 -0800 | [diff] [blame] | 105 | |
Christian Brauner | e65ce2a | 2021-01-21 14:19:27 +0100 | [diff] [blame] | 106 | error = set_posix_acl(&init_user_ns, inode, ACL_TYPE_ACCESS, |
| 107 | argp->acl_access); |
Ben Hutchings | 9996537 | 2016-06-22 19:43:35 +0100 | [diff] [blame] | 108 | if (error) |
| 109 | goto out_drop_lock; |
Christian Brauner | e65ce2a | 2021-01-21 14:19:27 +0100 | [diff] [blame] | 110 | error = set_posix_acl(&init_user_ns, inode, ACL_TYPE_DEFAULT, |
| 111 | argp->acl_default); |
Ben Hutchings | 9996537 | 2016-06-22 19:43:35 +0100 | [diff] [blame] | 112 | |
| 113 | out_drop_lock: |
| 114 | fh_unlock(fh); |
Christoph Hellwig | 4ac7249 | 2013-12-20 05:16:55 -0800 | [diff] [blame] | 115 | fh_drop_write(fh); |
| 116 | out_errno: |
Chuck Lever | 14168d6 | 2020-10-01 18:59:54 -0400 | [diff] [blame] | 117 | resp->status = nfserrno(error); |
Christoph Hellwig | 4ac7249 | 2013-12-20 05:16:55 -0800 | [diff] [blame] | 118 | out: |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 119 | /* argp->acl_{access,default} may have been allocated in |
| 120 | nfs3svc_decode_setaclargs. */ |
| 121 | posix_acl_release(argp->acl_access); |
| 122 | posix_acl_release(argp->acl_default); |
Chuck Lever | cc028a1 | 2020-10-02 15:52:44 -0400 | [diff] [blame] | 123 | return rpc_success; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 124 | } |
| 125 | |
| 126 | /* |
| 127 | * XDR decode functions |
| 128 | */ |
Chuck Lever | 05027ea | 2020-11-17 11:52:04 -0500 | [diff] [blame] | 129 | |
Chuck Lever | c44b31c | 2021-10-12 11:57:28 -0400 | [diff] [blame] | 130 | static bool |
Chuck Lever | 16c6636 | 2021-10-12 11:57:22 -0400 | [diff] [blame] | 131 | nfs3svc_decode_getaclargs(struct svc_rqst *rqstp, struct xdr_stream *xdr) |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 132 | { |
Christoph Hellwig | 026fec7 | 2017-05-08 19:01:48 +0200 | [diff] [blame] | 133 | struct nfsd3_getaclargs *args = rqstp->rq_argp; |
| 134 | |
Chuck Lever | 05027ea | 2020-11-17 11:52:04 -0500 | [diff] [blame] | 135 | if (!svcxdr_decode_nfs_fh3(xdr, &args->fh)) |
Chuck Lever | c44b31c | 2021-10-12 11:57:28 -0400 | [diff] [blame] | 136 | return false; |
Chuck Lever | 05027ea | 2020-11-17 11:52:04 -0500 | [diff] [blame] | 137 | if (xdr_stream_decode_u32(xdr, &args->mask) < 0) |
Chuck Lever | c44b31c | 2021-10-12 11:57:28 -0400 | [diff] [blame] | 138 | return false; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 139 | |
Chuck Lever | c44b31c | 2021-10-12 11:57:28 -0400 | [diff] [blame] | 140 | return true; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 141 | } |
| 142 | |
Chuck Lever | c44b31c | 2021-10-12 11:57:28 -0400 | [diff] [blame] | 143 | static bool |
Chuck Lever | 16c6636 | 2021-10-12 11:57:22 -0400 | [diff] [blame] | 144 | nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, struct xdr_stream *xdr) |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 145 | { |
Chuck Lever | 68519ff | 2020-11-17 11:56:26 -0500 | [diff] [blame] | 146 | struct nfsd3_setaclargs *argp = rqstp->rq_argp; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 147 | |
Chuck Lever | 68519ff | 2020-11-17 11:56:26 -0500 | [diff] [blame] | 148 | if (!svcxdr_decode_nfs_fh3(xdr, &argp->fh)) |
Chuck Lever | c44b31c | 2021-10-12 11:57:28 -0400 | [diff] [blame] | 149 | return false; |
Chuck Lever | 68519ff | 2020-11-17 11:56:26 -0500 | [diff] [blame] | 150 | if (xdr_stream_decode_u32(xdr, &argp->mask) < 0) |
Chuck Lever | c44b31c | 2021-10-12 11:57:28 -0400 | [diff] [blame] | 151 | return false; |
Chuck Lever | 68519ff | 2020-11-17 11:56:26 -0500 | [diff] [blame] | 152 | if (argp->mask & ~NFS_ACL_MASK) |
Chuck Lever | c44b31c | 2021-10-12 11:57:28 -0400 | [diff] [blame] | 153 | return false; |
Chuck Lever | 68519ff | 2020-11-17 11:56:26 -0500 | [diff] [blame] | 154 | if (!nfs_stream_decode_acl(xdr, NULL, (argp->mask & NFS_ACL) ? |
| 155 | &argp->acl_access : NULL)) |
Chuck Lever | c44b31c | 2021-10-12 11:57:28 -0400 | [diff] [blame] | 156 | return false; |
Chuck Lever | 68519ff | 2020-11-17 11:56:26 -0500 | [diff] [blame] | 157 | if (!nfs_stream_decode_acl(xdr, NULL, (argp->mask & NFS_DFACL) ? |
| 158 | &argp->acl_default : NULL)) |
Chuck Lever | c44b31c | 2021-10-12 11:57:28 -0400 | [diff] [blame] | 159 | return false; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 160 | |
Chuck Lever | c44b31c | 2021-10-12 11:57:28 -0400 | [diff] [blame] | 161 | return true; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 162 | } |
| 163 | |
| 164 | /* |
| 165 | * XDR encode functions |
| 166 | */ |
| 167 | |
| 168 | /* GETACL */ |
Chuck Lever | 130e205 | 2021-10-13 10:41:13 -0400 | [diff] [blame] | 169 | static bool |
Chuck Lever | fda4944 | 2021-10-13 10:41:06 -0400 | [diff] [blame] | 170 | nfs3svc_encode_getaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr) |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 171 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 172 | struct nfsd3_getaclres *resp = rqstp->rq_resp; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 173 | struct dentry *dentry = resp->fh.fh_dentry; |
Chuck Lever | 20798df | 2020-11-18 16:11:42 -0500 | [diff] [blame] | 174 | struct kvec *head = rqstp->rq_res.head; |
J. Bruce Fields | ab1016d | 2021-07-01 20:06:56 -0400 | [diff] [blame] | 175 | struct inode *inode; |
Chuck Lever | 20798df | 2020-11-18 16:11:42 -0500 | [diff] [blame] | 176 | unsigned int base; |
| 177 | int n; |
| 178 | int w; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 179 | |
Chuck Lever | 20798df | 2020-11-18 16:11:42 -0500 | [diff] [blame] | 180 | if (!svcxdr_encode_nfsstat3(xdr, resp->status)) |
Chuck Lever | 130e205 | 2021-10-13 10:41:13 -0400 | [diff] [blame] | 181 | return false; |
Chuck Lever | 20798df | 2020-11-18 16:11:42 -0500 | [diff] [blame] | 182 | switch (resp->status) { |
| 183 | case nfs_ok: |
J. Bruce Fields | ab1016d | 2021-07-01 20:06:56 -0400 | [diff] [blame] | 184 | inode = d_inode(dentry); |
Chuck Lever | 20798df | 2020-11-18 16:11:42 -0500 | [diff] [blame] | 185 | if (!svcxdr_encode_post_op_attr(rqstp, xdr, &resp->fh)) |
Chuck Lever | 130e205 | 2021-10-13 10:41:13 -0400 | [diff] [blame] | 186 | return false; |
Chuck Lever | 20798df | 2020-11-18 16:11:42 -0500 | [diff] [blame] | 187 | if (xdr_stream_encode_u32(xdr, resp->mask) < 0) |
Chuck Lever | 130e205 | 2021-10-13 10:41:13 -0400 | [diff] [blame] | 188 | return false; |
Chuck Lever | 20798df | 2020-11-18 16:11:42 -0500 | [diff] [blame] | 189 | |
| 190 | base = (char *)xdr->p - (char *)head->iov_base; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 191 | |
Jesper Juhl | 14d2b59 | 2006-12-08 02:39:40 -0800 | [diff] [blame] | 192 | rqstp->rq_res.page_len = w = nfsacl_size( |
| 193 | (resp->mask & NFS_ACL) ? resp->acl_access : NULL, |
| 194 | (resp->mask & NFS_DFACL) ? resp->acl_default : NULL); |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 195 | while (w > 0) { |
J. Bruce Fields | afc5940 | 2012-12-10 18:01:37 -0500 | [diff] [blame] | 196 | if (!*(rqstp->rq_next_page++)) |
Chuck Lever | 130e205 | 2021-10-13 10:41:13 -0400 | [diff] [blame] | 197 | return false; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 198 | w -= PAGE_SIZE; |
| 199 | } |
| 200 | |
| 201 | n = nfsacl_encode(&rqstp->rq_res, base, inode, |
| 202 | resp->acl_access, |
| 203 | resp->mask & NFS_ACL, 0); |
| 204 | if (n > 0) |
| 205 | n = nfsacl_encode(&rqstp->rq_res, base + n, inode, |
| 206 | resp->acl_default, |
| 207 | resp->mask & NFS_DFACL, |
| 208 | NFS_ACL_DEFAULT); |
| 209 | if (n <= 0) |
Chuck Lever | 130e205 | 2021-10-13 10:41:13 -0400 | [diff] [blame] | 210 | return false; |
Chuck Lever | 20798df | 2020-11-18 16:11:42 -0500 | [diff] [blame] | 211 | break; |
| 212 | default: |
| 213 | if (!svcxdr_encode_post_op_attr(rqstp, xdr, &resp->fh)) |
Chuck Lever | 130e205 | 2021-10-13 10:41:13 -0400 | [diff] [blame] | 214 | return false; |
Chuck Lever | 20798df | 2020-11-18 16:11:42 -0500 | [diff] [blame] | 215 | } |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 216 | |
Chuck Lever | 130e205 | 2021-10-13 10:41:13 -0400 | [diff] [blame] | 217 | return true; |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 218 | } |
| 219 | |
| 220 | /* SETACL */ |
Chuck Lever | 130e205 | 2021-10-13 10:41:13 -0400 | [diff] [blame] | 221 | static bool |
Chuck Lever | fda4944 | 2021-10-13 10:41:06 -0400 | [diff] [blame] | 222 | nfs3svc_encode_setaclres(struct svc_rqst *rqstp, struct xdr_stream *xdr) |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 223 | { |
Christoph Hellwig | 63f8de3 | 2017-05-08 19:42:02 +0200 | [diff] [blame] | 224 | struct nfsd3_attrstat *resp = rqstp->rq_resp; |
| 225 | |
Chuck Lever | 15e432b | 2020-11-18 16:21:24 -0500 | [diff] [blame] | 226 | return svcxdr_encode_nfsstat3(xdr, resp->status) && |
| 227 | svcxdr_encode_post_op_attr(rqstp, xdr, &resp->fh); |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 228 | } |
| 229 | |
| 230 | /* |
| 231 | * XDR release functions |
| 232 | */ |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 233 | static void nfs3svc_release_getacl(struct svc_rqst *rqstp) |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 234 | { |
Christoph Hellwig | 8537488 | 2017-05-08 18:48:24 +0200 | [diff] [blame] | 235 | struct nfsd3_getaclres *resp = rqstp->rq_resp; |
| 236 | |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 237 | fh_put(&resp->fh); |
| 238 | posix_acl_release(resp->acl_access); |
| 239 | posix_acl_release(resp->acl_default); |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 240 | } |
| 241 | |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 242 | struct nfsd3_voidargs { int dummy; }; |
| 243 | |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 244 | #define ST 1 /* status*/ |
| 245 | #define AT 21 /* attributes */ |
| 246 | #define pAT (1+AT) /* post attributes - conditional */ |
| 247 | #define ACL (1+NFS_ACL_MAX_ENTRIES*3) /* Access Control List */ |
| 248 | |
Chuck Lever | ba1df79 | 2020-10-01 18:59:07 -0400 | [diff] [blame] | 249 | static const struct svc_procedure nfsd_acl_procedures3[3] = { |
| 250 | [ACLPROC3_NULL] = { |
| 251 | .pc_func = nfsd3_proc_null, |
Chuck Lever | 788f718 | 2020-11-05 14:48:29 -0500 | [diff] [blame] | 252 | .pc_decode = nfssvc_decode_voidarg, |
| 253 | .pc_encode = nfssvc_encode_voidres, |
| 254 | .pc_argsize = sizeof(struct nfsd_voidargs), |
| 255 | .pc_ressize = sizeof(struct nfsd_voidres), |
Chuck Lever | ba1df79 | 2020-10-01 18:59:07 -0400 | [diff] [blame] | 256 | .pc_cachetype = RC_NOCACHE, |
| 257 | .pc_xdrressize = ST, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 258 | .pc_name = "NULL", |
Chuck Lever | ba1df79 | 2020-10-01 18:59:07 -0400 | [diff] [blame] | 259 | }, |
| 260 | [ACLPROC3_GETACL] = { |
| 261 | .pc_func = nfsd3_proc_getacl, |
| 262 | .pc_decode = nfs3svc_decode_getaclargs, |
| 263 | .pc_encode = nfs3svc_encode_getaclres, |
| 264 | .pc_release = nfs3svc_release_getacl, |
| 265 | .pc_argsize = sizeof(struct nfsd3_getaclargs), |
| 266 | .pc_ressize = sizeof(struct nfsd3_getaclres), |
| 267 | .pc_cachetype = RC_NOCACHE, |
| 268 | .pc_xdrressize = ST+1+2*(1+ACL), |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 269 | .pc_name = "GETACL", |
Chuck Lever | ba1df79 | 2020-10-01 18:59:07 -0400 | [diff] [blame] | 270 | }, |
| 271 | [ACLPROC3_SETACL] = { |
| 272 | .pc_func = nfsd3_proc_setacl, |
| 273 | .pc_decode = nfs3svc_decode_setaclargs, |
| 274 | .pc_encode = nfs3svc_encode_setaclres, |
| 275 | .pc_release = nfs3svc_release_fhandle, |
| 276 | .pc_argsize = sizeof(struct nfsd3_setaclargs), |
| 277 | .pc_ressize = sizeof(struct nfsd3_attrstat), |
| 278 | .pc_cachetype = RC_NOCACHE, |
| 279 | .pc_xdrressize = ST+pAT, |
Chuck Lever | 2289e87 | 2020-09-17 17:22:49 -0400 | [diff] [blame] | 280 | .pc_name = "SETACL", |
Chuck Lever | ba1df79 | 2020-10-01 18:59:07 -0400 | [diff] [blame] | 281 | }, |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 282 | }; |
| 283 | |
Christoph Hellwig | 7fd38af | 2017-05-08 23:40:27 +0200 | [diff] [blame] | 284 | static unsigned int nfsd_acl_count3[ARRAY_SIZE(nfsd_acl_procedures3)]; |
Christoph Hellwig | e967918 | 2017-05-12 16:21:37 +0200 | [diff] [blame] | 285 | const struct svc_version nfsd_acl_version3 = { |
| 286 | .vs_vers = 3, |
| 287 | .vs_nproc = 3, |
| 288 | .vs_proc = nfsd_acl_procedures3, |
| 289 | .vs_count = nfsd_acl_count3, |
| 290 | .vs_dispatch = nfsd_dispatch, |
| 291 | .vs_xdrsize = NFS3_SVC_XDRSIZE, |
Andreas Gruenbacher | a257cdd | 2005-06-22 17:16:26 +0000 | [diff] [blame] | 292 | }; |
| 293 | |