linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuck Lever <chuck.lever@oracle.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH v2 095/118] NFSD: Update the SYMLINK3args decoder to use struct xdr_stream
Date: Fri, 20 Nov 2020 15:42:11 -0500	[thread overview]
Message-ID: <160590493180.1340.14177384748797931925.stgit@klimt.1015granger.net> (raw)
In-Reply-To: <160590425404.1340.8850646771948736468.stgit@klimt.1015granger.net>

Similar to the WRITE decoder, code that checks the sanity of the
payload size is re-wired to work with xdr_stream infrastructure.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfsd/nfs3xdr.c |   33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index ec4778f01472..6dfab4bd6c2c 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -623,26 +623,29 @@ nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, __be32 *p)
 int
 nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p)
 {
+	struct xdr_stream *xdr = &rqstp->rq_xdr_stream;
 	struct nfsd3_symlinkargs *args = rqstp->rq_argp;
-	char *base = (char *)p;
-	size_t dlen;
+	struct kvec *head = rqstp->rq_arg.head;
+	struct kvec *tail = rqstp->rq_arg.tail;
+	size_t remaining;
 
-	if (!(p = decode_fh(p, &args->ffh)) ||
-	    !(p = decode_filename(p, &args->fname, &args->flen)))
-		return 0;
-	p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp));
+	if (!svcxdr_decode_diropargs3(xdr, &args->ffh, &args->fname, &args->flen))
+		return XDR_DECODE_FAILED;
+	if (!svcxdr_decode_sattr3(rqstp, xdr, &args->attrs))
+		return XDR_DECODE_FAILED;
+	if (xdr_stream_decode_u32(xdr, &args->tlen) < 0)
+		return XDR_DECODE_FAILED;
 
-	args->tlen = ntohl(*p++);
+	/* request sanity */
+	remaining = head->iov_len + rqstp->rq_arg.page_len + tail->iov_len;
+	remaining -= xdr_stream_pos(xdr);
+	if (remaining < xdr_align_size(args->tlen))
+		return XDR_DECODE_FAILED;
 
-	args->first.iov_base = p;
-	args->first.iov_len = rqstp->rq_arg.head[0].iov_len;
-	args->first.iov_len -= (char *)p - base;
+	args->first.iov_base = xdr->p;
+	args->first.iov_len = head->iov_len - xdr_stream_pos(xdr);
 
-	dlen = args->first.iov_len + rqstp->rq_arg.page_len +
-	       rqstp->rq_arg.tail[0].iov_len;
-	if (dlen < XDR_QUADLEN(args->tlen) << 2)
-		return 0;
-	return 1;
+	return XDR_DECODE_DONE;
 }
 
 int



  parent reply	other threads:[~2020-11-20 20:42 UTC|newest]

Thread overview: 127+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-20 20:33 [PATCH v2 000/118] Update NFSD XDR functions Chuck Lever
2020-11-20 20:33 ` [PATCH v2 001/118] NFSD: Fix returned READDIR offset cookie Chuck Lever
2020-11-21  0:59   ` J. Bruce Fields
2020-11-21 16:15     ` Chuck Lever
2020-11-21 16:32       ` Bruce Fields
2020-11-20 20:33 ` [PATCH v2 002/118] SUNRPC: Add xdr_set_scratch_page() and xdr_reset_scratch_buffer() Chuck Lever
2020-11-20 20:34 ` [PATCH v2 003/118] SUNRPC: Prepare for xdr_stream-style decoding on the server-side Chuck Lever
2020-11-23 18:49   ` J. Bruce Fields
2020-11-23 18:52     ` Chuck Lever
2020-11-20 20:34 ` [PATCH v2 004/118] NFSD: Add common helpers to decode void args and encode void results Chuck Lever
2020-11-20 20:34 ` [PATCH v2 005/118] NFSD: Replace the internals of the READ_BUF() macro Chuck Lever
2020-11-23 19:18   ` J. Bruce Fields
2020-11-23 19:21     ` Chuck Lever
2020-11-20 20:34 ` [PATCH v2 006/118] NFSD: Replace READ* macros in nfsd4_decode_access() Chuck Lever
2020-11-20 20:34 ` [PATCH v2 007/118] NFSD: Replace READ* macros in nfsd4_decode_stateid() Chuck Lever
2020-11-20 20:34 ` [PATCH v2 008/118] NFSD: Replace READ* macros in nfsd4_decode_close() Chuck Lever
2020-11-20 20:34 ` [PATCH v2 009/118] NFSD: Replace READ* macros in nfsd4_decode_commit() Chuck Lever
2020-11-20 20:34 ` [PATCH v2 010/118] NFSD: Change the way the expected length of a fattr4 is checked Chuck Lever
2020-11-20 20:34 ` [PATCH v2 011/118] NFSD: Replace READ* macros that decode the fattr4 size attribute Chuck Lever
2020-11-20 20:34 ` [PATCH v2 012/118] NFSD: Replace READ* macros that decode the fattr4 acl attribute Chuck Lever
2020-11-20 20:34 ` [PATCH v2 013/118] NFSD: Replace READ* macros that decode the fattr4 mode attribute Chuck Lever
2020-11-20 20:35 ` [PATCH v2 014/118] NFSD: Replace READ* macros that decode the fattr4 owner attribute Chuck Lever
2020-11-20 20:35 ` [PATCH v2 015/118] NFSD: Replace READ* macros that decode the fattr4 owner_group attribute Chuck Lever
2020-11-20 20:35 ` [PATCH v2 016/118] NFSD: Replace READ* macros that decode the fattr4 time_set attributes Chuck Lever
2020-11-20 20:35 ` [PATCH v2 017/118] NFSD: Replace READ* macros that decode the fattr4 security label attribute Chuck Lever
2020-11-20 20:35 ` [PATCH v2 018/118] NFSD: Replace READ* macros that decode the fattr4 umask attribute Chuck Lever
2020-11-20 20:35 ` [PATCH v2 019/118] NFSD: Replace READ* macros in nfsd4_decode_fattr() Chuck Lever
2020-11-20 20:35 ` [PATCH v2 020/118] NFSD: Replace READ* macros in nfsd4_decode_create() Chuck Lever
2020-11-20 20:35 ` [PATCH v2 021/118] NFSD: Replace READ* macros in nfsd4_decode_getattr() Chuck Lever
2020-11-20 20:35 ` [PATCH v2 022/118] NFSD: Replace READ* macros in nfsd4_decode_link() Chuck Lever
2020-11-20 20:35 ` [PATCH v2 023/118] NFSD: Relocate nfsd4_decode_opaque() Chuck Lever
2020-11-20 20:35 ` [PATCH v2 024/118] NFSD: Add helpers to decode a clientid4 and an NFSv4 state owner Chuck Lever
2020-11-20 20:35 ` [PATCH v2 025/118] NFSD: Add helper for decoding locker4 Chuck Lever
2020-11-20 20:36 ` [PATCH v2 026/118] NFSD: Replace READ* macros in nfsd4_decode_lock() Chuck Lever
2020-11-20 20:36 ` [PATCH v2 027/118] NFSD: Replace READ* macros in nfsd4_decode_lockt() Chuck Lever
2020-11-20 20:36 ` [PATCH v2 028/118] NFSD: Replace READ* macros in nfsd4_decode_locku() Chuck Lever
2020-11-20 20:36 ` [PATCH v2 029/118] NFSD: Replace READ* macros in nfsd4_decode_lookup() Chuck Lever
2020-11-20 20:36 ` [PATCH v2 030/118] NFSD: Add helper to decode NFSv4 verifiers Chuck Lever
2020-11-20 20:36 ` [PATCH v2 031/118] NFSD: Add helper to decode OPEN's createhow4 argument Chuck Lever
2020-11-20 20:36 ` [PATCH v2 032/118] NFSD: Add helper to decode OPEN's openflag4 argument Chuck Lever
2020-11-20 20:36 ` [PATCH v2 033/118] NFSD: Replace READ* macros in nfsd4_decode_share_access() Chuck Lever
2020-11-20 20:36 ` [PATCH v2 034/118] NFSD: Replace READ* macros in nfsd4_decode_share_deny() Chuck Lever
2020-11-20 20:36 ` [PATCH v2 035/118] NFSD: Add helper to decode OPEN's open_claim4 argument Chuck Lever
2020-11-20 20:36 ` [PATCH v2 036/118] NFSD: Replace READ* macros in nfsd4_decode_open() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 037/118] NFSD: Replace READ* macros in nfsd4_decode_open_confirm() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 038/118] NFSD: Replace READ* macros in nfsd4_decode_open_downgrade() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 039/118] NFSD: Replace READ* macros in nfsd4_decode_putfh() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 040/118] NFSD: Replace READ* macros in nfsd4_decode_read() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 041/118] NFSD: Replace READ* macros in nfsd4_decode_readdir() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 042/118] NFSD: Replace READ* macros in nfsd4_decode_remove() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 043/118] NFSD: Replace READ* macros in nfsd4_decode_rename() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 044/118] NFSD: Replace READ* macros in nfsd4_decode_renew() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 045/118] NFSD: Replace READ* macros in nfsd4_decode_secinfo() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 046/118] NFSD: Replace READ* macros in nfsd4_decode_setclientid() Chuck Lever
2020-11-20 20:37 ` [PATCH v2 047/118] NFSD: Replace READ* macros in nfsd4_decode_setclientid_confirm() Chuck Lever
2020-11-20 20:38 ` [PATCH v2 048/118] NFSD: Replace READ* macros in nfsd4_decode_verify() Chuck Lever
2020-11-20 20:38 ` [PATCH v2 049/118] NFSD: Replace READ* macros in nfsd4_decode_write() Chuck Lever
2020-11-20 20:38 ` [PATCH v2 050/118] NFSD: Replace READ* macros in nfsd4_decode_release_lockowner() Chuck Lever
2020-11-20 20:38 ` [PATCH v2 051/118] NFSD: Replace READ* macros in nfsd4_decode_cb_sec() Chuck Lever
2020-11-20 20:38 ` [PATCH v2 052/118] NFSD: Replace READ* macros in nfsd4_decode_backchannel_ctl() Chuck Lever
2020-11-20 20:38 ` [PATCH v2 053/118] NFSD: Replace READ* macros in nfsd4_decode_bind_conn_to_session() Chuck Lever
2020-11-20 20:38 ` [PATCH v2 054/118] NFSD: Add a separate decoder to handle state_protect_ops Chuck Lever
2020-11-20 20:38 ` [PATCH v2 055/118] NFSD: Add a separate decoder for ssv_sp_parms Chuck Lever
2020-11-20 20:38 ` [PATCH v2 056/118] NFSD: Add a helper to decode state_protect4_a Chuck Lever
2020-11-20 20:38 ` [PATCH v2 057/118] NFSD: Add a helper to decode nfs_impl_id4 Chuck Lever
2020-11-20 20:38 ` [PATCH v2 058/118] NFSD: Add a helper to decode channel_attrs4 Chuck Lever
2020-11-20 20:38 ` [PATCH v2 059/118] NFSD: Replace READ* macros in nfsd4_decode_create_session() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 060/118] NFSD: Replace READ* macros in nfsd4_decode_destroy_session() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 061/118] NFSD: Replace READ* macros in nfsd4_decode_free_stateid() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 062/118] NFSD: Replace READ* macros in nfsd4_decode_getdeviceinfo() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 063/118] NFSD: Replace READ* macros in nfsd4_decode_layoutcommit() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 064/118] NFSD: Replace READ* macros in nfsd4_decode_layoutget() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 065/118] NFSD: Replace READ* macros in nfsd4_decode_layoutreturn() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 066/118] NFSD: Replace READ* macros in nfsd4_decode_secinfo_no_name() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 067/118] NFSD: Replace READ* macros in nfsd4_decode_sequence() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 068/118] NFSD: Replace READ* macros in nfsd4_decode_test_stateid() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 069/118] NFSD: Replace READ* macros in nfsd4_decode_destroy_clientid() Chuck Lever
2020-11-20 20:39 ` [PATCH v2 070/118] NFSD: Replace READ* macros in nfsd4_decode_reclaim_complete() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 071/118] NFSD: Replace READ* macros in nfsd4_decode_fallocate() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 072/118] NFSD: Replace READ* macros in nfsd4_decode_clone() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 073/118] NFSD: Replace READ* macros in nfsd4_decode_nl4_server() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 074/118] NFSD: Replace READ* macros in nfsd4_decode_copy() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 075/118] NFSD: Replace READ* macros in nfsd4_decode_seek() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 076/118] NFSD: Replace READ* macros in nfsd4_decode_xattr_name() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 077/118] NFSD: Replace READ* macros in nfsd4_decode_setxattr() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 078/118] NFSD: Replace READ* macros in nfsd4_decode_listxattrs() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 079/118] NFSD: Replace READ* macros in nfsd4_decode_compound() Chuck Lever
2020-11-20 20:40 ` [PATCH v2 080/118] NFSD: Remove macros that are no longer used Chuck Lever
2020-11-20 20:40 ` [PATCH v2 081/118] NFSD: Update GETATTR3args decoder to use struct xdr_stream Chuck Lever
2020-11-20 20:41 ` [PATCH v2 082/118] NFSD: Update ACCESS3arg " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 083/118] NFSD: Update READ3arg " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 084/118] NFSD: Update WRITE3arg " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 085/118] NFSD: Update READLINK3arg " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 086/118] NFSD: Add helper to set up the pages where the dirlist is encoded Chuck Lever
2020-11-20 20:41 ` [PATCH v2 087/118] NFSD: Update READDIR3args decoders to use struct xdr_stream Chuck Lever
2020-11-23 20:55   ` J. Bruce Fields
2020-11-20 20:41 ` [PATCH v2 088/118] NFSD: Update COMMIT3arg decoder " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 089/118] NFSD: Update the NFSv3 DIROPargs " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 090/118] NFSD: Update the RENAME3args " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 091/118] NFSD: Update the LINK3args " Chuck Lever
2020-11-20 20:41 ` [PATCH v2 092/118] NFSD: Update the SETATTR3args " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 093/118] NFSD: Update the CREATE3args " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 094/118] NFSD: Update the MKDIR3args " Chuck Lever
2020-11-20 20:42 ` Chuck Lever [this message]
2020-11-20 20:42 ` [PATCH v2 096/118] NFSD: Update the MKNOD3args " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 097/118] NFSD: Update the NFSv2 GETATTR argument " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 098/118] NFSD: Update the NFSv2 READ " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 099/118] NFSD: Update the NFSv2 WRITE " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 100/118] NFSD: Update the NFSv2 READLINK " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 101/118] NFSD: Add helper to set up the pages where the dirlist is encoded Chuck Lever
2020-11-20 20:42 ` [PATCH v2 102/118] NFSD: Update the NFSv2 READDIR argument decoder to use struct xdr_stream Chuck Lever
2020-11-20 20:42 ` [PATCH v2 103/118] NFSD: Update NFSv2 diropargs decoding " Chuck Lever
2020-11-20 20:42 ` [PATCH v2 104/118] NFSD: Update the NFSv2 RENAME argument decoder " Chuck Lever
2020-11-20 20:43 ` [PATCH v2 105/118] NFSD: Update the NFSv2 LINK " Chuck Lever
2020-11-20 20:43 ` [PATCH v2 106/118] NFSD: Update the NFSv2 SETATTR " Chuck Lever
2020-11-20 20:43 ` [PATCH v2 107/118] NFSD: Update the NFSv2 CREATE " Chuck Lever
2020-11-20 20:43 ` [PATCH v2 108/118] NFSD: Update the NFSv2 SYMLINK " Chuck Lever
2020-11-20 20:43 ` [PATCH v2 109/118] NFSD: Remove argument length checking in nfsd_dispatch() Chuck Lever
2020-11-20 20:43 ` [PATCH v2 110/118] NFSD: Update the NFSv2 GETACL argument decoder to use struct xdr_stream Chuck Lever
2020-11-20 20:43 ` [PATCH v2 111/118] NFSD: Add an xdr_stream-based decoder for NFSv2/3 ACLs Chuck Lever
2020-11-20 20:43 ` [PATCH v2 112/118] NFSD: Update the NFSv2 SETACL argument decoder to use struct xdr_stream Chuck Lever
2020-11-20 20:43 ` [PATCH v2 113/118] NFSD: Update the NFSv2 ACL GETATTR " Chuck Lever
2020-11-20 20:43 ` [PATCH v2 114/118] NFSD: Update the NFSv2 ACL ACCESS " Chuck Lever
2020-11-20 20:43 ` [PATCH v2 115/118] NFSD: Clean up after updating NFSv2 ACL decoders Chuck Lever
2020-11-20 20:44 ` [PATCH v2 116/118] NFSD: Update the NFSv3 GETACL argument decoder to use struct xdr_stream Chuck Lever
2020-11-20 20:44 ` [PATCH v2 117/118] NFSD: Update the NFSv2 SETACL " Chuck Lever
2020-11-20 20:44 ` [PATCH v2 118/118] NFSD: Clean up after updating NFSv3 ACL decoders Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=160590493180.1340.14177384748797931925.stgit@klimt.1015granger.net \
    --to=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).