From patchwork Mon Nov 23 20:04:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926201 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E3B6C64E8A for ; Mon, 23 Nov 2020 20:04:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42D7620717 for ; Mon, 23 Nov 2020 20:04:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZRGKBKpv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728078AbgKWUEI (ORCPT ); Mon, 23 Nov 2020 15:04:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41396 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbgKWUEH (ORCPT ); Mon, 23 Nov 2020 15:04:07 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A27F9C0613CF for ; Mon, 23 Nov 2020 12:04:07 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id y18so1894569qki.11 for ; Mon, 23 Nov 2020 12:04:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=HcSb6CUIyEdHtSUSeX0VbJSU8WnCONnxaJpo3aBIQQY=; b=ZRGKBKpvOaO7lbpuBVybrzGv8L7rVLEpT8+09PK0PeMqXHEvSpp0tm7me9QHKYWBYe hHbWmcuVujdVA+lWQFf/hl5jFljIRFkKzBjg3z1YWHh9AzS3VjkHHtVCxM5n3VfexeWu Y5nUoIy3gdxPXPyl1A+QSMBrmzrOr5Ja5tT2xJ1vMegBRtOQ8w96IsgDtc2zJHDsQHLj u7kGEt8eWtGayldKTWHRZtRofxcjq7OkqEx6xfCrKTme6Uyqmh1wiu3DINkDxlEK7+/N 3z6RnNcBBBHDjPhdSMoLcPQGjFOF0HSE9OjevoT/RY3uOOehiX/d82CQ+q3VdXXdIx6B IG0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=HcSb6CUIyEdHtSUSeX0VbJSU8WnCONnxaJpo3aBIQQY=; b=dCKB/o8z/2s8RvfMcLYkx92i1NFPvYdO9fOoDBpJ4PggygKIkfwHv5ZM0+G8A/6Hrq 4At43MTSS3LWXrkbRPcpLMKxnAAFjDGwULmXvdU10vYrZiMgv1vkJuPsiM9e5nh+c8T4 SvqIrLb+j/gkOpcU2yGY8diEKFiO9vfVBl/918vRNZDlAjRGG+VKqDuqm9L4M5umkTWj 2I3B5OeRgMvFJECMBEnKXFke86QqbAFZRWj9B83L3ZMgFCrnaUzVrT5BxfQWEWfRG6j5 M1ieziBa7P7j65Zc/z41iklxqTHm9QsVJmiPBYeKZ4RF3AlWTI/i7UEoyHVPD+aXqJJB idNA== X-Gm-Message-State: AOAM533202lGKQZStk/2Fkn+RsDsm8xImg0GA7iRHNL8U65ehZWgTZt8 i16hvAvO5X0CcekOKMXcBqOjC5Mzk14= X-Google-Smtp-Source: ABdhPJwR/Ao+ThIGBQZ0CqxNB97j/JpJwScFyMpbifgEMU++rYWl7W1Oow1ZtidsV+WFEh5QTGwDVg== X-Received: by 2002:a37:6c41:: with SMTP id h62mr1209233qkc.401.1606161846273; Mon, 23 Nov 2020 12:04:06 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id i21sm10243140qtm.1.2020.11.23.12.04.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:04:05 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK44hl010269 for ; Mon, 23 Nov 2020 20:04:04 GMT Subject: [PATCH v3 01/85] SUNRPC: Add xdr_set_scratch_page() and xdr_reset_scratch_buffer() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:04:04 -0500 Message-ID: <160616184452.51996.9922379919062613933.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Clean up: De-duplicate some frequently-used code. Signed-off-by: Chuck Lever --- fs/nfs/blocklayout/blocklayout.c | 2 + fs/nfs/blocklayout/dev.c | 2 + fs/nfs/dir.c | 2 + fs/nfs/filelayout/filelayout.c | 2 + fs/nfs/filelayout/filelayoutdev.c | 2 + fs/nfs/flexfilelayout/flexfilelayout.c | 2 + fs/nfs/flexfilelayout/flexfilelayoutdev.c | 2 + fs/nfs/nfs42xdr.c | 2 + fs/nfs/nfs4xdr.c | 6 +--- fs/nfsd/nfs4proc.c | 2 + include/linux/sunrpc/xdr.h | 44 ++++++++++++++++++++++++++++- net/sunrpc/auth_gss/gss_rpc_xdr.c | 2 + net/sunrpc/xdr.c | 28 +++--------------- 13 files changed, 59 insertions(+), 39 deletions(-) diff --git a/fs/nfs/blocklayout/blocklayout.c b/fs/nfs/blocklayout/blocklayout.c index 08108b6d2fa1..3be6836074ae 100644 --- a/fs/nfs/blocklayout/blocklayout.c +++ b/fs/nfs/blocklayout/blocklayout.c @@ -697,7 +697,7 @@ bl_alloc_lseg(struct pnfs_layout_hdr *lo, struct nfs4_layoutget_res *lgr, xdr_init_decode_pages(&xdr, &buf, lgr->layoutp->pages, lgr->layoutp->len); - xdr_set_scratch_buffer(&xdr, page_address(scratch), PAGE_SIZE); + xdr_set_scratch_page(&xdr, scratch); status = -EIO; p = xdr_inline_decode(&xdr, 4); diff --git a/fs/nfs/blocklayout/dev.c b/fs/nfs/blocklayout/dev.c index dec5880ac6de..acb1d22907da 100644 --- a/fs/nfs/blocklayout/dev.c +++ b/fs/nfs/blocklayout/dev.c @@ -510,7 +510,7 @@ bl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, goto out; xdr_init_decode_pages(&xdr, &buf, pdev->pages, pdev->pglen); - xdr_set_scratch_buffer(&xdr, page_address(scratch), PAGE_SIZE); + xdr_set_scratch_page(&xdr, scratch); p = xdr_inline_decode(&xdr, sizeof(__be32)); if (!p) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 4e011adaf967..8a24fe20dccf 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -576,7 +576,7 @@ int nfs_readdir_page_filler(nfs_readdir_descriptor_t *desc, struct nfs_entry *en goto out_nopages; xdr_init_decode_pages(&stream, &buf, xdr_pages, buflen); - xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE); + xdr_set_scratch_page(&stream, scratch); do { if (entry->label) diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c index 7f5aa0403e16..d158a500c25c 100644 --- a/fs/nfs/filelayout/filelayout.c +++ b/fs/nfs/filelayout/filelayout.c @@ -666,7 +666,7 @@ filelayout_decode_layout(struct pnfs_layout_hdr *flo, return -ENOMEM; xdr_init_decode_pages(&stream, &buf, lgr->layoutp->pages, lgr->layoutp->len); - xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE); + xdr_set_scratch_page(&stream, scratch); /* 20 = ufl_util (4), first_stripe_index (4), pattern_offset (8), * num_fh (4) */ diff --git a/fs/nfs/filelayout/filelayoutdev.c b/fs/nfs/filelayout/filelayoutdev.c index d913e818858f..86c3f7e69ec4 100644 --- a/fs/nfs/filelayout/filelayoutdev.c +++ b/fs/nfs/filelayout/filelayoutdev.c @@ -82,7 +82,7 @@ nfs4_fl_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, goto out_err; xdr_init_decode_pages(&stream, &buf, pdev->pages, pdev->pglen); - xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE); + xdr_set_scratch_page(&stream, scratch); /* Get the stripe count (number of stripe index) */ p = xdr_inline_decode(&stream, 4); diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index a163533446fa..d7010686d39a 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c @@ -378,7 +378,7 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh, xdr_init_decode_pages(&stream, &buf, lgr->layoutp->pages, lgr->layoutp->len); - xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE); + xdr_set_scratch_page(&stream, scratch); /* stripe unit and mirror_array_cnt */ rc = -EIO; diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c index 3eda40a320a5..c9b61b818ec1 100644 --- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c +++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c @@ -69,7 +69,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, INIT_LIST_HEAD(&dsaddrs); xdr_init_decode_pages(&stream, &buf, pdev->pages, pdev->pglen); - xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE); + xdr_set_scratch_page(&stream, scratch); /* multipath count */ p = xdr_inline_decode(&stream, 4); diff --git a/fs/nfs/nfs42xdr.c b/fs/nfs/nfs42xdr.c index 6e060a88f98c..cb5d4da2308f 100644 --- a/fs/nfs/nfs42xdr.c +++ b/fs/nfs/nfs42xdr.c @@ -1540,7 +1540,7 @@ static int nfs4_xdr_dec_listxattrs(struct rpc_rqst *rqstp, struct compound_hdr hdr; int status; - xdr_set_scratch_buffer(xdr, page_address(res->scratch), PAGE_SIZE); + xdr_set_scratch_page(xdr, res->scratch); status = decode_compound_hdr(xdr, &hdr); if (status) diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c index c6dbfcae7517..2eabe5add344 100644 --- a/fs/nfs/nfs4xdr.c +++ b/fs/nfs/nfs4xdr.c @@ -6403,10 +6403,8 @@ nfs4_xdr_dec_getacl(struct rpc_rqst *rqstp, struct xdr_stream *xdr, struct compound_hdr hdr; int status; - if (res->acl_scratch != NULL) { - void *p = page_address(res->acl_scratch); - xdr_set_scratch_buffer(xdr, p, PAGE_SIZE); - } + if (res->acl_scratch != NULL) + xdr_set_scratch_page(xdr, res->acl_scratch); status = decode_compound_hdr(xdr, &hdr); if (status) goto out; diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index e83b21778816..20772f6b0b2d 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -2276,7 +2276,7 @@ static void svcxdr_init_encode(struct svc_rqst *rqstp, xdr->end = head->iov_base + PAGE_SIZE - rqstp->rq_auth_slack; /* Tail and page_len should be zero at this point: */ buf->len = buf->head[0].iov_len; - xdr->scratch.iov_len = 0; + xdr_reset_scratch_buffer(xdr); xdr->page_ptr = buf->pages - 1; buf->buflen = PAGE_SIZE * (1 + rqstp->rq_page_end - buf->pages) - rqstp->rq_auth_slack; diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index ec2a22ccdc2a..2729d2d6efce 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -248,7 +248,6 @@ extern void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p, struct rpc_rqst *rqst); extern void xdr_init_decode_pages(struct xdr_stream *xdr, struct xdr_buf *buf, struct page **pages, unsigned int len); -extern void xdr_set_scratch_buffer(struct xdr_stream *xdr, void *buf, size_t buflen); extern __be32 *xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes); extern unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len); extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len); @@ -256,6 +255,49 @@ extern int xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned in extern uint64_t xdr_align_data(struct xdr_stream *, uint64_t, uint32_t); extern uint64_t xdr_expand_hole(struct xdr_stream *, uint64_t, uint64_t); +/** + * xdr_set_scratch_buffer - Attach a scratch buffer for decoding data. + * @xdr: pointer to xdr_stream struct + * @buf: pointer to an empty buffer + * @buflen: size of 'buf' + * + * The scratch buffer is used when decoding from an array of pages. + * If an xdr_inline_decode() call spans across page boundaries, then + * we copy the data into the scratch buffer in order to allow linear + * access. + */ +static inline void +xdr_set_scratch_buffer(struct xdr_stream *xdr, void *buf, size_t buflen) +{ + xdr->scratch.iov_base = buf; + xdr->scratch.iov_len = buflen; +} + +/** + * xdr_set_scratch_page - Attach a scratch buffer for decoding data + * @xdr: pointer to xdr_stream struct + * @page: an anonymous page + * + * See xdr_set_scratch_buffer(). + */ +static inline void +xdr_set_scratch_page(struct xdr_stream *xdr, struct page *page) +{ + xdr_set_scratch_buffer(xdr, page_address(page), PAGE_SIZE); +} + +/** + * xdr_reset_scratch_buffer - Clear scratch buffer information + * @xdr: pointer to xdr_stream struct + * + * See xdr_set_scratch_buffer(). + */ +static inline void +xdr_reset_scratch_buffer(struct xdr_stream *xdr) +{ + xdr_set_scratch_buffer(xdr, NULL, 0); +} + /** * xdr_stream_remaining - Return the number of bytes remaining in the stream * @xdr: pointer to struct xdr_stream diff --git a/net/sunrpc/auth_gss/gss_rpc_xdr.c b/net/sunrpc/auth_gss/gss_rpc_xdr.c index 2ff7b7083eba..c636c648849b 100644 --- a/net/sunrpc/auth_gss/gss_rpc_xdr.c +++ b/net/sunrpc/auth_gss/gss_rpc_xdr.c @@ -789,7 +789,7 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp, scratch = alloc_page(GFP_KERNEL); if (!scratch) return -ENOMEM; - xdr_set_scratch_buffer(xdr, page_address(scratch), PAGE_SIZE); + xdr_set_scratch_page(xdr, scratch); /* res->status */ err = gssx_dec_status(xdr, &res->status); diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 28f81769a27c..c607744b3ea8 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -669,7 +669,7 @@ void xdr_init_encode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p, struct kvec *iov = buf->head; int scratch_len = buf->buflen - buf->page_len - buf->tail[0].iov_len; - xdr_set_scratch_buffer(xdr, NULL, 0); + xdr_reset_scratch_buffer(xdr); BUG_ON(scratch_len < 0); xdr->buf = buf; xdr->iov = iov; @@ -713,7 +713,7 @@ inline void xdr_commit_encode(struct xdr_stream *xdr) page = page_address(*xdr->page_ptr); memcpy(xdr->scratch.iov_base, page, shift); memmove(page, page + shift, (void *)xdr->p - page); - xdr->scratch.iov_len = 0; + xdr_reset_scratch_buffer(xdr); } EXPORT_SYMBOL_GPL(xdr_commit_encode); @@ -743,8 +743,7 @@ static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr, * the "scratch" iov to track any temporarily unused fragment of * space at the end of the previous buffer: */ - xdr->scratch.iov_base = xdr->p; - xdr->scratch.iov_len = frag1bytes; + xdr_set_scratch_buffer(xdr, xdr->p, frag1bytes); p = page_address(*xdr->page_ptr); /* * Note this is where the next encode will start after we've @@ -1052,8 +1051,7 @@ void xdr_init_decode(struct xdr_stream *xdr, struct xdr_buf *buf, __be32 *p, struct rpc_rqst *rqst) { xdr->buf = buf; - xdr->scratch.iov_base = NULL; - xdr->scratch.iov_len = 0; + xdr_reset_scratch_buffer(xdr); xdr->nwords = XDR_QUADLEN(buf->len); if (buf->head[0].iov_len != 0) xdr_set_iov(xdr, buf->head, buf->len); @@ -1101,24 +1099,6 @@ static __be32 * __xdr_inline_decode(struct xdr_stream *xdr, size_t nbytes) return p; } -/** - * xdr_set_scratch_buffer - Attach a scratch buffer for decoding data. - * @xdr: pointer to xdr_stream struct - * @buf: pointer to an empty buffer - * @buflen: size of 'buf' - * - * The scratch buffer is used when decoding from an array of pages. - * If an xdr_inline_decode() call spans across page boundaries, then - * we copy the data into the scratch buffer in order to allow linear - * access. - */ -void xdr_set_scratch_buffer(struct xdr_stream *xdr, void *buf, size_t buflen) -{ - xdr->scratch.iov_base = buf; - xdr->scratch.iov_len = buflen; -} -EXPORT_SYMBOL_GPL(xdr_set_scratch_buffer); - static __be32 *xdr_copy_to_scratch(struct xdr_stream *xdr, size_t nbytes) { __be32 *p; From patchwork Mon Nov 23 20:04:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926199 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 608F8C6379D for ; Mon, 23 Nov 2020 20:04:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0ABC820721 for ; Mon, 23 Nov 2020 20:04:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vGOgrm9i" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728361AbgKWUEN (ORCPT ); Mon, 23 Nov 2020 15:04:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbgKWUEM (ORCPT ); Mon, 23 Nov 2020 15:04:12 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2748C0613CF for ; Mon, 23 Nov 2020 12:04:12 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id y197so18220855qkb.7 for ; Mon, 23 Nov 2020 12:04:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=eQANfuwWnOSHuC60MvPAFAvRrM9IVrY6VIQgnRQZKF0=; b=vGOgrm9iAsOWUoJ1vxKRoDEQaixN98Wp7N13RwTj8LJT4fwg+Pdnuym9dVanxoju0S N326oBgnGlX8usf1LbhRVXnx43Rojk/dEnOZRrQeUdcSlqFkCxn9Up8QrJLNEF429Y/T JeT40eQ3UvkmXi9920y4+HRQCgY0lvwngCNQTIeunMSlYKqGgTZ3i8LjlY+mKKJxdUr8 TsPY8gvzfNTrwFu5gbLsLB0iiuqoSP244AyoiZ8yaQmMkgcCFsjw54mgEGhxOeltph0r 3N7J09yUNCK9KhCRVtIrju9oIicqWSJ0GGzxl2LIc8wceYswNYNYPqzsUlEzB26cCFMZ Ezhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=eQANfuwWnOSHuC60MvPAFAvRrM9IVrY6VIQgnRQZKF0=; b=uA8t7EIVLLDKffvUEaDoVgqThRsJLafSJVQiBPVClycD5v/A8zRoWTdj8qJ535y9GI Y/l8XofSSjXel7UCTKv7NKCLLtLAOeO2JfzdGdRExiP/bIXFv0EythFQBFmwqqKYia3T HUX0AUnVhQrZVJgYUmpeKcQqNIPyMrvC2rj9mZ21CZQH7iH0dlLwVakMqc3O2Nr8KfSb QrZFheRip/zi1ZY6acrw+fMGqX3Y6C6cPB0AozGeD2iFLDDac3IJS9fGhkdgvHovZXve ZtUr5ipkPMTacYs1CWBZ1bHJq5yLih+KrAmDR3G40USVdrvNSViNvvDJsUBGkSUglADg gFng== X-Gm-Message-State: AOAM533QGNbd7hgSUrKeiac3UtIE01xmAR1lcRA2IpVmuIrd2x75tztR GaNk4xcoiOlBOB/D65tERvWb4ZlEeS8= X-Google-Smtp-Source: ABdhPJwlhef5wc9IRUodJOhcw74qyHokfaXTgCpWSg28VelcOZU67fTyS0LU8wrtv+gYnSada5sAdA== X-Received: by 2002:ae9:d604:: with SMTP id r4mr1279514qkk.32.1606161851565; Mon, 23 Nov 2020 12:04:11 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id s23sm9898676qke.11.2020.11.23.12.04.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:04:10 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK490G010272 for ; Mon, 23 Nov 2020 20:04:09 GMT Subject: [PATCH v3 02/85] SUNRPC: Prepare for xdr_stream-style decoding on the server-side From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:04:09 -0500 Message-ID: <160616184984.51996.13364904743048575286.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org A "permanent" struct xdr_stream is allocated in struct svc_rqst so that it is usable by all server-side decoders. A per-rqst scratch buffer is also allocated to handle decoding XDR data items that cross page boundaries. To demonstrate how it will be used, add the first call site for the new svcxdr_init_decode() API. As an additional part of the overall conversion, add symbolic constants for successful and failed XDR operations. Returning "0" is overloaded. Sometimes it means something failed, but sometimes it means success. To make it more clear when XDR decoding functions succeed or fail, introduce symbolic constants. Signed-off-by: Chuck Lever --- fs/nfsd/nfssvc.c | 2 ++ include/linux/sunrpc/svc.h | 16 ++++++++++++++++ net/sunrpc/svc.c | 5 +++++ 3 files changed, 23 insertions(+) diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 27b1ad136150..3fac172600ac 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -1020,6 +1020,8 @@ int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp) * (necessary in the NFSv4.0 compound case) */ rqstp->rq_cachetype = proc->pc_cachetype; + + svcxdr_init_decode(rqstp, argv->iov_base); if (!proc->pc_decode(rqstp, argv->iov_base)) goto out_decode_err; diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index c220b734fa69..bb6c93283697 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -248,6 +248,8 @@ struct svc_rqst { size_t rq_xprt_hlen; /* xprt header len */ struct xdr_buf rq_arg; struct xdr_buf rq_res; + struct xdr_stream rq_xdr_stream; + struct page *rq_scratch_page; struct page *rq_pages[RPCSVC_MAXPAGES + 1]; struct page * *rq_respages; /* points into rq_pages */ struct page * *rq_next_page; /* next reply page to use */ @@ -557,4 +559,18 @@ static inline void svc_reserve_auth(struct svc_rqst *rqstp, int space) svc_reserve(rqstp, space + rqstp->rq_auth_slack); } +/** + * svcxdr_init_decode - Prepare an xdr_stream for svc Call decoding + * @rqstp: controlling server RPC transaction context + * @p: Starting position + * + */ +static inline void svcxdr_init_decode(struct svc_rqst *rqstp, __be32 *p) +{ + struct xdr_stream *xdr = &rqstp->rq_xdr_stream; + + xdr_init_decode(xdr, &rqstp->rq_arg, p, NULL); + xdr_set_scratch_page(xdr, rqstp->rq_scratch_page); +} + #endif /* SUNRPC_SVC_H */ diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index b41500645c3f..4187745887f0 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -614,6 +614,10 @@ svc_rqst_alloc(struct svc_serv *serv, struct svc_pool *pool, int node) rqstp->rq_server = serv; rqstp->rq_pool = pool; + rqstp->rq_scratch_page = alloc_pages_node(node, GFP_KERNEL, 0); + if (!rqstp->rq_scratch_page) + goto out_enomem; + rqstp->rq_argp = kmalloc_node(serv->sv_xdrsize, GFP_KERNEL, node); if (!rqstp->rq_argp) goto out_enomem; @@ -842,6 +846,7 @@ void svc_rqst_free(struct svc_rqst *rqstp) { svc_release_buffer(rqstp); + put_page(rqstp->rq_scratch_page); kfree(rqstp->rq_resp); kfree(rqstp->rq_argp); kfree(rqstp->rq_auth_data); From patchwork Mon Nov 23 20:04:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926203 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8511CC83012 for ; Mon, 23 Nov 2020 20:04:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42E3620724 for ; Mon, 23 Nov 2020 20:04:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DFcxJ1uO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728419AbgKWUEU (ORCPT ); Mon, 23 Nov 2020 15:04:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbgKWUES (ORCPT ); Mon, 23 Nov 2020 15:04:18 -0500 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83E54C0613CF for ; Mon, 23 Nov 2020 12:04:18 -0800 (PST) Received: by mail-qv1-xf43.google.com with SMTP id p12so7252046qvj.13 for ; Mon, 23 Nov 2020 12:04:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=WqZPqx+yNlg7M39WK6DrTIRZO9hQ702+J8YXXZcD/o8=; b=DFcxJ1uOfb54DdEpjgyJSNSSmeywbRZaxv0u4t04/4kCg8QPhBVtvoqzynoWXfVXBt YD04JTPh/V33JMkRJiDu7VBIwxtI0u4fyqRIX8E2MRRJJxvdBnA7UOwfbAWrIVbWiyYu 81gwLKRIYw4wUKExMEfRZZAm99jup/xkEYY6QOfrMNiSOmT4ebMJoQRMz4JKGyapigRL wydns8F2iFkVgkh/SB3V9pD3LNUJGmk+aWxkjdn/hOYI5GQVva2JdZ0t4aLTw3usbnEg T6aW74ir/6rBfpNNzdEMhqXLSXrWJOfkbUQka5R/RXjwDxDiRwwx0aejpjeFFL32ga6O qeUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=WqZPqx+yNlg7M39WK6DrTIRZO9hQ702+J8YXXZcD/o8=; b=c3KF7b1o3X2WhTPOQvIpoEBhOCko6accjgrd5lUlah0Fuig/W7S6EH8eKzZsCEU6BO Ur3NrjOfw8cFXqH81ZXRZsysBMKIyoKBdZ9RR+WqNH/LNAcFZu53TYB4XvtG1vmdaoX6 UFmQpX00b2lGBbkyOq/gLQRroxA/lyl2TaSEP+kueRVyJtiE2zdkKSAjzroZtg5/XOG9 iqit0LI9OiA9H/uYaFbRGgJzjbSXB7q1NTzBOohh0sZcsMAOkh9kdrhbejGMDuccA6sp dQFw0IdRjUTabuy3amifMP5lckO4Swk0PshwCeACvEgQO1Oy2sH+qnHrczPe/oSCEVf7 +pgg== X-Gm-Message-State: AOAM531HN0f4fhbqkAgiCBZAA0QTzLbOVm+uoEo7kZ2CxtoHPcKcbrlM OO5/TLbDTxj0nPEioxcSZNnnHQvY40k= X-Google-Smtp-Source: ABdhPJxL6D/TTukh4m4slOGagOu1Ga73udb/xcKkZ5uO8SnjHY7QzLLkUfMweEucRpHPPHMsLqwnBg== X-Received: by 2002:ad4:5762:: with SMTP id r2mr1000817qvx.45.1606161857206; Mon, 23 Nov 2020 12:04:17 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id p128sm6167476qkc.47.2020.11.23.12.04.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:04:16 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK4FsR010276 for ; Mon, 23 Nov 2020 20:04:15 GMT Subject: [PATCH v3 03/85] NFSD: Add common helpers to decode void args and encode void results From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:04:15 -0500 Message-ID: <160616185513.51996.5294904003222661494.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Start off the conversion to xdr_stream by de-duplicating the functions that decode void arguments and encode void results. Signed-off-by: Chuck Lever --- fs/nfsd/nfs2acl.c | 21 ++++----------------- fs/nfsd/nfs3acl.c | 8 ++++---- fs/nfsd/nfs3proc.c | 10 ++++------ fs/nfsd/nfs3xdr.c | 11 ----------- fs/nfsd/nfs4proc.c | 11 ++++------- fs/nfsd/nfs4xdr.c | 12 ------------ fs/nfsd/nfsd.h | 8 ++++++++ fs/nfsd/nfsproc.c | 25 ++++++++++++------------- fs/nfsd/nfssvc.c | 28 ++++++++++++++++++++++++++++ fs/nfsd/nfsxdr.c | 10 ---------- fs/nfsd/xdr.h | 2 -- fs/nfsd/xdr3.h | 2 -- fs/nfsd/xdr4.h | 2 -- 13 files changed, 64 insertions(+), 86 deletions(-) diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c index 6a900f770dd2..b0f66604532a 100644 --- a/fs/nfsd/nfs2acl.c +++ b/fs/nfsd/nfs2acl.c @@ -185,10 +185,6 @@ static __be32 nfsacld_proc_access(struct svc_rqst *rqstp) /* * XDR decode functions */ -static int nfsaclsvc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p) -{ - return 1; -} static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p) { @@ -255,15 +251,6 @@ static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p) * XDR encode functions */ -/* - * There must be an encoding function for void results so svc_process - * will work properly. - */ -static int nfsaclsvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p) -{ - return xdr_ressize_check(rqstp, p); -} - /* GETACL */ static int nfsaclsvc_encode_getaclres(struct svc_rqst *rqstp, __be32 *p) { @@ -378,10 +365,10 @@ struct nfsd3_voidargs { int dummy; }; static const struct svc_procedure nfsd_acl_procedures2[5] = { [ACLPROC2_NULL] = { .pc_func = nfsacld_proc_null, - .pc_decode = nfsaclsvc_decode_voidarg, - .pc_encode = nfsaclsvc_encode_voidres, - .pc_argsize = sizeof(struct nfsd3_voidargs), - .pc_ressize = sizeof(struct nfsd3_voidargs), + .pc_decode = nfssvc_decode_voidarg, + .pc_encode = nfssvc_encode_voidres, + .pc_argsize = sizeof(struct nfsd_voidargs), + .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST, }, diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c index 34a394e50e1d..7c30876a31a1 100644 --- a/fs/nfsd/nfs3acl.c +++ b/fs/nfsd/nfs3acl.c @@ -245,10 +245,10 @@ struct nfsd3_voidargs { int dummy; }; static const struct svc_procedure nfsd_acl_procedures3[3] = { [ACLPROC3_NULL] = { .pc_func = nfsd3_proc_null, - .pc_decode = nfs3svc_decode_voidarg, - .pc_encode = nfs3svc_encode_voidres, - .pc_argsize = sizeof(struct nfsd3_voidargs), - .pc_ressize = sizeof(struct nfsd3_voidargs), + .pc_decode = nfssvc_decode_voidarg, + .pc_encode = nfssvc_encode_voidres, + .pc_argsize = sizeof(struct nfsd_voidargs), + .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST, }, diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index d9be589fed15..76931f4f57c3 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -692,8 +692,6 @@ nfsd3_proc_commit(struct svc_rqst *rqstp) #define nfsd3_attrstatres nfsd3_attrstat #define nfsd3_wccstatres nfsd3_attrstat #define nfsd3_createres nfsd3_diropres -#define nfsd3_voidres nfsd3_voidargs -struct nfsd3_voidargs { int dummy; }; #define ST 1 /* status*/ #define FH 17 /* filehandle with length */ @@ -704,10 +702,10 @@ struct nfsd3_voidargs { int dummy; }; static const struct svc_procedure nfsd_procedures3[22] = { [NFS3PROC_NULL] = { .pc_func = nfsd3_proc_null, - .pc_decode = nfs3svc_decode_voidarg, - .pc_encode = nfs3svc_encode_voidres, - .pc_argsize = sizeof(struct nfsd3_voidargs), - .pc_ressize = sizeof(struct nfsd3_voidres), + .pc_decode = nfssvc_decode_voidarg, + .pc_encode = nfssvc_encode_voidres, + .pc_argsize = sizeof(struct nfsd_voidargs), + .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST, }, diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 186b07a72373..a6718b952975 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -304,11 +304,6 @@ void fill_post_wcc(struct svc_fh *fhp) /* * XDR decode functions */ -int -nfs3svc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p) -{ - return 1; -} int nfs3svc_decode_fhandle(struct svc_rqst *rqstp, __be32 *p) @@ -642,12 +637,6 @@ nfs3svc_decode_commitargs(struct svc_rqst *rqstp, __be32 *p) * XDR encode functions */ -int -nfs3svc_encode_voidres(struct svc_rqst *rqstp, __be32 *p) -{ - return xdr_ressize_check(rqstp, p); -} - /* GETATTR */ int nfs3svc_encode_attrstat(struct svc_rqst *rqstp, __be32 *p) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 20772f6b0b2d..76300b0441f0 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -3295,16 +3295,13 @@ static const char *nfsd4_op_name(unsigned opnum) return "unknown_operation"; } -#define nfsd4_voidres nfsd4_voidargs -struct nfsd4_voidargs { int dummy; }; - static const struct svc_procedure nfsd_procedures4[2] = { [NFSPROC4_NULL] = { .pc_func = nfsd4_proc_null, - .pc_decode = nfs4svc_decode_voidarg, - .pc_encode = nfs4svc_encode_voidres, - .pc_argsize = sizeof(struct nfsd4_voidargs), - .pc_ressize = sizeof(struct nfsd4_voidres), + .pc_decode = nfssvc_decode_voidarg, + .pc_encode = nfssvc_encode_voidres, + .pc_argsize = sizeof(struct nfsd_voidargs), + .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = 1, }, diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index e3c6bea83bd6..86a149ce0e84 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -5271,12 +5271,6 @@ nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op) p = xdr_encode_opaque_fixed(p, rp->rp_buf, rp->rp_buflen); } -int -nfs4svc_encode_voidres(struct svc_rqst *rqstp, __be32 *p) -{ - return xdr_ressize_check(rqstp, p); -} - void nfsd4_release_compoundargs(struct svc_rqst *rqstp) { struct nfsd4_compoundargs *args = rqstp->rq_argp; @@ -5294,12 +5288,6 @@ void nfsd4_release_compoundargs(struct svc_rqst *rqstp) } } -int -nfs4svc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p) -{ - return 1; -} - int nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p) { diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h index cb742e17e04a..7907de3f2ee6 100644 --- a/fs/nfsd/nfsd.h +++ b/fs/nfsd/nfsd.h @@ -73,6 +73,14 @@ extern unsigned long nfsd_drc_mem_used; extern const struct seq_operations nfs_exports_op; +/* + * Common void argument and result helpers + */ +struct nfsd_voidargs { }; +struct nfsd_voidres { }; +int nfssvc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p); +int nfssvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p); + /* * Function prototypes. */ diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index 0d71549f9d42..9473d048efec 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -609,7 +609,6 @@ nfsd_proc_statfs(struct svc_rqst *rqstp) * NFSv2 Server procedures. * Only the results of non-idempotent operations are cached. */ -struct nfsd_void { int dummy; }; #define ST 1 /* status */ #define FH 8 /* filehandle */ @@ -618,10 +617,10 @@ struct nfsd_void { int dummy; }; static const struct svc_procedure nfsd_procedures2[18] = { [NFSPROC_NULL] = { .pc_func = nfsd_proc_null, - .pc_decode = nfssvc_decode_void, - .pc_encode = nfssvc_encode_void, - .pc_argsize = sizeof(struct nfsd_void), - .pc_ressize = sizeof(struct nfsd_void), + .pc_decode = nfssvc_decode_voidarg, + .pc_encode = nfssvc_encode_voidres, + .pc_argsize = sizeof(struct nfsd_voidargs), + .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = 0, }, @@ -647,10 +646,10 @@ static const struct svc_procedure nfsd_procedures2[18] = { }, [NFSPROC_ROOT] = { .pc_func = nfsd_proc_root, - .pc_decode = nfssvc_decode_void, - .pc_encode = nfssvc_encode_void, - .pc_argsize = sizeof(struct nfsd_void), - .pc_ressize = sizeof(struct nfsd_void), + .pc_decode = nfssvc_decode_voidarg, + .pc_encode = nfssvc_encode_voidres, + .pc_argsize = sizeof(struct nfsd_voidargs), + .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = 0, }, @@ -685,10 +684,10 @@ static const struct svc_procedure nfsd_procedures2[18] = { }, [NFSPROC_WRITECACHE] = { .pc_func = nfsd_proc_writecache, - .pc_decode = nfssvc_decode_void, - .pc_encode = nfssvc_encode_void, - .pc_argsize = sizeof(struct nfsd_void), - .pc_ressize = sizeof(struct nfsd_void), + .pc_decode = nfssvc_decode_voidarg, + .pc_encode = nfssvc_encode_voidres, + .pc_argsize = sizeof(struct nfsd_voidargs), + .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = 0, }, diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 3fac172600ac..c4c646f25f1c 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -1075,6 +1075,34 @@ int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp) return 1; } +/** + * nfssvc_decode_voidarg - Decode void arguments + * @rqstp: Server RPC transaction context + * @p: buffer containing arguments to decode + * + * Return values: + * %0: Arguments were not valid + * %1: Decoding was successful + */ +int nfssvc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p) +{ + return 1; +} + +/** + * nfssvc_encode_voidres - Encode void results + * @rqstp: Server RPC transaction context + * @p: buffer in which to encode results + * + * Return values: + * %0: Local error while encoding + * %1: Encoding was successful + */ +int nfssvc_encode_voidres(struct svc_rqst *rqstp, __be32 *p) +{ + return xdr_ressize_check(rqstp, p); +} + int nfsd_pool_stats_open(struct inode *inode, struct file *file) { int ret; diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index 9e00a902113e..7aa6e8aca2c1 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -192,11 +192,6 @@ __be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *f /* * XDR decode functions */ -int -nfssvc_decode_void(struct svc_rqst *rqstp, __be32 *p) -{ - return xdr_argsize_check(rqstp, p); -} int nfssvc_decode_fhandle(struct svc_rqst *rqstp, __be32 *p) @@ -423,11 +418,6 @@ nfssvc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p) /* * XDR encode functions */ -int -nfssvc_encode_void(struct svc_rqst *rqstp, __be32 *p) -{ - return xdr_ressize_check(rqstp, p); -} int nfssvc_encode_stat(struct svc_rqst *rqstp, __be32 *p) diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h index 0ff336b0b25f..ad77387734cc 100644 --- a/fs/nfsd/xdr.h +++ b/fs/nfsd/xdr.h @@ -144,7 +144,6 @@ union nfsd_xdrstore { #define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore) -int nfssvc_decode_void(struct svc_rqst *, __be32 *); int nfssvc_decode_fhandle(struct svc_rqst *, __be32 *); int nfssvc_decode_sattrargs(struct svc_rqst *, __be32 *); int nfssvc_decode_diropargs(struct svc_rqst *, __be32 *); @@ -156,7 +155,6 @@ int nfssvc_decode_readlinkargs(struct svc_rqst *, __be32 *); int nfssvc_decode_linkargs(struct svc_rqst *, __be32 *); int nfssvc_decode_symlinkargs(struct svc_rqst *, __be32 *); int nfssvc_decode_readdirargs(struct svc_rqst *, __be32 *); -int nfssvc_encode_void(struct svc_rqst *, __be32 *); int nfssvc_encode_stat(struct svc_rqst *, __be32 *); int nfssvc_encode_attrstat(struct svc_rqst *, __be32 *); int nfssvc_encode_diropres(struct svc_rqst *, __be32 *); diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h index ae6fa6c9cb46..456fcd7a1038 100644 --- a/fs/nfsd/xdr3.h +++ b/fs/nfsd/xdr3.h @@ -273,7 +273,6 @@ union nfsd3_xdrstore { #define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore) -int nfs3svc_decode_voidarg(struct svc_rqst *, __be32 *); int nfs3svc_decode_fhandle(struct svc_rqst *, __be32 *); int nfs3svc_decode_sattrargs(struct svc_rqst *, __be32 *); int nfs3svc_decode_diropargs(struct svc_rqst *, __be32 *); @@ -290,7 +289,6 @@ int nfs3svc_decode_symlinkargs(struct svc_rqst *, __be32 *); int nfs3svc_decode_readdirargs(struct svc_rqst *, __be32 *); int nfs3svc_decode_readdirplusargs(struct svc_rqst *, __be32 *); int nfs3svc_decode_commitargs(struct svc_rqst *, __be32 *); -int nfs3svc_encode_voidres(struct svc_rqst *, __be32 *); int nfs3svc_encode_attrstat(struct svc_rqst *, __be32 *); int nfs3svc_encode_wccstat(struct svc_rqst *, __be32 *); int nfs3svc_encode_diropres(struct svc_rqst *, __be32 *); diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 679d40af1bbb..37f89ad5e992 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -781,8 +781,6 @@ set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp) bool nfsd4_mach_creds_match(struct nfs4_client *cl, struct svc_rqst *rqstp); -int nfs4svc_decode_voidarg(struct svc_rqst *, __be32 *); -int nfs4svc_encode_voidres(struct svc_rqst *, __be32 *); int nfs4svc_decode_compoundargs(struct svc_rqst *, __be32 *); int nfs4svc_encode_compoundres(struct svc_rqst *, __be32 *); __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *, u32); From patchwork Mon Nov 23 20:04:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926195 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5A97C83013 for ; Mon, 23 Nov 2020 20:04:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7EE012071E for ; Mon, 23 Nov 2020 20:04:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Tz68b0u3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728456AbgKWUEX (ORCPT ); Mon, 23 Nov 2020 15:04:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbgKWUEX (ORCPT ); Mon, 23 Nov 2020 15:04:23 -0500 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72C62C0613CF for ; Mon, 23 Nov 2020 12:04:23 -0800 (PST) Received: by mail-qk1-x743.google.com with SMTP id z188so6803061qke.9 for ; Mon, 23 Nov 2020 12:04:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=tDjUj9OHG3MgWfymkB8Z0cJsQnH7QZk73EqARM1nLzM=; b=Tz68b0u33h0YXFePiq90M+nmlkPuH/TGpX5itjL9S8BHJhBKJB2CB9dvUR1YODEJ93 8Y3m8o9DPTM4HeM7cAsUt+1PZtUBpqJPFxe/d8q8VqxAUJPWan4AdPy7iLct2BlgCD4v bEBdFBTsgHgAxvyDZS2KAo5FtRjMnhVMSWS+2yDeT2WORgC686D//lVlufQvNSJjQl+E BN6tbYswOUvyy4W/fD11ZCHHn9bMPEzRvwVKhddKamEOzl52IBlY3I/4GuAk8GJHmUaA 3uvvTuZi98afc+kR3ViZFEIgnu5x0uf7BYU3wGU1G2u1qAU+3BMQhKE0jDlXPueYnPWF OrUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=tDjUj9OHG3MgWfymkB8Z0cJsQnH7QZk73EqARM1nLzM=; b=ZRxOm9wtYNR+CRTvNzvUSdRfAzqwNa+S+C3O1nqNF2dyClMU06bdaXH83o/Jc+nbGt Y7bE+y2aLZRGwI/KopWH7CTsbF243LQnZw+BEVz7J7Z9jiPAIEc1jKQ6z2C/wyeAohIg XrtUw3PuvXFq2gV/mCnrnj9AdjoFrbwylArsMibDI4gknUwThhQUEsdRJgh1xF8pP02W eYhj4zNYovqNtTlJc8D1beCaXjCjOByNhz4NuHGbqtUa7dIZc/1ZSMa57qiMDBo2pa3g +EBfeifFAu6q1OSz9NWZck9SI7gjWcLkSO3X8yASQTR5YqFxGx2Rgc2hNmlPRnZIXXJ3 Imlw== X-Gm-Message-State: AOAM530TcjqeoNo3tkHuoqrlpZjRqvsuHJz9u4R+ppSVN62Qwb2PSvJr sqqWaO+jO+FXGtBJRTzawRX3i3CsJNI= X-Google-Smtp-Source: ABdhPJzNEYav66oMngNQYkhB1l/CDpJIQkv6Ah8OjvYAnpKZLFq4y0s+dLO7RN5B8F7qwkwbbn31/Q== X-Received: by 2002:a37:b4e:: with SMTP id 75mr1165702qkl.78.1606161862038; Mon, 23 Nov 2020 12:04:22 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id c9sm10257847qkm.116.2020.11.23.12.04.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:04:21 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK4KDV010279 for ; Mon, 23 Nov 2020 20:04:20 GMT Subject: [PATCH v3 04/85] NFSD: Add tracepoints in nfsd_dispatch() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:04:20 -0500 Message-ID: <160616186042.51996.15361343804924022774.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org For troubleshooting purposes, record GARBAGE_ARGS and CANT_ENCODE failures. Signed-off-by: Chuck Lever --- fs/nfsd/nfssvc.c | 17 +++++---------- fs/nfsd/trace.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 12 deletions(-) diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index c4c646f25f1c..7214e578c09c 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -29,6 +29,8 @@ #include "netns.h" #include "filecache.h" +#include "trace.h" + #define NFSDDBG_FACILITY NFSDDBG_SVC bool inter_copy_offload_enable; @@ -1009,11 +1011,8 @@ int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp) struct kvec *resv = &rqstp->rq_res.head[0]; __be32 *p; - dprintk("nfsd_dispatch: vers %d proc %d\n", - rqstp->rq_vers, rqstp->rq_proc); - if (nfs_request_too_big(rqstp, proc)) - goto out_too_large; + goto out_decode_err; /* * Give the xdr decoder a chance to change this if it wants @@ -1052,24 +1051,18 @@ int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp) out_cached_reply: return 1; -out_too_large: - dprintk("nfsd: NFSv%d argument too large\n", rqstp->rq_vers); - *statp = rpc_garbage_args; - return 1; - out_decode_err: - dprintk("nfsd: failed to decode arguments!\n"); + trace_nfsd_garbage_args_err(rqstp); *statp = rpc_garbage_args; return 1; out_update_drop: - dprintk("nfsd: Dropping request; may be revisited later\n"); nfsd_cache_update(rqstp, RC_NOCACHE, NULL); out_dropit: return 0; out_encode_err: - dprintk("nfsd: failed to encode result!\n"); + trace_nfsd_cant_encode_err(rqstp); nfsd_cache_update(rqstp, RC_NOCACHE, NULL); *statp = rpc_system_err; return 1; diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index 89f218d0279c..0bf1707bd846 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -12,6 +12,66 @@ #include "export.h" #include "nfsfh.h" +#define NFSD_TRACE_PROC_ARG_FIELDS \ + __field(unsigned int, netns_ino) \ + __field(u32, xid) \ + __array(unsigned char, server, sizeof(struct sockaddr_in6)) \ + __array(unsigned char, client, sizeof(struct sockaddr_in6)) + +#define NFSD_TRACE_PROC_ARG_ASSIGNMENTS \ + do { \ + __entry->netns_ino = SVC_NET(rqstp)->ns.inum; \ + __entry->xid = be32_to_cpu(rqstp->rq_xid); \ + memcpy(__entry->server, &rqstp->rq_xprt->xpt_local, \ + rqstp->rq_xprt->xpt_locallen); \ + memcpy(__entry->client, &rqstp->rq_xprt->xpt_remote, \ + rqstp->rq_xprt->xpt_remotelen); \ + } while (0); + +TRACE_EVENT(nfsd_garbage_args_err, + TP_PROTO( + const struct svc_rqst *rqstp + ), + TP_ARGS(rqstp), + TP_STRUCT__entry( + NFSD_TRACE_PROC_ARG_FIELDS + + __field(u32, vers) + __field(u32, proc) + ), + TP_fast_assign( + NFSD_TRACE_PROC_ARG_ASSIGNMENTS + + __entry->vers = rqstp->rq_vers; + __entry->proc = rqstp->rq_proc; + ), + TP_printk("xid=0x%08x vers=%u proc=%u", + __entry->xid, __entry->vers, __entry->proc + ) +); + +TRACE_EVENT(nfsd_cant_encode_err, + TP_PROTO( + const struct svc_rqst *rqstp + ), + TP_ARGS(rqstp), + TP_STRUCT__entry( + NFSD_TRACE_PROC_ARG_FIELDS + + __field(u32, vers) + __field(u32, proc) + ), + TP_fast_assign( + NFSD_TRACE_PROC_ARG_ASSIGNMENTS + + __entry->vers = rqstp->rq_vers; + __entry->proc = rqstp->rq_proc; + ), + TP_printk("xid=0x%08x vers=%u proc=%u", + __entry->xid, __entry->vers, __entry->proc + ) +); + #define show_nfsd_may_flags(x) \ __print_flags(x, "|", \ { NFSD_MAY_EXEC, "EXEC" }, \ From patchwork Mon Nov 23 20:04:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926205 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1FAAFC2D0E4 for ; Mon, 23 Nov 2020 20:05:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B9BEC2071E for ; Mon, 23 Nov 2020 20:05:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PS6Gu3vG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728482AbgKWUEa (ORCPT ); Mon, 23 Nov 2020 15:04:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726770AbgKWUE3 (ORCPT ); Mon, 23 Nov 2020 15:04:29 -0500 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7473DC0613CF for ; Mon, 23 Nov 2020 12:04:28 -0800 (PST) Received: by mail-qv1-xf43.google.com with SMTP id 11so152190qvq.11 for ; Mon, 23 Nov 2020 12:04:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=W4j98SKwgtN/8xfyf2yWXsdXmMUkUzTkpLQWBxfiNCg=; b=PS6Gu3vG6WpOJy/k5SsxllUl5wRZN1fr5ZBZX9/Ln2F7U3P2D66xZ+Z60weE3OyfH6 0m305cWZ3qXxDjfuYAzmzPEI6Wn8m8EPW+ITzcdU605+eD3Vo7tTW3+2BsL4UyluxmJ8 JA/YxofKcKn44I8dauOZSMpC5MvLXExYNnfVEGZmUEaerPOcr10Vl7AhD88ZNFWqAWrF bvnhoo5kHcGUZI3mkDlMf6lU5v5ErzxD9+TVJZhlxLNQSB6n+VQ1dX4NPSYZjAsuEexD UgSncwocQywjZtNQp7+U4MTz7h9YGAN51rQHndgPjhl8onvgZDjFRurSDP/84q8DuXCk cNdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=W4j98SKwgtN/8xfyf2yWXsdXmMUkUzTkpLQWBxfiNCg=; b=hQs8P04OzEBPWScfc2A311r4Qu+d/P8BVThMukOj2BoHe23VzHNgxa/n9SIdZ0aW7d 8UgfKZBb7n7xcimM4qCFdK9q27lSCJzY6uyHzdj7eUowcOLtjPEee+7P7GKcQ9+FODdL q0py5ID8Colfm/njhEF4IULu2esGsvnMo8S3VEMlR84jNnTrdsbUrO50LcMABj6aXrPg JaHhjOZRkHEAHXD8wTLhEV1xx8gQfuRmQZyuxC+SFqqmugYkYXkS3dFBcnQDK+VoAmrB CjIqFsQAjZ9VOniH2eVQisWFL75yvx7xxCaX1XbUyPdfoVOw7P++BPTn+7ltWjnofkbv A2tg== X-Gm-Message-State: AOAM531VGmXGo9t3oBOiMtW4/JxHnIah+itl4qysARYQBT5XCJvhCmFM 8UIXCbEy87pXt/EpBnstQNLiviOo+Fc= X-Google-Smtp-Source: ABdhPJy2RFWTUeKTkUxiwRidLR3Mqpa4u0WYdTWbu6TVSgTfgqKownlkcyCdtJQ4PNwHNs7uUWdVgw== X-Received: by 2002:a0c:e9c7:: with SMTP id q7mr1101025qvo.9.1606161867338; Mon, 23 Nov 2020 12:04:27 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id a123sm4124988qkc.52.2020.11.23.12.04.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:04:26 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK4PjO010282 for ; Mon, 23 Nov 2020 20:04:25 GMT Subject: [PATCH v3 05/85] NFSD: Add tracepoints in From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:04:25 -0500 Message-ID: <160616186571.51996.4492471734685593106.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org For troubleshooting purposes, record failures to decode NFSv4 operation arguments and encode operation results. trace_nfsd_compound_decode_err() replaces the dprintk() call sites that are embedded in READ_* macros that are about to be removed. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 13 +++++++++- fs/nfsd/trace.h | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 86a149ce0e84..66edac748272 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -54,6 +54,8 @@ #include "pnfs.h" #include "filecache.h" +#include "trace.h" + #ifdef CONFIG_NFSD_V4_SECURITY_LABEL #include #endif @@ -2248,9 +2250,14 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) READ_BUF(4); op->opnum = be32_to_cpup(p++); - if (nfsd4_opnum_in_range(argp, op)) + if (nfsd4_opnum_in_range(argp, op)) { op->status = nfsd4_dec_ops[op->opnum](argp, &op->u); - else { + if (op->status != nfs_ok) + trace_nfsd_compound_decode_err(argp->rqstp, + argp->opcnt, i, + op->opnum, + op->status); + } else { op->opnum = OP_ILLEGAL; op->status = nfserr_op_illegal; } @@ -5203,6 +5210,8 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op) !nfsd4_enc_ops[op->opnum]); encoder = nfsd4_enc_ops[op->opnum]; op->status = encoder(resp, op->status, &op->u); + if (op->status) + trace_nfsd_compound_encode_err(rqstp, op->opnum, op->status); if (opdesc && opdesc->op_release) opdesc->op_release(&op->u); xdr_commit_encode(xdr); diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index 0bf1707bd846..92a0973dd671 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -28,6 +28,24 @@ rqstp->rq_xprt->xpt_remotelen); \ } while (0); +#define NFSD_TRACE_PROC_RES_FIELDS \ + __field(unsigned int, netns_ino) \ + __field(u32, xid) \ + __field(unsigned long, status) \ + __array(unsigned char, server, sizeof(struct sockaddr_in6)) \ + __array(unsigned char, client, sizeof(struct sockaddr_in6)) + +#define NFSD_TRACE_PROC_RES_ASSIGNMENTS(error) \ + do { \ + __entry->netns_ino = SVC_NET(rqstp)->ns.inum; \ + __entry->xid = be32_to_cpu(rqstp->rq_xid); \ + __entry->status = be32_to_cpu(error); \ + memcpy(__entry->server, &rqstp->rq_xprt->xpt_local, \ + rqstp->rq_xprt->xpt_locallen); \ + memcpy(__entry->client, &rqstp->rq_xprt->xpt_remote, \ + rqstp->rq_xprt->xpt_remotelen); \ + } while (0); + TRACE_EVENT(nfsd_garbage_args_err, TP_PROTO( const struct svc_rqst *rqstp @@ -127,6 +145,56 @@ TRACE_EVENT(nfsd_compound_status, __get_str(name), __entry->status) ) +TRACE_EVENT(nfsd_compound_decode_err, + TP_PROTO( + const struct svc_rqst *rqstp, + u32 args_opcnt, + u32 resp_opcnt, + u32 opnum, + __be32 status + ), + TP_ARGS(rqstp, args_opcnt, resp_opcnt, opnum, status), + TP_STRUCT__entry( + NFSD_TRACE_PROC_RES_FIELDS + + __field(u32, args_opcnt) + __field(u32, resp_opcnt) + __field(u32, opnum) + ), + TP_fast_assign( + NFSD_TRACE_PROC_RES_ASSIGNMENTS(status) + + __entry->args_opcnt = args_opcnt; + __entry->resp_opcnt = resp_opcnt; + __entry->opnum = opnum; + ), + TP_printk("op=%u/%u opnum=%u status=%lu", + __entry->resp_opcnt, __entry->args_opcnt, + __entry->opnum, __entry->status) +); + +TRACE_EVENT(nfsd_compound_encode_err, + TP_PROTO( + const struct svc_rqst *rqstp, + u32 opnum, + __be32 status + ), + TP_ARGS(rqstp, opnum, status), + TP_STRUCT__entry( + NFSD_TRACE_PROC_RES_FIELDS + + __field(u32, opnum) + ), + TP_fast_assign( + NFSD_TRACE_PROC_RES_ASSIGNMENTS(status) + + __entry->opnum = opnum; + ), + TP_printk("opnum=%u status=%lu", + __entry->opnum, __entry->status) +); + + DECLARE_EVENT_CLASS(nfsd_fh_err_class, TP_PROTO(struct svc_rqst *rqstp, struct svc_fh *fhp, From patchwork Mon Nov 23 20:04:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926207 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 58719C63777 for ; Mon, 23 Nov 2020 20:05:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2C0B20721 for ; Mon, 23 Nov 2020 20:05:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B5srlMg6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726770AbgKWUEf (ORCPT ); Mon, 23 Nov 2020 15:04:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728510AbgKWUEd (ORCPT ); Mon, 23 Nov 2020 15:04:33 -0500 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4AF8C0613CF for ; Mon, 23 Nov 2020 12:04:33 -0800 (PST) Received: by mail-qk1-x743.google.com with SMTP id i199so4772583qke.5 for ; Mon, 23 Nov 2020 12:04:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=sqWPzXZtAarBtY7GFxuAixEcr+8hS1FXoUqar6a0q4g=; b=B5srlMg6jzNi2KSBZ+LkY0kTxvCo6K8Exb/vrS3nRCvXpbS3eJiA4JD9Bzv1MlOgB+ 6RDKu4m0jURjiIF23Q5d/ri/1SajtMGvhX1HBFOD7JSorsaYyKC0j2MGTkTbTHvvcReq Ybk3v4pV1jl78P1NN9CLNjzKH6o2WgodDOLNeJG0f4Lmj6aYOJpr0UTwp7cF/fosHFy4 5FpD/OzGFECPUxMjDvkftpltvfWbI3bOsPLhSxpFPsPCtQOXnz8xc/pLmEEdTIq4jZlg 2bzbdLsmiABMvxOKX1QrlRTgPHraURFLrmlIBjTVFUa3ybc42KJ9neCRfJ4O6LeQM58l GXiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=sqWPzXZtAarBtY7GFxuAixEcr+8hS1FXoUqar6a0q4g=; b=Kr0e23BE1I7vE16w7HB8JIHHU53nmxmIzQnfPz22pi3WYu4yTXogzuuL5lUgXbSnDo WoY0TuPX0snSNmYgIwvvuNYdkChnDR00Q1rV1OhdnwrWy1IAK4aHIHa2ymxC1Gkr3/1F NCQgF1PvqjywWbTtUep4uOQ5MGtdKQ7B4DnCtisOa5wjVoAM6BB+qFiwn2HhOcyq4tYq SUWDwWG2HjIZrR1FSXVak8ZQjyzuhVDNY+oaMkiZ+C/RrhMflxZoh4JI2NYIIFTtvWGw vFvphLVOjB77TILn1QyZgIbkIGg08xqozPxUFCfdpQr3CuuLinkMU1ZE8qnV1+LEBuzM ZwTg== X-Gm-Message-State: AOAM533y4wwcLAcXWMKQibiRNZmOxh4W9+Lm27kkFiwbO+xuMwtfwEIT zPAXxMQvKl0R0tdzwa+ifQ3Qj6vGkOg= X-Google-Smtp-Source: ABdhPJzpSizXjH7Yrt4uAWevM64f87WgNNMhv3aBtR7RMO/Khit++UTpXgPkDw6RVympK29bggecAw== X-Received: by 2002:a05:620a:204d:: with SMTP id d13mr1243098qka.106.1606161872500; Mon, 23 Nov 2020 12:04:32 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id b17sm10176473qkl.123.2020.11.23.12.04.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:04:31 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK4Vxi010286 for ; Mon, 23 Nov 2020 20:04:31 GMT Subject: [PATCH v3 06/85] NFSD: Replace the internals of the READ_BUF() macro From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:04:31 -0500 Message-ID: <160616187100.51996.890505567278190070.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Convert the READ_BUF macro in nfs4xdr.c from open code to instead use the new xdr_stream-style decoders already in use by the encode side (and by the in-kernel NFS client implementation). Once this conversion is done, each individual NFSv4 argument decoder can be independently cleaned up to replace these macros with C code. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4proc.c | 4 - fs/nfsd/nfs4xdr.c | 181 ++++++-------------------------------------- fs/nfsd/xdr4.h | 10 -- include/linux/sunrpc/xdr.h | 2 net/sunrpc/xdr.c | 45 +++++++++++ 5 files changed, 77 insertions(+), 165 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 76300b0441f0..df2d6f70c8d4 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1023,8 +1023,8 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, write->wr_how_written = write->wr_stable_how; - nvecs = svc_fill_write_vector(rqstp, write->wr_pagelist, - &write->wr_head, write->wr_buflen); + nvecs = svc_fill_write_vector(rqstp, write->wr_payload.pages, + write->wr_payload.head, write->wr_buflen); WARN_ON_ONCE(nvecs > ARRAY_SIZE(rqstp->rq_vec)); status = nfsd_vfs_write(rqstp, &cstate->current_fh, nf, diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 66edac748272..25eb6bba48ca 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -131,90 +131,13 @@ xdr_error: \ memcpy((x), p, nbytes); \ p += XDR_QUADLEN(nbytes); \ } while (0) - -/* READ_BUF, read_buf(): nbytes must be <= PAGE_SIZE */ -#define READ_BUF(nbytes) do { \ - if (nbytes <= (u32)((char *)argp->end - (char *)argp->p)) { \ - p = argp->p; \ - argp->p += XDR_QUADLEN(nbytes); \ - } else if (!(p = read_buf(argp, nbytes))) { \ - dprintk("NFSD: xdr error (%s:%d)\n", \ - __FILE__, __LINE__); \ - goto xdr_error; \ - } \ -} while (0) - -static void next_decode_page(struct nfsd4_compoundargs *argp) -{ - argp->p = page_address(argp->pagelist[0]); - argp->pagelist++; - if (argp->pagelen < PAGE_SIZE) { - argp->end = argp->p + XDR_QUADLEN(argp->pagelen); - argp->pagelen = 0; - } else { - argp->end = argp->p + (PAGE_SIZE>>2); - argp->pagelen -= PAGE_SIZE; - } -} - -static __be32 *read_buf(struct nfsd4_compoundargs *argp, u32 nbytes) -{ - /* We want more bytes than seem to be available. - * Maybe we need a new page, maybe we have just run out - */ - unsigned int avail = (char *)argp->end - (char *)argp->p; - __be32 *p; - - if (argp->pagelen == 0) { - struct kvec *vec = &argp->rqstp->rq_arg.tail[0]; - - if (!argp->tail) { - argp->tail = true; - avail = vec->iov_len; - argp->p = vec->iov_base; - argp->end = vec->iov_base + avail; - } - - if (avail < nbytes) - return NULL; - - p = argp->p; - argp->p += XDR_QUADLEN(nbytes); - return p; - } - - if (avail + argp->pagelen < nbytes) - return NULL; - if (avail + PAGE_SIZE < nbytes) /* need more than a page !! */ - return NULL; - /* ok, we can do it with the current plus the next page */ - if (nbytes <= sizeof(argp->tmp)) - p = argp->tmp; - else { - kfree(argp->tmpp); - p = argp->tmpp = kmalloc(nbytes, GFP_KERNEL); - if (!p) - return NULL; - - } - /* - * The following memcpy is safe because read_buf is always - * called with nbytes > avail, and the two cases above both - * guarantee p points to at least nbytes bytes. - */ - memcpy(p, argp->p, avail); - next_decode_page(argp); - memcpy(((char*)p)+avail, argp->p, (nbytes - avail)); - argp->p += XDR_QUADLEN(nbytes - avail); - return p; -} - -static unsigned int compoundargs_bytes_left(struct nfsd4_compoundargs *argp) -{ - unsigned int this = (char *)argp->end - (char *)argp->p; - - return this + argp->pagelen; -} +#define READ_BUF(nbytes) \ + do { \ + p = xdr_inline_decode(argp->xdr,\ + nbytes); \ + if (!p) \ + goto xdr_error; \ + } while (0) static int zero_clientid(clientid_t *clid) { @@ -261,44 +184,6 @@ svcxdr_dupstr(struct nfsd4_compoundargs *argp, void *buf, u32 len) return p; } -static __be32 -svcxdr_construct_vector(struct nfsd4_compoundargs *argp, struct kvec *head, - struct page ***pagelist, u32 buflen) -{ - int avail; - int len; - int pages; - - /* Sorry .. no magic macros for this.. * - * READ_BUF(write->wr_buflen); - * SAVEMEM(write->wr_buf, write->wr_buflen); - */ - avail = (char *)argp->end - (char *)argp->p; - if (avail + argp->pagelen < buflen) { - dprintk("NFSD: xdr error (%s:%d)\n", - __FILE__, __LINE__); - return nfserr_bad_xdr; - } - head->iov_base = argp->p; - head->iov_len = avail; - *pagelist = argp->pagelist; - - len = XDR_QUADLEN(buflen) << 2; - if (len >= avail) { - len -= avail; - - pages = len >> PAGE_SHIFT; - argp->pagelist += pages; - argp->pagelen -= pages * PAGE_SIZE; - len -= pages * PAGE_SIZE; - - next_decode_page(argp); - } - argp->p += XDR_QUADLEN(len); - - return 0; -} - /** * savemem - duplicate a chunk of memory for later processing * @argp: NFSv4 compound argument structure to be freed with @@ -398,7 +283,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, READ_BUF(4); len += 4; nace = be32_to_cpup(p++); - if (nace > compoundargs_bytes_left(argp)/20) + if (nace > xdr_stream_remaining(argp->xdr) / sizeof(struct nfs4_ace)) /* * Even with 4-byte names there wouldn't be * space for that many aces; something fishy is @@ -929,7 +814,7 @@ static __be32 nfsd4_decode_share_deny(struct nfsd4_compoundargs *argp, u32 *x) static __be32 nfsd4_decode_opaque(struct nfsd4_compoundargs *argp, struct xdr_netobj *o) { - __be32 *p; + DECODE_HEAD; READ_BUF(4); o->len = be32_to_cpup(p++); @@ -939,9 +824,8 @@ static __be32 nfsd4_decode_opaque(struct nfsd4_compoundargs *argp, struct xdr_ne READ_BUF(o->len); SAVEMEM(o->data, o->len); - return nfs_ok; -xdr_error: - return nfserr_bad_xdr; + + DECODE_TAIL; } static __be32 @@ -1319,10 +1203,8 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write) goto xdr_error; write->wr_buflen = be32_to_cpup(p++); - status = svcxdr_construct_vector(argp, &write->wr_head, - &write->wr_pagelist, write->wr_buflen); - if (status) - return status; + if (!xdr_stream_subsegment(argp->xdr, &write->wr_payload, write->wr_buflen)) + goto xdr_error; DECODE_TAIL; } @@ -1891,13 +1773,14 @@ nfsd4_decode_seek(struct nfsd4_compoundargs *argp, struct nfsd4_seek *seek) */ /* - * Decode data into buffer. Uses head and pages constructed by - * svcxdr_construct_vector. + * Decode data into buffer. */ static __be32 -nfsd4_vbuf_from_vector(struct nfsd4_compoundargs *argp, struct kvec *head, - struct page **pages, char **bufp, u32 buflen) +nfsd4_vbuf_from_vector(struct nfsd4_compoundargs *argp, struct xdr_buf *xdr, + char **bufp, u32 buflen) { + struct page **pages = xdr->pages; + struct kvec *head = xdr->head; char *tmp, *dp; u32 len; @@ -2012,8 +1895,6 @@ nfsd4_decode_setxattr(struct nfsd4_compoundargs *argp, { DECODE_HEAD; u32 flags, maxcount, size; - struct kvec head; - struct page **pagelist; READ_BUF(4); flags = be32_to_cpup(p++); @@ -2036,12 +1917,12 @@ nfsd4_decode_setxattr(struct nfsd4_compoundargs *argp, setxattr->setxa_len = size; if (size > 0) { - status = svcxdr_construct_vector(argp, &head, &pagelist, size); - if (status) - return status; + struct xdr_buf payload; - status = nfsd4_vbuf_from_vector(argp, &head, pagelist, - &setxattr->setxa_buf, size); + if (!xdr_stream_subsegment(argp->xdr, &payload, size)) + goto xdr_error; + status = nfsd4_vbuf_from_vector(argp, &payload, + &setxattr->setxa_buf, size); } DECODE_TAIL; @@ -5288,8 +5169,6 @@ void nfsd4_release_compoundargs(struct svc_rqst *rqstp) kfree(args->ops); args->ops = args->iops; } - kfree(args->tmpp); - args->tmpp = NULL; while (args->to_free) { struct svcxdr_tmpbuf *tb = args->to_free; args->to_free = tb->next; @@ -5302,19 +5181,11 @@ nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p) { struct nfsd4_compoundargs *args = rqstp->rq_argp; - if (rqstp->rq_arg.head[0].iov_len % 4) { - /* client is nuts */ - dprintk("%s: compound not properly padded! (peeraddr=%pISc xid=0x%x)", - __func__, svc_addr(rqstp), be32_to_cpu(rqstp->rq_xid)); - return 0; - } - args->p = p; - args->end = rqstp->rq_arg.head[0].iov_base + rqstp->rq_arg.head[0].iov_len; - args->pagelist = rqstp->rq_arg.pages; - args->pagelen = rqstp->rq_arg.page_len; - args->tail = false; + /* svcxdr_tmp_alloc */ args->tmpp = NULL; args->to_free = NULL; + + args->xdr = &rqstp->rq_xdr_stream; args->ops = args->iops; args->rqstp = rqstp; diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 37f89ad5e992..0eb13bd603ea 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -419,8 +419,7 @@ struct nfsd4_write { u64 wr_offset; /* request */ u32 wr_stable_how; /* request */ u32 wr_buflen; /* request */ - struct kvec wr_head; - struct page ** wr_pagelist; /* request */ + struct xdr_buf wr_payload; /* request */ u32 wr_bytes_written; /* response */ u32 wr_how_written; /* response */ @@ -696,15 +695,10 @@ struct svcxdr_tmpbuf { struct nfsd4_compoundargs { /* scratch variables for XDR decode */ - __be32 * p; - __be32 * end; - struct page ** pagelist; - int pagelen; - bool tail; __be32 tmp[8]; __be32 * tmpp; + struct xdr_stream *xdr; struct svcxdr_tmpbuf *to_free; - struct svc_rqst *rqstp; u32 taglen; diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index 2729d2d6efce..cc64cd0891f1 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -254,6 +254,8 @@ extern void xdr_enter_page(struct xdr_stream *xdr, unsigned int len); extern int xdr_process_buf(struct xdr_buf *buf, unsigned int offset, unsigned int len, int (*actor)(struct scatterlist *, void *), void *data); extern uint64_t xdr_align_data(struct xdr_stream *, uint64_t, uint32_t); extern uint64_t xdr_expand_hole(struct xdr_stream *, uint64_t, uint64_t); +extern bool xdr_stream_subsegment(struct xdr_stream *xdr, struct xdr_buf *subbuf, + unsigned int len); /** * xdr_set_scratch_buffer - Attach a scratch buffer for decoding data. diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index c607744b3ea8..757560a3b06b 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -1407,6 +1407,51 @@ int xdr_buf_subsegment(const struct xdr_buf *buf, struct xdr_buf *subbuf, } EXPORT_SYMBOL_GPL(xdr_buf_subsegment); +/** + * xdr_stream_subsegment - set @subbuf to a portion of @xdr + * @xdr: an xdr_stream set up for decoding + * @subbuf: the result buffer + * @nbytes: length of @xdr to extract, in bytes + * + * Sets up @subbuf to represent a portion of @xdr. The portion + * starts at the current offset in @xdr, and extends for a length + * of @nbytes. If this is successful, @xdr is advanced to the next + * position following that portion. + * + * Return values: + * %true: @subbuf has been initialized, and @xdr has been advanced. + * %false: a bounds error has occurred + */ +bool xdr_stream_subsegment(struct xdr_stream *xdr, struct xdr_buf *subbuf, + unsigned int nbytes) +{ + unsigned int remaining, offset, len; + + if (xdr_buf_subsegment(xdr->buf, subbuf, xdr_stream_pos(xdr), nbytes)) + return false; + + if (subbuf->head[0].iov_len) + if (!__xdr_inline_decode(xdr, subbuf->head[0].iov_len)) + return false; + + remaining = subbuf->page_len; + offset = subbuf->page_base; + while (remaining) { + len = min_t(unsigned int, remaining, PAGE_SIZE) - offset; + + if (xdr->p == xdr->end && !xdr_set_next_buffer(xdr)) + return false; + if (!__xdr_inline_decode(xdr, len)) + return false; + + remaining -= len; + offset = 0; + } + + return true; +} +EXPORT_SYMBOL_GPL(xdr_stream_subsegment); + /** * xdr_buf_trim - lop at most "len" bytes off the end of "buf" * @buf: buf to be trimmed From patchwork Mon Nov 23 20:04:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C414CC63798 for ; Mon, 23 Nov 2020 20:05:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C2C92071E for ; Mon, 23 Nov 2020 20:05:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HDNBfc7g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728533AbgKWUEl (ORCPT ); Mon, 23 Nov 2020 15:04:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729028AbgKWUEk (ORCPT ); Mon, 23 Nov 2020 15:04:40 -0500 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62C4DC0613CF for ; Mon, 23 Nov 2020 12:04:39 -0800 (PST) Received: by mail-qk1-x744.google.com with SMTP id l2so18291883qkf.0 for ; Mon, 23 Nov 2020 12:04:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=njLLBy7BWEKIoNPzBFWF/Rgwysmdmg4ZQTlLf7t+JPY=; b=HDNBfc7gxf4yxwPiGRDEcTdvhp0rcK/fVneVk5nCaIRQonqiHFVz1+bEJw4UCVCx26 IC+6TiE2+iehS4Ut2EZdWZ1nTmRF+4E2ygtUcBp4RcS2I6vpTkxV0smSh0YbgqI5h002 GE0AfylMr+11NsAgvG0MMAZ/4K7qeSYTgVG4XeG1izUlFsbQWLvf2tw/Cmv3VcDQwiHz ROAq1IUA6I8/juo4ONhP7qfwMIWOmLLd/KdQIHFkatHBtvbby2eI/ygL3wByYEkm7egY i/PWiyqAC9HEoMJmGaB0VcQ7f4Y9A3icujMvKhHGxG0v8ammQ9NjsOtTEvr/iGEUamHH MYLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=njLLBy7BWEKIoNPzBFWF/Rgwysmdmg4ZQTlLf7t+JPY=; b=Vv9OcWvejoqb7T8FHRHqHBhUsbfaNj6pH1RN58+XN+yXoinMMOKoELOXUNmKQDnKHf jSHZ9Zp+CH/JX89kOwnwCcUEfr1MAsonDYVWsOqY3bvalZE/yqfMy0EvG0lbqF7gcx73 qQNuYp7utqYyz1N0v5YaSIsVvrtJqBCnfssf10CYR1/TWOyrgg8z/w6MNUPrZ0ZYqThM uhjJq0fK30U5eIr3bm1Z2dQDw6fQSfFgnkWGnCWs62ZbpIth3dK9p+hvAdA9F31n0rcF 1AwuD1wAwqtqDzQxzJ+pq+7d4zyZzRULlFzn1JlSm3fLWUvWBFYlgujYMhT6adDPrJQ/ D/xA== X-Gm-Message-State: AOAM533oGuvn6trwS4F8nhnTxAWTKK7FWvnPOVfWyeahyhP1jcyUzSEJ w71d5rpdZncirBbdneesDhz2jlu6n5U= X-Google-Smtp-Source: ABdhPJw3YELwKIEHE1GPpZYq2lGdIj9VPT+sf6mFAmwPG7pz1J19/D21ug5NcTtIUm8+e3hp8l5LTw== X-Received: by 2002:a37:9a94:: with SMTP id c142mr1195960qke.480.1606161878137; Mon, 23 Nov 2020 12:04:38 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id i9sm10226383qtp.72.2020.11.23.12.04.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:04:37 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK4a6m010289 for ; Mon, 23 Nov 2020 20:04:36 GMT Subject: [PATCH v3 07/85] NFSD: Replace READ* macros in nfsd4_decode_access() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:04:36 -0500 Message-ID: <160616187607.51996.15759892839673887795.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 25eb6bba48ca..f490832a1a06 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -439,17 +439,6 @@ nfsd4_decode_stateid(struct nfsd4_compoundargs *argp, stateid_t *sid) DECODE_TAIL; } -static __be32 -nfsd4_decode_access(struct nfsd4_compoundargs *argp, struct nfsd4_access *access) -{ - DECODE_HEAD; - - READ_BUF(4); - access->ac_req_access = be32_to_cpup(p++); - - DECODE_TAIL; -} - static __be32 nfsd4_decode_cb_sec(struct nfsd4_compoundargs *argp, struct nfsd4_cb_sec *cbs) { DECODE_HEAD; @@ -531,6 +520,19 @@ static __be32 nfsd4_decode_cb_sec(struct nfsd4_compoundargs *argp, struct nfsd4_ DECODE_TAIL; } +/* + * NFSv4 operation argument decoders + */ + +static __be32 +nfsd4_decode_access(struct nfsd4_compoundargs *argp, + struct nfsd4_access *access) +{ + if (xdr_stream_decode_u32(argp->xdr, &access->ac_req_access) < 0) + return nfserr_bad_xdr; + return nfs_ok; +} + static __be32 nfsd4_decode_backchannel_ctl(struct nfsd4_compoundargs *argp, struct nfsd4_backchannel_ctl *bc) { DECODE_HEAD; From patchwork Mon Nov 23 20:04:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926211 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DF9DC6379F for ; Mon, 23 Nov 2020 20:05:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B78AD20717 for ; Mon, 23 Nov 2020 20:05:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cKy2M8i3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729028AbgKWUEp (ORCPT ); Mon, 23 Nov 2020 15:04:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728996AbgKWUEp (ORCPT ); Mon, 23 Nov 2020 15:04:45 -0500 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D22AC0613CF for ; Mon, 23 Nov 2020 12:04:44 -0800 (PST) Received: by mail-qt1-x842.google.com with SMTP id t5so14373516qtp.2 for ; Mon, 23 Nov 2020 12:04:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=4+wQXn4zDGfwNooc/nX4OmYNvKGDHnBDGPd/i4l+RJY=; b=cKy2M8i3f9/Wp1aOvBNSRK6XfhmdxgSqCvK+ejpQz60Lm0jkmJ9RGpOnsjtYjQUM2k LrakjwdK5o/sfhHYn8Owc/cnV22UdQ9jRJBXMYUow+WicMctUy5Cs5kACpTSqqiEQMPT aHWziBY1JILRT41s43ioo2W3kd3rEx6cfehA211jkfbZIkGKzrYBX3Q+jTV7u1AnriPY Ys41dRsWcVzRhWGWJNQKjGe/ijoZAe6vBBfa+t3krAdvwELTGblvOBMBm/AYqRcKgRpo irfQtdIwAfhVO7JiZSdX4/QdIP7r4mRylolJL2sjTFbNieVLnjOBDeK/U42RngVEtvHA alZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=4+wQXn4zDGfwNooc/nX4OmYNvKGDHnBDGPd/i4l+RJY=; b=Rg0sJa1w93sl+9mjyjUOTl+2xX/yX/X6fbAWwV1JHeNekcwA4WvmHhdW13TOt1ukrM EtCQCk6bQqE3WiLNdwEAWxSOsft4R8r/0w3S5rXAX0CHZtBQszgJfG0YOKk8vAMjP+3G K7/TS2g4Nddo3PwZXjLbrmEGfhJJVQ+GkctgqdpvPyq9hTa3BJCEbb/Qae+5H44k3Ya3 i1uzG3pV1L5Z3DTrvyRXKnxkZJ4ny2cMCtg+fkTf2PHt7Cfmlwag+GKG8lUgH0mFRSg/ R6utn83lYXaZmf62FIqsHvGpxjrohrpVzJ+ah9fpHPjSf9l6TQEW+tXU6WyZFnKwNQIC Z3hg== X-Gm-Message-State: AOAM531nmg/elKVzhAJ8cEzDcB9WA9m/A789GPzLIsS2GSjjt0X56wqd kt++iVU2XvPrf3ajRR3gqhv5S97Z15k= X-Google-Smtp-Source: ABdhPJwyfWxH1EdNcSYmJTKhbEY0BgCrZdGngJrGQNtVJcGClNzVtj1J1l0UNzqvbPcZVZmRPpps9g== X-Received: by 2002:ac8:76c7:: with SMTP id q7mr822544qtr.317.1606161883078; Mon, 23 Nov 2020 12:04:43 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id e126sm820201qkb.90.2020.11.23.12.04.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:04:42 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK4fqk010292 for ; Mon, 23 Nov 2020 20:04:41 GMT Subject: [PATCH v3 08/85] NFSD: Replace READ* macros in nfsd4_decode_close() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:04:41 -0500 Message-ID: <160616188135.51996.6016156334767656634.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index f490832a1a06..fd7447d07009 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -439,6 +439,19 @@ nfsd4_decode_stateid(struct nfsd4_compoundargs *argp, stateid_t *sid) DECODE_TAIL; } +static __be32 +nfsd4_decode_stateid4(struct nfsd4_compoundargs *argp, stateid_t *sid) +{ + __be32 *p; + + p = xdr_inline_decode(argp->xdr, NFS4_STATEID_SIZE); + if (!p) + return nfserr_bad_xdr; + sid->si_generation = be32_to_cpup(p++); + memcpy(&sid->si_opaque, p, sizeof(sid->si_opaque)); + return nfs_ok; +} + static __be32 nfsd4_decode_cb_sec(struct nfsd4_compoundargs *argp, struct nfsd4_cb_sec *cbs) { DECODE_HEAD; @@ -559,13 +572,9 @@ static __be32 nfsd4_decode_bind_conn_to_session(struct nfsd4_compoundargs *argp, static __be32 nfsd4_decode_close(struct nfsd4_compoundargs *argp, struct nfsd4_close *close) { - DECODE_HEAD; - - READ_BUF(4); - close->cl_seqid = be32_to_cpup(p++); - return nfsd4_decode_stateid(argp, &close->cl_stateid); - - DECODE_TAIL; + if (xdr_stream_decode_u32(argp->xdr, &close->cl_seqid) < 0) + return nfserr_bad_xdr; + return nfsd4_decode_stateid4(argp, &close->cl_stateid); } From patchwork Mon Nov 23 20:04:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 501E7C6379D for ; Mon, 23 Nov 2020 20:05:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F06E62071E for ; Mon, 23 Nov 2020 20:05:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ICPFBv++" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729125AbgKWUEw (ORCPT ); Mon, 23 Nov 2020 15:04:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728996AbgKWUEw (ORCPT ); Mon, 23 Nov 2020 15:04:52 -0500 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 864C6C0613CF for ; Mon, 23 Nov 2020 12:04:49 -0800 (PST) Received: by mail-qk1-x742.google.com with SMTP id d9so18216896qke.8 for ; Mon, 23 Nov 2020 12:04:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=GQDCey4LXxpSI4KVkEqiWJdxjzTi2/ZRohD25cPmZI0=; b=ICPFBv++LtP1ME9TZpcNWx7YVOhK27KKLscw2Tslt2zdNx3J3uqn92q45GkbTEsWap xNKV/tQhbne6uDmBa2V0CDqZrKFdgZyhn/bzH2wZziGggj7QdId5zcdzu3LBZXMPEs39 PQnDurqFrZgBSrYm+B1O1aJgNE4qG+1rCdbpkNBrmRxkpq8/NgzxqvhfCF+f8jamuu6q 1QCOyffNpxISXWigvGZfL9LtbWwW+y/VL9ZLcGAUHXfCQ5Bez5M2yTl+HTqk4CTxIG8U DxBLFW6Yy2ppOEaA4wOlQ4Hi09fyi13gVeOCrTK9CseLuxJf7nwryLevwQHOr2QUiQ94 KLgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=GQDCey4LXxpSI4KVkEqiWJdxjzTi2/ZRohD25cPmZI0=; b=iHr0y08XpooTNC4uUBbCGGDOJlCULXv5Me6S5MxTysAaZRoDkEFie8ouFvPNJY6XVo CzkDGlo9E7pp2Y9mzDVOx+jQkJ/GCO+jUjNSNCcw37DLC0mX5TqUHbR/nwzuB8Tfimjh BqBfV38bCcALORTv2nEJxCkAZxwn9Memq5bl17vyRIjqxETQRX+5blCTbCus/JdrXNJ9 95A+hYI+oWr8JGlDQoIp3YdwE58IlKsoNG4a+68Ac2gbV/NsHoXLuXqxY1kQ4uWPbEX8 TeRCg586Mo9mRDCJ/Izlk0mwvg0AsbRZxe/ACIuwVI2k+EMOgdqbyH57hh7UC2XBYUJm 7LAw== X-Gm-Message-State: AOAM531bwfd58hcwqEjrcKlrl2n6vXwsf1V8ImaWVfmPK9+FwHogDDZl Bav3oLUUTSKZTIVT+AtIL8GA9G4jxj8= X-Google-Smtp-Source: ABdhPJxGBkTrJzNRhOftXgM3W8vKHTmNpfvIPhvs0U4QOQTBUIKbpjnOG+sh3jEgTEHPEhL0uHwgvg== X-Received: by 2002:a05:620a:401:: with SMTP id 1mr1219983qkp.257.1606161888398; Mon, 23 Nov 2020 12:04:48 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id a13sm6442299qtj.69.2020.11.23.12.04.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:04:47 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK4kAD010295 for ; Mon, 23 Nov 2020 20:04:46 GMT Subject: [PATCH v3 09/85] NFSD: Replace READ* macros in nfsd4_decode_commit() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:04:46 -0500 Message-ID: <160616188664.51996.938229739001960697.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 12 +++++------- include/linux/sunrpc/xdr.h | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index fd7447d07009..de7408adb7c6 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -581,13 +581,11 @@ nfsd4_decode_close(struct nfsd4_compoundargs *argp, struct nfsd4_close *close) static __be32 nfsd4_decode_commit(struct nfsd4_compoundargs *argp, struct nfsd4_commit *commit) { - DECODE_HEAD; - - READ_BUF(12); - p = xdr_decode_hyper(p, &commit->co_offset); - commit->co_count = be32_to_cpup(p++); - - DECODE_TAIL; + if (xdr_stream_decode_u64(argp->xdr, &commit->co_offset) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &commit->co_count) < 0) + return nfserr_bad_xdr; + return nfs_ok; } static __be32 diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index cc64cd0891f1..cc669d95c484 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -571,6 +571,27 @@ xdr_stream_decode_u32(struct xdr_stream *xdr, __u32 *ptr) return 0; } +/** + * xdr_stream_decode_u64 - Decode a 64-bit integer + * @xdr: pointer to xdr_stream + * @ptr: location to store 64-bit integer + * + * Return values: + * %0 on success + * %-EBADMSG on XDR buffer overflow + */ +static inline ssize_t +xdr_stream_decode_u64(struct xdr_stream *xdr, __u64 *ptr) +{ + const size_t count = sizeof(*ptr); + __be32 *p = xdr_inline_decode(xdr, count); + + if (unlikely(!p)) + return -EBADMSG; + xdr_decode_hyper(p, ptr); + return 0; +} + /** * xdr_stream_decode_opaque_fixed - Decode fixed length opaque xdr data * @xdr: pointer to xdr_stream From patchwork Mon Nov 23 20:04:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B5D8C64E69 for ; Mon, 23 Nov 2020 20:05:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 34A6A20717 for ; Mon, 23 Nov 2020 20:05:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sFgarIsW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729134AbgKWUEz (ORCPT ); Mon, 23 Nov 2020 15:04:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728229AbgKWUEz (ORCPT ); Mon, 23 Nov 2020 15:04:55 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04F35C0613CF for ; Mon, 23 Nov 2020 12:04:55 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id i199so4773767qke.5 for ; Mon, 23 Nov 2020 12:04:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=Z84HjOvQPeCK6o4R4Yv7RajFvqsaAPyLXqsH/7l+Ckk=; b=sFgarIsWPAVdNlEM/LYewJ0MDRmOUQKGtl5+itt64JtPQcb1BEoRtD2q4FGQsS17qI gatVkocKzU9oX0E6J3+oo0RMDzERVQbj2I46KJUAohesebjOXSgoN9frLr45kN+m4+Dy KCBbqIdsgw64EbfOvos0LA+yBhZEsrkoYBPhtzrmH6a/6eW1j9maY+QVnNsRz/8bai73 DOc4ungxYLUB8ivEBKni+GRS+UuUo9NxqLxM5yHw9LbBun3H/WZZGClMb8jAFguaN8L2 eratZgTIt4lVM86J0axJSgn9hrTvePSN273aZMCIDYRLp54uTm7/xpdNPAsZFgao71E4 yHLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=Z84HjOvQPeCK6o4R4Yv7RajFvqsaAPyLXqsH/7l+Ckk=; b=kHNfdz9KL1Zve9YQGa69Urnyy7X/LJw0gUPoulf3Z8OWnGQDz+FUwdmK1BTfsjVoSk A90CgFJBfoGdy5Y5e0M9KshLpW0rXbka+Be7SKpVoAK6/ohrH/PYFHr0xu8fz5UGg9YV zAYm2c1Dkl6m1HxCJVA2KCT6SrXzD/0tmGsXsgwFVqF5WV9UUZyDp5WBPoTxkYRn/75J EYtSmIXMrb5u6f5YjZa1A3Q9M3U6bySyekgoHnSK+2m20X7XhN1u6wan3k/gKYCwo7bb G+XY6MeOEJTiewCKn5N8UCLLJYef6Yl01vZ6kaiBaXUYvUeyx3030/TJbczOnNWz6r24 zrhw== X-Gm-Message-State: AOAM531zdN6mnEnJ9LgenJP26f98kw61mwdnXtq0CP9KSjw6Hk1xS62j 2KAL89mIT3vsnLf2DlcUWgT3B2xAnds= X-Google-Smtp-Source: ABdhPJw8D10E7rOrNpzGB2e29nkVEsim0ZcHFtFkB7mLS/A8Bn3RIo2BIys++y5SzdJtwW6A/x4mwg== X-Received: by 2002:a37:b505:: with SMTP id e5mr1219529qkf.309.1606161893803; Mon, 23 Nov 2020 12:04:53 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id o127sm9484479qkf.135.2020.11.23.12.04.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:04:52 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK4pTp010298 for ; Mon, 23 Nov 2020 20:04:51 GMT Subject: [PATCH v3 10/85] NFSD: Change the way the expected length of a fattr4 is checked From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:04:51 -0500 Message-ID: <160616189193.51996.3348726953277601601.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Because the fattr4 is now managed in an xdr_stream, all that is needed is to store the initial position of the stream before decoding the attribute list. Then the actual length of the list is computed using the final stream position, after decoding is complete. No behavior change is expected. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index de7408adb7c6..6dae8b0a5f0f 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -250,7 +250,8 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, struct iattr *iattr, struct nfs4_acl **acl, struct xdr_netobj *label, int *umask) { - int expected_len, len = 0; + unsigned int starting_pos; + u32 attrlist4_count; u32 dummy32; char *buf; @@ -267,12 +268,12 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, return nfserr_attrnotsupp; } - READ_BUF(4); - expected_len = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &attrlist4_count) < 0) + return nfserr_bad_xdr; + starting_pos = xdr_stream_pos(argp->xdr); if (bmval[0] & FATTR4_WORD0_SIZE) { READ_BUF(8); - len += 8; p = xdr_decode_hyper(p, &iattr->ia_size); iattr->ia_valid |= ATTR_SIZE; } @@ -280,7 +281,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, u32 nace; struct nfs4_ace *ace; - READ_BUF(4); len += 4; + READ_BUF(4); nace = be32_to_cpup(p++); if (nace > xdr_stream_remaining(argp->xdr) / sizeof(struct nfs4_ace)) @@ -297,13 +298,12 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, (*acl)->naces = nace; for (ace = (*acl)->aces; ace < (*acl)->aces + nace; ace++) { - READ_BUF(16); len += 16; + READ_BUF(16); ace->type = be32_to_cpup(p++); ace->flag = be32_to_cpup(p++); ace->access_mask = be32_to_cpup(p++); dummy32 = be32_to_cpup(p++); READ_BUF(dummy32); - len += XDR_QUADLEN(dummy32) << 2; READMEM(buf, dummy32); ace->whotype = nfs4_acl_get_whotype(buf, dummy32); status = nfs_ok; @@ -322,17 +322,14 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, *acl = NULL; if (bmval[1] & FATTR4_WORD1_MODE) { READ_BUF(4); - len += 4; iattr->ia_mode = be32_to_cpup(p++); iattr->ia_mode &= (S_IFMT | S_IALLUGO); iattr->ia_valid |= ATTR_MODE; } if (bmval[1] & FATTR4_WORD1_OWNER) { READ_BUF(4); - len += 4; dummy32 = be32_to_cpup(p++); READ_BUF(dummy32); - len += (XDR_QUADLEN(dummy32) << 2); READMEM(buf, dummy32); if ((status = nfsd_map_name_to_uid(argp->rqstp, buf, dummy32, &iattr->ia_uid))) return status; @@ -340,10 +337,8 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, } if (bmval[1] & FATTR4_WORD1_OWNER_GROUP) { READ_BUF(4); - len += 4; dummy32 = be32_to_cpup(p++); READ_BUF(dummy32); - len += (XDR_QUADLEN(dummy32) << 2); READMEM(buf, dummy32); if ((status = nfsd_map_name_to_gid(argp->rqstp, buf, dummy32, &iattr->ia_gid))) return status; @@ -351,11 +346,9 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, } if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) { READ_BUF(4); - len += 4; dummy32 = be32_to_cpup(p++); switch (dummy32) { case NFS4_SET_TO_CLIENT_TIME: - len += 12; status = nfsd4_decode_time(argp, &iattr->ia_atime); if (status) return status; @@ -370,11 +363,9 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, } if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) { READ_BUF(4); - len += 4; dummy32 = be32_to_cpup(p++); switch (dummy32) { case NFS4_SET_TO_CLIENT_TIME: - len += 12; status = nfsd4_decode_time(argp, &iattr->ia_mtime); if (status) return status; @@ -392,18 +383,14 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, if (IS_ENABLED(CONFIG_NFSD_V4_SECURITY_LABEL) && bmval[2] & FATTR4_WORD2_SECURITY_LABEL) { READ_BUF(4); - len += 4; dummy32 = be32_to_cpup(p++); /* lfs: we don't use it */ READ_BUF(4); - len += 4; dummy32 = be32_to_cpup(p++); /* pi: we don't use it either */ READ_BUF(4); - len += 4; dummy32 = be32_to_cpup(p++); READ_BUF(dummy32); if (dummy32 > NFS4_MAXLABELLEN) return nfserr_badlabel; - len += (XDR_QUADLEN(dummy32) << 2); READMEM(buf, dummy32); label->len = dummy32; label->data = svcxdr_dupstr(argp, buf, dummy32); @@ -414,15 +401,16 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, if (!umask) goto xdr_error; READ_BUF(8); - len += 8; dummy32 = be32_to_cpup(p++); iattr->ia_mode = dummy32 & (S_IFMT | S_IALLUGO); dummy32 = be32_to_cpup(p++); *umask = dummy32 & S_IRWXUGO; iattr->ia_valid |= ATTR_MODE; } - if (len != expected_len) - goto xdr_error; + + /* request sanity: did attrlist4 contain the expected number of words? */ + if (attrlist4_count != xdr_stream_pos(argp->xdr) - starting_pos) + return nfserr_bad_xdr; DECODE_TAIL; } From patchwork Mon Nov 23 20:04:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6FDEC64E7A for ; Mon, 23 Nov 2020 20:05:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6F5DF2071E for ; Mon, 23 Nov 2020 20:05:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FTXIfYiT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729181AbgKWUFA (ORCPT ); Mon, 23 Nov 2020 15:05:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728108AbgKWUE7 (ORCPT ); Mon, 23 Nov 2020 15:04:59 -0500 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3BACC0613CF for ; Mon, 23 Nov 2020 12:04:59 -0800 (PST) Received: by mail-qk1-x743.google.com with SMTP id b144so3716046qkc.13 for ; Mon, 23 Nov 2020 12:04:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=sKctRiTsI4+gWPapXa/R8VDyO1YNtMROkytZLiJISrY=; b=FTXIfYiTydkGGhQb92rtu0JCIqF1jEcSfG+G7G0UsXWdRdCcvhzS/O9vAey04KMXX2 oRlJkESeqUwzeAcGhpxO04r6CwWGz5OIPaFk1LKzbOhkDF4WJI/bbaKmBhaapGbw4vTc IV9kf27umXGB9/sUVCW4m5j0KhRA7A8kiz4rj3nAtGVN3tJuxwcPPRUlRVDrwQC3hJeE eUNHA/yBUzxBYYSCFwnnf0GWevjJDRGAc5viWHvYVFUG9a9B6NnR3MBg91r45DQqvk0x VAdewnxYARy1hpS0BI77vhg3yRqsGwhdGPPSg3zYrkWvjK2alkzak6UIfmMYKuJFExzF wnow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=sKctRiTsI4+gWPapXa/R8VDyO1YNtMROkytZLiJISrY=; b=PkqqsmUMblwI7vfO8ImbLwI4JG4espX4acL3DgWIUG3hAh7CqSupJ7h6kG1Lb21FPw DVU8SiGxrMZYMvRfTvmPAlpx2sqqGQfTCdlK8K4MZmou5/sIstB7vsufH6E6/H4pUXzb +PKKMZPynaGOWEQZKUpNDAuvZt1oDl0LBhNxc9dcqME8MBXJSaqRwVmZfqKWdpBaQZNt Legm4Hn0Cbj9sgVjoWTWK6hwkHMD1CDm5Bej61XigCzD/VBWkNTgp74Xyq2AcfCG2NNt obBIwtNqETouZWYnIJnK3svs/OY22fURi8D7drcQ1WUJRUfW+KzppiXJEC9U3mXrZADV HUcA== X-Gm-Message-State: AOAM533HrCpE0j5BCmUECigQo6/IMwNXuwQbDMiHZR44LKuQhdMwcaER 0WcfEeqyKcVA9fmf9dI+tF3w/LA5wyE= X-Google-Smtp-Source: ABdhPJx3vI/YY8sIEJ/I/koY8LRb5eH2kzB1gEopp/72y0Upc294XvGrSmghtKPHEHm2L15SQjypfw== X-Received: by 2002:a05:620a:11a4:: with SMTP id c4mr1291196qkk.8.1606161898686; Mon, 23 Nov 2020 12:04:58 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id 72sm10099441qkn.44.2020.11.23.12.04.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:04:58 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK4vqN010301 for ; Mon, 23 Nov 2020 20:04:57 GMT Subject: [PATCH v3 11/85] NFSD: Replace READ* macros that decode the fattr4 size attribute From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:04:57 -0500 Message-ID: <160616189727.51996.3163424533928322558.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 6dae8b0a5f0f..ec47efd68c72 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -273,8 +273,11 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, starting_pos = xdr_stream_pos(argp->xdr); if (bmval[0] & FATTR4_WORD0_SIZE) { - READ_BUF(8); - p = xdr_decode_hyper(p, &iattr->ia_size); + u64 size; + + if (xdr_stream_decode_u64(argp->xdr, &size) < 0) + return nfserr_bad_xdr; + iattr->ia_size = size; iattr->ia_valid |= ATTR_SIZE; } if (bmval[0] & FATTR4_WORD0_ACL) { From patchwork Mon Nov 23 20:05:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926217 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15758C64E75 for ; Mon, 23 Nov 2020 20:05:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AD95920717 for ; Mon, 23 Nov 2020 20:05:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AI8eWPqz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729723AbgKWUFJ (ORCPT ); Mon, 23 Nov 2020 15:05:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729539AbgKWUFJ (ORCPT ); Mon, 23 Nov 2020 15:05:09 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D035C0613CF for ; Mon, 23 Nov 2020 12:05:08 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id i199so4774546qke.5 for ; Mon, 23 Nov 2020 12:05:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=jxOyeZahZWSY/Hxf4QXHLYVx5g9HfKAFTcAru2xkFsA=; b=AI8eWPqzT0IjCA+YxJAV9ej86pIc23LmUmiJ69p0vYY0J/mh5V9fbAetQECgZzfiw0 Wew87Hui1a8gCFH3M5ltpXkOxSLzIi/RsaM9bwEk1LLc9zU/H0dNebIdglHd6mlpTLUC fv6r9/Db4rtR8DEuVIEaJcJzojsrO1witalcIkVbHzIaP5PvFFUzVmCrI5s0urU7xaQ7 3cBwzLlUxnPj7l7Jakw3ZvvsbvMujj8QJCVIYPUn1tTgH+7uDp8/B5erHwb7HPo67kaw V2BJVBENJO5zp+OuetQ8y8G+U4W/eAszO1lMF7RwSYJX1WCD7AsgSaq5e5GjlyebGRaf d8tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=jxOyeZahZWSY/Hxf4QXHLYVx5g9HfKAFTcAru2xkFsA=; b=RhPB4Db1WEU62D+ck/LkPa7csSOYBwqWo3qX4xU14S6yUmLR9gz55/ieu9ZnimI+HT cTFWJaB5AIEepAWAiqHkgmWnXPrKuYo7ITwwz+j2PNi14ZTAvz+Ui3lglhHWFkyh3Ba/ /ocv3zp00DYZGZpTOKdEj54wdPlTZ6plz7CcVg9bCLdJzM+8p9c72YapKqQHgZjDvG0o 4ROfnFY5r6ZU4Kl2M8OcMX67F0HSF6jW3emPCbnN4ow9jmLKDKJhf8dd3EYngysEe7G5 BjZR4WPx92EMCdtFinz37yhjTqWo09/WRJPu8BWA3MFUrdt+x53eEjJgSnZzMF4rvw2e fnSg== X-Gm-Message-State: AOAM531mvcRjsIxWlPYQDKTSgNWweJi89RmehNckvCYMIonZ7LM85m9n zvER7cmI1+n812a8hDGha1ATdqNMYwI= X-Google-Smtp-Source: ABdhPJykUXXKBI8WlrDoj0jdipsKvgNQSXOoDydWNmg3TqoFXtJuhD7uaroGASxD/kFhn4xo5fFRxw== X-Received: by 2002:a37:6594:: with SMTP id z142mr1222063qkb.115.1606161904273; Mon, 23 Nov 2020 12:05:04 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id r14sm10482556qtu.25.2020.11.23.12.05.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:05:03 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK522f010304 for ; Mon, 23 Nov 2020 20:05:02 GMT Subject: [PATCH v3 12/85] NFSD: Replace READ* macros that decode the fattr4 acl attribute From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:05:02 -0500 Message-ID: <160616190235.51996.16689530413211925078.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Refactor for clarity and to move infrequently-used code out of line. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 107 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 67 insertions(+), 40 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index ec47efd68c72..273d5f849df8 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -245,6 +245,70 @@ nfsd4_decode_bitmap(struct nfsd4_compoundargs *argp, u32 *bmval) DECODE_TAIL; } +static __be32 +nfsd4_decode_nfsace4(struct nfsd4_compoundargs *argp, struct nfs4_ace *ace) +{ + __be32 *p, status; + u32 length; + + if (xdr_stream_decode_u32(argp->xdr, &ace->type) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &ace->flag) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &ace->access_mask) < 0) + return nfserr_bad_xdr; + + if (xdr_stream_decode_u32(argp->xdr, &length) < 0) + return nfserr_bad_xdr; + p = xdr_inline_decode(argp->xdr, length); + if (!p) + return nfserr_bad_xdr; + ace->whotype = nfs4_acl_get_whotype((char *)p, length); + if (ace->whotype != NFS4_ACL_WHO_NAMED) + status = nfs_ok; + else if (ace->flag & NFS4_ACE_IDENTIFIER_GROUP) + status = nfsd_map_name_to_gid(argp->rqstp, + (char *)p, length, &ace->who_gid); + else + status = nfsd_map_name_to_uid(argp->rqstp, + (char *)p, length, &ace->who_uid); + + return status; +} + +/* A counted array of nfsace4's */ +static noinline __be32 +nfsd4_decode_acl(struct nfsd4_compoundargs *argp, struct nfs4_acl **acl) +{ + struct nfs4_ace *ace; + __be32 status; + u32 count; + + if (xdr_stream_decode_u32(argp->xdr, &count) < 0) + return nfserr_bad_xdr; + + if (count > xdr_stream_remaining(argp->xdr) / 20) + /* + * Even with 4-byte names there wouldn't be + * space for that many aces; something fishy is + * going on: + */ + return nfserr_fbig; + + *acl = svcxdr_tmpalloc(argp, nfs4_acl_bytes(count)); + if (*acl == NULL) + return nfserr_jukebox; + + (*acl)->naces = count; + for (ace = (*acl)->aces; ace < (*acl)->aces + count; ace++) { + status = nfsd4_decode_nfsace4(argp, ace); + if (status) + return status; + } + + return nfs_ok; +} + static __be32 nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, struct iattr *iattr, struct nfs4_acl **acl, @@ -281,46 +345,9 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, iattr->ia_valid |= ATTR_SIZE; } if (bmval[0] & FATTR4_WORD0_ACL) { - u32 nace; - struct nfs4_ace *ace; - - READ_BUF(4); - nace = be32_to_cpup(p++); - - if (nace > xdr_stream_remaining(argp->xdr) / sizeof(struct nfs4_ace)) - /* - * Even with 4-byte names there wouldn't be - * space for that many aces; something fishy is - * going on: - */ - return nfserr_fbig; - - *acl = svcxdr_tmpalloc(argp, nfs4_acl_bytes(nace)); - if (*acl == NULL) - return nfserr_jukebox; - - (*acl)->naces = nace; - for (ace = (*acl)->aces; ace < (*acl)->aces + nace; ace++) { - READ_BUF(16); - ace->type = be32_to_cpup(p++); - ace->flag = be32_to_cpup(p++); - ace->access_mask = be32_to_cpup(p++); - dummy32 = be32_to_cpup(p++); - READ_BUF(dummy32); - READMEM(buf, dummy32); - ace->whotype = nfs4_acl_get_whotype(buf, dummy32); - status = nfs_ok; - if (ace->whotype != NFS4_ACL_WHO_NAMED) - ; - else if (ace->flag & NFS4_ACE_IDENTIFIER_GROUP) - status = nfsd_map_name_to_gid(argp->rqstp, - buf, dummy32, &ace->who_gid); - else - status = nfsd_map_name_to_uid(argp->rqstp, - buf, dummy32, &ace->who_uid); - if (status) - return status; - } + status = nfsd4_decode_acl(argp, acl); + if (status) + return status; } else *acl = NULL; if (bmval[1] & FATTR4_WORD1_MODE) { From patchwork Mon Nov 23 20:05:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B5D2C64E7B for ; Mon, 23 Nov 2020 20:05:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8C1F2071E for ; Mon, 23 Nov 2020 20:05:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mrFoHYlE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729516AbgKWUFL (ORCPT ); Mon, 23 Nov 2020 15:05:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729736AbgKWUFL (ORCPT ); Mon, 23 Nov 2020 15:05:11 -0500 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93695C0613CF for ; Mon, 23 Nov 2020 12:05:10 -0800 (PST) Received: by mail-qk1-x744.google.com with SMTP id q5so18200072qkc.12 for ; Mon, 23 Nov 2020 12:05:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=59G1dPFQw0SbnN96ZTNX0IHLXP/fiJbjJC2aXfhzPRs=; b=mrFoHYlEl95S+CT+sr5bl+CQC3eUzdbBvimi2ZiLN2Xfu98iqt9Ap/BztOgn52uOU1 xTU9lIjbshKAER5cn7co2G95NPzZudZrlAKNDRpGZFaP222nUKKzQeZ94oq8AztRPGC1 cZQX1/tJ7cMEGRbvMCVIzN113Hf3sOQVO6M+yl4Nu+eJGBXkzVA4VGKHISG8romexyoV JCJHicZUioLA+tNopDz3nzQZwuyv2tVibiYVdg1CMWsmOJsOliUyiFigahMsdEL8svqn TICFitqOz90wVa4HAm2fQcjdlJSnx9H84ajkP0ko2nVz1nkB1bA/0ecZg6h6nMnV2pfv fYUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=59G1dPFQw0SbnN96ZTNX0IHLXP/fiJbjJC2aXfhzPRs=; b=Lu8tH1Bz6ONopnw7gruR1EYIrc0MrwFsTSlX2X7NUqDima3Hh3wSqK99tC5qCHx5dH PzuHd8CTJuJ58GUaMdiavmkC7E1DF462SYeJhO5TjdOLgM36XAOIJTGM1gdfMqV0I0We M9B8o3mHXSbNLAs+8An1FznHTAEDLp37wZwJtlgTyDXBemztP6uxkd6wTdblQ3WC7zLr 764cIHsyJbtllk5iyTsnwu9iB00ZHC6DmQ6WDg50k4ITd0a6QNzgFYxP4mUlHv17kghc jP/0XvPdfiYqTc2Nb6UE6b3zsf+iPsw+0kM5fJEFIdeiJvLib1Lu2/O6idaJehBSz/nU /qjg== X-Gm-Message-State: AOAM531wGVxUxBuVVwiqVUzUdJGnSsJ2WU9T+9wL2hc77Y+nURXAmKth 1KPucC/kBVfNexTQsXPeR7/kGW2LruM= X-Google-Smtp-Source: ABdhPJw02AQ4n4cCnjaefJm8rqDuy9etGaKVqAD7dH/sUu7pQ27QvRi96RpgUXUIQcJwA2YG6+x2ng== X-Received: by 2002:a05:620a:2e8:: with SMTP id a8mr1322460qko.144.1606161909440; Mon, 23 Nov 2020 12:05:09 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id t56sm9479411qth.27.2020.11.23.12.05.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:05:08 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK573F010307 for ; Mon, 23 Nov 2020 20:05:07 GMT Subject: [PATCH v3 13/85] NFSD: Replace READ* macros that decode the fattr4 mode attribute From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:05:07 -0500 Message-ID: <160616190770.51996.16267066264499044512.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 273d5f849df8..597da7cb28af 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -351,8 +351,11 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, } else *acl = NULL; if (bmval[1] & FATTR4_WORD1_MODE) { - READ_BUF(4); - iattr->ia_mode = be32_to_cpup(p++); + u32 mode; + + if (xdr_stream_decode_u32(argp->xdr, &mode) < 0) + return nfserr_bad_xdr; + iattr->ia_mode = mode; iattr->ia_mode &= (S_IFMT | S_IALLUGO); iattr->ia_valid |= ATTR_MODE; } From patchwork Mon Nov 23 20:05:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926219 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E419C64E7C for ; Mon, 23 Nov 2020 20:05:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3034820717 for ; Mon, 23 Nov 2020 20:05:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eMdgHWgL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728108AbgKWUFQ (ORCPT ); Mon, 23 Nov 2020 15:05:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727079AbgKWUFP (ORCPT ); Mon, 23 Nov 2020 15:05:15 -0500 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F5DFC0613CF for ; Mon, 23 Nov 2020 12:05:15 -0800 (PST) Received: by mail-qt1-x843.google.com with SMTP id t5so14375169qtp.2 for ; Mon, 23 Nov 2020 12:05:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=ek9mp6KvuYLbDR6TLP/AcPNtzm6FNrNbLlruqgeb5Gc=; b=eMdgHWgLi2vukYy4oIela6bI+zBRzuTO8iy9HOu/TwV/0mgCwaPwabGJI8zdB97s/9 xluT8MoSNymcUUYwOsGFsZc7IZ59ZfbNsLW58/EkFqiR5BOs/93oCF3Idvg+mPiCUBHS IRdnzaV80FF1eAKLiWWgrmKqI+y9AkFxPzhGBEHuwrfNnwJ4mkCyqs15lwowP52jcoUG a3buiOGDc6ydjlpc+J82MPj6FrjBbg+I7Ji0MUTw8sKf9BhcRGsyPNKmhUywQ0zOSayn e0mec6MSHs9xgpEIKlAetb5YOmenjlkMaQ8t8PHNKzL8B+pK3nOPGoTwyarfjQKB3b+D piRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=ek9mp6KvuYLbDR6TLP/AcPNtzm6FNrNbLlruqgeb5Gc=; b=sMsDVUhNNTRu+x15+KzewF86Jkfpg8JESEE2SYDJCJbCGM8bOLO9emJ7aoCk75i82T AXXINfLELB/xOqUOLOuNjOjDEQmwUthk6EmJ5SVvdG53LI+q3RzC8pAl2I0/xgDm1JVB vZ3pSxen/YSOYv/JpyPgik6u2xtd5OHur5aODLcZ7Kfbx3glZ5XsE+GMM4nh594F+3ZW X/prYj3kZpTJnnyjBM1gFt4LuY53vzt0DLEYme3y4cVyQ7MrKS0087O0QizRrKWWU3zd VAVg8mx1OxZzd40SoMzoc+n/ifPJrehmbDNmVgAiih/r8xgsI9jcRPndNSuwUAkmiSBe UARQ== X-Gm-Message-State: AOAM533FmyajtgD1kCUaC5glQPDy3Un0InUutpowS28IYenJ62kTTGeP XgLRuh5BMly2saJS3f8RGCruH4EGOiA= X-Google-Smtp-Source: ABdhPJzu5koEgDM2PvIcHgKVn3DheMvuphtCqkKhfap/Q68CzkJ6rkGTa58uVoxzYKWoUvU0yayMSg== X-Received: by 2002:ac8:734a:: with SMTP id q10mr831785qtp.389.1606161914411; Mon, 23 Nov 2020 12:05:14 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id d82sm10143455qkc.14.2020.11.23.12.05.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:05:13 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK5Cl2010310 for ; Mon, 23 Nov 2020 20:05:12 GMT Subject: [PATCH v3 14/85] NFSD: Replace READ* macros that decode the fattr4 owner attribute From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:05:12 -0500 Message-ID: <160616191276.51996.13499570109676145470.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 597da7cb28af..0b46cb9e3867 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -360,11 +360,16 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, iattr->ia_valid |= ATTR_MODE; } if (bmval[1] & FATTR4_WORD1_OWNER) { - READ_BUF(4); - dummy32 = be32_to_cpup(p++); - READ_BUF(dummy32); - READMEM(buf, dummy32); - if ((status = nfsd_map_name_to_uid(argp->rqstp, buf, dummy32, &iattr->ia_uid))) + u32 length; + + if (xdr_stream_decode_u32(argp->xdr, &length) < 0) + return nfserr_bad_xdr; + p = xdr_inline_decode(argp->xdr, length); + if (!p) + return nfserr_bad_xdr; + status = nfsd_map_name_to_uid(argp->rqstp, (char *)p, length, + &iattr->ia_uid); + if (status) return status; iattr->ia_valid |= ATTR_UID; } From patchwork Mon Nov 23 20:05:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1647C2D0E4 for ; Mon, 23 Nov 2020 20:05:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6AF912071E for ; Mon, 23 Nov 2020 20:05:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IfOEOmgl" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728819AbgKWUFV (ORCPT ); Mon, 23 Nov 2020 15:05:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728172AbgKWUFU (ORCPT ); Mon, 23 Nov 2020 15:05:20 -0500 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B871CC0613CF for ; Mon, 23 Nov 2020 12:05:20 -0800 (PST) Received: by mail-qv1-xf44.google.com with SMTP id u23so9449619qvf.1 for ; Mon, 23 Nov 2020 12:05:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=7hF7ieFqsu6i+8+NfU/CsHEiy5OAg+2MqRJKJJ2UjAg=; b=IfOEOmglsyZ6zfPGSfv03wTnh4cDNXV6dFeJr+hnbJ6nNZbmDSVAjQncFugI5QSb/a 9EbwHk9ho4GpeQgUl+R8B8aOLezigKI+IqtSC9jizwhXIFSVCLm3Lt9Lww9+n6JAwUTM LlgJiIXy+QPWmtVPxCTmos2VfAZxBsGifv//2J8uJHlFWKBZHZZ8Y/WHyIIGglFF89Ty W2HI32dVbc0ckpyLWy/ee7njrLQO5EfQHrLLBV2b5WSdlLQEVTnqB1okHJ7MYqVmNvOX BH0AVxekJdnQYnEbJtZu2QLc0BasmMTF+oYsAQiYulTbMpu2t45RPY2BzgE8lQBSg+0N iHrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=7hF7ieFqsu6i+8+NfU/CsHEiy5OAg+2MqRJKJJ2UjAg=; b=d2DCVKokkVT1NXhIi39ytW1pgj/8qcU+plWGN2SYOMDWfZKgiR5OJ5kJIrh390bRFx lqf28tmXZ6otOwcF7umBy4LvELoQGyMtQ6yT6B0f37CxKYZMn55tGYElwQqCZ1kMQe/b esYs6HfrK5l10XzmuhovTnI2ZGF2SCCyHgsXMX6JtZuhqGadx3vIBJAA/Ce1qf29m/x1 HTN+DdoCuWZAcD7LyIDdBoVLcs4kh9C4UY3CR5abyBakWgzAEUvOPKximINOXa/WYPWQ rSJ2OJGoHDYLH9ma4EWvafR7xlcb+l/hJ/0BfrLFoqKRUeAGL8uFFNGHLbLOkXNQY1DW a0WQ== X-Gm-Message-State: AOAM532fl6Z9Y9gTLzJBBUkqG6QwssTroYhha4oEOdCMPdH/cywg4vLv 13phwbJulf7thXjqI7DCY54X+80oYfQ= X-Google-Smtp-Source: ABdhPJzlw0FugNX7GmdZ/bflHa0G2x+2NCzZsS3tUGbgloN/ttvoPHI783PJ5/yN4ZDzRmbKCSP8AQ== X-Received: by 2002:a0c:abc8:: with SMTP id k8mr1202498qvb.14.1606161919695; Mon, 23 Nov 2020 12:05:19 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id g4sm10354843qtu.82.2020.11.23.12.05.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:05:19 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK5ICK010313 for ; Mon, 23 Nov 2020 20:05:18 GMT Subject: [PATCH v3 15/85] NFSD: Replace READ* macros that decode the fattr4 owner_group attribute From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:05:18 -0500 Message-ID: <160616191805.51996.10833465502263704335.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 0b46cb9e3867..e5f73bfc79dc 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -374,11 +374,16 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, iattr->ia_valid |= ATTR_UID; } if (bmval[1] & FATTR4_WORD1_OWNER_GROUP) { - READ_BUF(4); - dummy32 = be32_to_cpup(p++); - READ_BUF(dummy32); - READMEM(buf, dummy32); - if ((status = nfsd_map_name_to_gid(argp->rqstp, buf, dummy32, &iattr->ia_gid))) + u32 length; + + if (xdr_stream_decode_u32(argp->xdr, &length) < 0) + return nfserr_bad_xdr; + p = xdr_inline_decode(argp->xdr, length); + if (!p) + return nfserr_bad_xdr; + status = nfsd_map_name_to_gid(argp->rqstp, (char *)p, length, + &iattr->ia_gid); + if (status) return status; iattr->ia_valid |= ATTR_GID; } From patchwork Mon Nov 23 20:05:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926221 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E15E3C64E7D for ; Mon, 23 Nov 2020 20:05:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A45CC20717 for ; Mon, 23 Nov 2020 20:05:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rFhwSk8u" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728288AbgKWUF1 (ORCPT ); Mon, 23 Nov 2020 15:05:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728172AbgKWUF1 (ORCPT ); Mon, 23 Nov 2020 15:05:27 -0500 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A9BFC0613CF for ; Mon, 23 Nov 2020 12:05:26 -0800 (PST) Received: by mail-qt1-x842.google.com with SMTP id e10so6886173qte.4 for ; Mon, 23 Nov 2020 12:05:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=3M88BWG2KaPxDVuMz2rPXZO7oeNufUPuQ1bPgNy0Z+A=; b=rFhwSk8uDI+UZi2B/sy0cPUj1K2gPjuZLDSQ8GETM7SW9eSAkXzkqncbezy+RtJpVF gTALmpyJmVnbwN+Q1n4huM6vyg0knqvzPApCMpgWMi1VuzYTLmMPMgZ+nUAaGW/jlKiZ TjHLGUFnzZehAK4PQr0iYt3+1y3PhQdXwpoKC7ibUjpRjsT/yE4ZUE59r7PFO0G8fvPl 4fpBF13i6nwEd2vnG6pXBxVqZBrDxcrORTgnNDrNrJVSqjegR+d+PXNqd8mzN3zS3GLr kQwPhQLlG+XIIB1OkXqpNAMciRhaU6hWHCiYMSR5vr2eoLfTRnwoGG1zHS+hGHJckd5L shfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=3M88BWG2KaPxDVuMz2rPXZO7oeNufUPuQ1bPgNy0Z+A=; b=L1FtOZo3Tyt/Calx5TAl4gCDOq7jW2PRS3Aclep9b0Hp0AOyqPOX/j6Al0giZuH0dc w9a1h+40GBpuyxNEqe9lK2Qf5UKhph1W863Wy+HMLvlXxQcsUXHt3wAhtrnCgtW5BJe0 4LdZsMmIMx0y0zjy6HB4kgWR5TPeIubYcdyumQwQ6nQIb7LNDc5IjWn3TYhTKsfIx9yC mMdvT+FD9yyCf28dnF2q3agSXWDrLmZLsvZdVcarHZyLsLW8BoKs1ou7TBi7P09hXHv+ 5g/QD3Bva2YGOgWyz3jmG7hUTdHoNVq2lZGtmYtmuN7H4pW6i/4iV2tRrv5gubdn45aT I+Kg== X-Gm-Message-State: AOAM532a+RvRY8HUf4lkHx6/uf38F6KXH9wqIa3R1NcR+KV3ga483/ac zbOLlD+oSsZxmFnvoKO84fsUxgBL3wU= X-Google-Smtp-Source: ABdhPJyiiSERQJoPWQffdHGw5ugtd82izVIAJfHqu9jLKudoQ/QLutY0gNRJdSEbrLR9xlWTmqJ0ag== X-Received: by 2002:ac8:444b:: with SMTP id m11mr930454qtn.122.1606161924993; Mon, 23 Nov 2020 12:05:24 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id q7sm2604044qkb.22.2020.11.23.12.05.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:05:24 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK5N0H010316 for ; Mon, 23 Nov 2020 20:05:23 GMT Subject: [PATCH v3 16/85] NFSD: Replace READ* macros that decode the fattr4 time_set attributes From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:05:23 -0500 Message-ID: <160616192333.51996.682877163956950323.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index e5f73bfc79dc..2668c150042e 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -219,6 +219,21 @@ nfsd4_decode_time(struct nfsd4_compoundargs *argp, struct timespec64 *tv) DECODE_TAIL; } +static __be32 +nfsd4_decode_nfstime4(struct nfsd4_compoundargs *argp, struct timespec64 *tv) +{ + __be32 *p; + + p = xdr_inline_decode(argp->xdr, XDR_UNIT * 3); + if (!p) + return nfserr_bad_xdr; + p = xdr_decode_hyper(p, &tv->tv_sec); + tv->tv_nsec = be32_to_cpup(p++); + if (tv->tv_nsec >= (u32)1000000000) + return nfserr_inval; + return nfs_ok; +} + static __be32 nfsd4_decode_bitmap(struct nfsd4_compoundargs *argp, u32 *bmval) { @@ -388,11 +403,13 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, iattr->ia_valid |= ATTR_GID; } if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) { - READ_BUF(4); - dummy32 = be32_to_cpup(p++); - switch (dummy32) { + u32 set_it; + + if (xdr_stream_decode_u32(argp->xdr, &set_it) < 0) + return nfserr_bad_xdr; + switch (set_it) { case NFS4_SET_TO_CLIENT_TIME: - status = nfsd4_decode_time(argp, &iattr->ia_atime); + status = nfsd4_decode_nfstime4(argp, &iattr->ia_atime); if (status) return status; iattr->ia_valid |= (ATTR_ATIME | ATTR_ATIME_SET); @@ -401,15 +418,17 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, iattr->ia_valid |= ATTR_ATIME; break; default: - goto xdr_error; + return nfserr_bad_xdr; } } if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) { - READ_BUF(4); - dummy32 = be32_to_cpup(p++); - switch (dummy32) { + u32 set_it; + + if (xdr_stream_decode_u32(argp->xdr, &set_it) < 0) + return nfserr_bad_xdr; + switch (set_it) { case NFS4_SET_TO_CLIENT_TIME: - status = nfsd4_decode_time(argp, &iattr->ia_mtime); + status = nfsd4_decode_nfstime4(argp, &iattr->ia_mtime); if (status) return status; iattr->ia_valid |= (ATTR_MTIME | ATTR_MTIME_SET); @@ -418,7 +437,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, iattr->ia_valid |= ATTR_MTIME; break; default: - goto xdr_error; + return nfserr_bad_xdr; } } From patchwork Mon Nov 23 20:05:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C682C63777 for ; Mon, 23 Nov 2020 20:05:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DC4512071E for ; Mon, 23 Nov 2020 20:05:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="av0ii5+U" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728341AbgKWUFc (ORCPT ); Mon, 23 Nov 2020 15:05:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727079AbgKWUFc (ORCPT ); Mon, 23 Nov 2020 15:05:32 -0500 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13458C0613CF for ; Mon, 23 Nov 2020 12:05:31 -0800 (PST) Received: by mail-qt1-x841.google.com with SMTP id l7so8049375qtp.8 for ; Mon, 23 Nov 2020 12:05:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=V82GSOh6+vlstoU+jnFTV5cu0MbSSQ2SDtB7TRi2Ocw=; b=av0ii5+UsbIaqoIxAjMGVbivHkTzzF8+gmy3IjwpJEGCPCwm1N3PJCEvg9aIN5sR5k 2S0IIiIdZjDn2LnXTqSSHzP6Cjs9/LOogCpmpoqTgtQnRcILLtCUycckHQHTnspncqk3 pEKRPE4px28owmNt9EjCTsTZupY/FvZHLBU/vJSwA6ZGNBKG/AuuN689s+wSfdRIGUS+ D+y6NZJD9z+3+x9Ajo/RuGpB6MnkGv8webSIuwXoKvxI5AsG8eSASG3xD2KUyuyWszmA 8PqIpgkllmcgHdx8kmyYgWzJ3xTvicTqxkeeTldZh5drNFWr9YQMlMOXjKWb6UrxcDG6 05Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=V82GSOh6+vlstoU+jnFTV5cu0MbSSQ2SDtB7TRi2Ocw=; b=pv5nhPGPGloZzEVX3DrTWs5msdln33UXlLhoYe3f/xfol3oGbyixD4c7gdrfaqjEX5 mK5YS9ilbGcG5Wp/hCqxIRP5gdKDf2pqAo9MuinB2ogce/eFr2Ztz5j0sH9fNNUxXdx3 DkOXJwJMej1uIof274JymGoIMqYgkXPq1DYwnW4lN18DDaP1ekjphCzI4DvKvKRpq6Bl 2QOBPRA+CqJFs04cpH/GPgCVGlkpMg3aXXm4GQa7mlkezU3dt6Yp8KiX9D0/fno7xxL4 xbU9JOiT5qhKUB5DIrmVhYbUleTnHq6Xg/KA2ED5nQEEftUrxLpIDodH3xKeDC1ZGtS0 lozg== X-Gm-Message-State: AOAM530IkdGZCiKUpmjcDG2DxZs8izySe3UuCVozeIvyfM5QHnzvP08N LJm1aV9cRIA39OpVRPAcXvK9EhzlcCs= X-Google-Smtp-Source: ABdhPJylnNC/hMVV71hCtlbWHbigp7X0RMSysBtBWp9PiLBYZMLQMz2yRwD+OzY3mFDZNpdurSJjzQ== X-Received: by 2002:ac8:6651:: with SMTP id j17mr919544qtp.176.1606161930022; Mon, 23 Nov 2020 12:05:30 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id b64sm10352407qkg.19.2020.11.23.12.05.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:05:29 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK5SLY010319 for ; Mon, 23 Nov 2020 20:05:28 GMT Subject: [PATCH v3 17/85] NFSD: Replace READ* macros that decode the fattr4 security label attribute From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:05:28 -0500 Message-ID: <160616192862.51996.1062624442478508351.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 46 ++++++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 2668c150042e..3844bbb7aaa3 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -324,6 +324,33 @@ nfsd4_decode_acl(struct nfsd4_compoundargs *argp, struct nfs4_acl **acl) return nfs_ok; } +static noinline __be32 +nfsd4_decode_security_label(struct nfsd4_compoundargs *argp, + struct xdr_netobj *label) +{ + u32 lfs, pi, length; + __be32 *p; + + if (xdr_stream_decode_u32(argp->xdr, &lfs) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &pi) < 0) + return nfserr_bad_xdr; + + if (xdr_stream_decode_u32(argp->xdr, &length) < 0) + return nfserr_bad_xdr; + if (length > NFS4_MAXLABELLEN) + return nfserr_badlabel; + p = xdr_inline_decode(argp->xdr, length); + if (!p) + return nfserr_bad_xdr; + label->len = length; + label->data = svcxdr_dupstr(argp, p, length); + if (!label->data) + return nfserr_jukebox; + + return nfs_ok; +} + static __be32 nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, struct iattr *iattr, struct nfs4_acl **acl, @@ -332,7 +359,6 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, unsigned int starting_pos; u32 attrlist4_count; u32 dummy32; - char *buf; DECODE_HEAD; iattr->ia_valid = 0; @@ -440,24 +466,12 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, return nfserr_bad_xdr; } } - label->len = 0; if (IS_ENABLED(CONFIG_NFSD_V4_SECURITY_LABEL) && bmval[2] & FATTR4_WORD2_SECURITY_LABEL) { - READ_BUF(4); - dummy32 = be32_to_cpup(p++); /* lfs: we don't use it */ - READ_BUF(4); - dummy32 = be32_to_cpup(p++); /* pi: we don't use it either */ - READ_BUF(4); - dummy32 = be32_to_cpup(p++); - READ_BUF(dummy32); - if (dummy32 > NFS4_MAXLABELLEN) - return nfserr_badlabel; - READMEM(buf, dummy32); - label->len = dummy32; - label->data = svcxdr_dupstr(argp, buf, dummy32); - if (!label->data) - return nfserr_jukebox; + status = nfsd4_decode_security_label(argp, label); + if (status) + return status; } if (bmval[2] & FATTR4_WORD2_MODE_UMASK) { if (!umask) From patchwork Mon Nov 23 20:05:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6FDB4C64E90 for ; Mon, 23 Nov 2020 20:05:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1BDEE20717 for ; Mon, 23 Nov 2020 20:05:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O7GP10zZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727079AbgKWUFg (ORCPT ); Mon, 23 Nov 2020 15:05:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728038AbgKWUFg (ORCPT ); Mon, 23 Nov 2020 15:05:36 -0500 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B41FC0613CF for ; Mon, 23 Nov 2020 12:05:36 -0800 (PST) Received: by mail-qt1-x842.google.com with SMTP id e10so6886734qte.4 for ; Mon, 23 Nov 2020 12:05:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=xafRn5urN93n9LRvMuxvvqgG7plRSgQmc2iMcxZO/wY=; b=O7GP10zZoXQ3p4XP/3xp135RncMCAhpR2Ptj/mk2oMuR2bgRgcuDHKU0Si7TXgyz2V LnR70gQINwft4UCvMbmMxhVEohMqRqUyoTpdmPVrv1fs3N0q7HBnAjTR/dtVbIMm6/EH KGkEc/YJHo0KNdVpXEnb7W7Eq4984SinuLjaiieu6Fd2MBkxMluMIKLlEBvTCdbBFiE/ ahaXkLzb34NggvRWSsgtafePjD7WMq3K+mkH4NM/NIqTbQ285zSqzZIOCBq+6NqSdb32 TKo/3XmvrRTfEbMFws/ZPGng23tsjFQW1NZ5i1XDUB0oTC4DL3WUwmOFOw18VvUiZvE7 yx/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=xafRn5urN93n9LRvMuxvvqgG7plRSgQmc2iMcxZO/wY=; b=qcJSQy66y56g13cc3i42vRvYwfVfJfeO3gtPSJx+qVabLqIDCFkHSCdB0N08tITJbr N2+qFQNENHtcXi/NFgZsnIQsIlAFVo4fw/tL4uvk+QTYYbNRlM2Z2ePDkU1qdkK2iwRG BkAooAvb1aMy+OpFpVHQ3Mw7vedBkYiuKamjaFwTB0z5PgfcJmwmim0xjn0xZd2ONj3+ Z+mjvoXR0J74lDbfcHaI5KVbg77hQQEQehdIt+TRK8q5HdH1tZaGTFHLNlxzV77Uo0nm L0SQEpKx2XyONlc3ww55MckAe19KzNz1diTP1CGh/PdJUKke4D3BnU+CBiKwl79Ce71G hFUg== X-Gm-Message-State: AOAM530+FQ3MzDJpfUXXJt62i/yerXsIFDoi6UYdQ6vMMj6+dGdZTlnD os+ddWvdNbqYpfKcNUsOqZV2/y5lj8E= X-Google-Smtp-Source: ABdhPJxmszNDXjgomehHr5ZADQrG+exndiq1JGj1SyobWv7fZCfg41JKrrHGnmh3jlwi8FQJ/9VaiQ== X-Received: by 2002:ac8:47d0:: with SMTP id d16mr862424qtr.125.1606161935309; Mon, 23 Nov 2020 12:05:35 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id j17sm10103278qtn.2.2020.11.23.12.05.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:05:34 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK5X57010322 for ; Mon, 23 Nov 2020 20:05:33 GMT Subject: [PATCH v3 18/85] NFSD: Replace READ* macros that decode the fattr4 umask attribute From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:05:33 -0500 Message-ID: <160616193368.51996.3435896308145544488.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 3844bbb7aaa3..54481804a096 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -358,7 +358,6 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, { unsigned int starting_pos; u32 attrlist4_count; - u32 dummy32; DECODE_HEAD; iattr->ia_valid = 0; @@ -474,13 +473,16 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, return status; } if (bmval[2] & FATTR4_WORD2_MODE_UMASK) { + u32 mode, mask; + if (!umask) - goto xdr_error; - READ_BUF(8); - dummy32 = be32_to_cpup(p++); - iattr->ia_mode = dummy32 & (S_IFMT | S_IALLUGO); - dummy32 = be32_to_cpup(p++); - *umask = dummy32 & S_IRWXUGO; + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &mode) < 0) + return nfserr_bad_xdr; + iattr->ia_mode = mode & (S_IFMT | S_IALLUGO); + if (xdr_stream_decode_u32(argp->xdr, &mask) < 0) + return nfserr_bad_xdr; + *umask = mask & S_IRWXUGO; iattr->ia_valid |= ATTR_MODE; } From patchwork Mon Nov 23 20:05:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90104C64EBC for ; Mon, 23 Nov 2020 20:05:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 50BED2071E for ; Mon, 23 Nov 2020 20:05:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kPg0G50m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728172AbgKWUFn (ORCPT ); Mon, 23 Nov 2020 15:05:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728038AbgKWUFn (ORCPT ); Mon, 23 Nov 2020 15:05:43 -0500 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE7B5C0613CF for ; Mon, 23 Nov 2020 12:05:42 -0800 (PST) Received: by mail-qt1-x844.google.com with SMTP id 7so14374876qtp.1 for ; Mon, 23 Nov 2020 12:05:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=5EyXRboDgcDSU80VZZr3ghNnhuDa+k9qaNIjsxtQUZE=; b=kPg0G50mvhNYO+4hUQ2R2S8Ihd5chW4eGR0ub88qmxnsDoI57GTGztnDIKTLdrkiHB 9LoBIowOfLAs43Kbt475QKme0w9IYQCKA0gDCqmpvDa2t5tDwXhG/TwNOYycyLkX88Sb G95RdGOLD65mtvr3di1ly/H32S1IC88BtUI4VDu23p/nl23eYxMu+anTZY7LzwMF83Xz I4f4RDOdMVz6LrTIN+guwbyNV8jDbBTnPzRoruDEil6JIygS2GyCVMAPsB2J17X/lpjA Bxcu+y3KumJsWVPrmFGQMaBgbLy3VqeW/NjLLEdHJkkFyvlUErZlFlxJ6lbzncM4Gez1 XZew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=5EyXRboDgcDSU80VZZr3ghNnhuDa+k9qaNIjsxtQUZE=; b=rtVBDRsL1H9poITBn3yPg97mS4qX4SDux2ig1yuxBlg2TZAmD6hrQq+uHqZ2hSR4zk 6X1TfI17e674+kTcqnbhdWq/WMuxBH+4wK4DremwOybeFdmSs0/GUveRbPZlpxzIONSp NIaR/uWQerav2ghT8hqIZ9iuROLvl5u3sNmbAALkeTGISyz34s31Pb0cQWmjn5n9iCHp Lt7HoXUFGZia57kwPohhjxEyT6zGIIwQ/YwkYWN1Gw6B5YhDJuDf+IOQFbiyEeNb37py WjpoxEZ32SwIl8oBRJkNCLjIskTpwloH/O6wzCuq+st4tCmzuEqwG7rJNdJd0hPRsi6Y bKKA== X-Gm-Message-State: AOAM530UZavKHK/42AMUktO2g7DlzjCNsNhPuHfi6NAU4k3n5AJ9dJYN 4iTIP6wEGnKemNykxguJPkVr/cAJfUM= X-Google-Smtp-Source: ABdhPJxLFKZwv/R5N/ATiwsOUOi/gACxEJD2duZC9UviY+DARK5KzVYC6Lqq9GNBa3hPs3oQtFrwbQ== X-Received: by 2002:aed:3b5d:: with SMTP id q29mr846779qte.91.1606161940629; Mon, 23 Nov 2020 12:05:40 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id m62sm4102167qkb.91.2020.11.23.12.05.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:05:39 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK5cFC010325 for ; Mon, 23 Nov 2020 20:05:38 GMT Subject: [PATCH v3 19/85] NFSD: Replace READ* macros in nfsd4_decode_fattr() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:05:38 -0500 Message-ID: <160616193897.51996.12609995444933822837.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Let's be more careful to avoid overrunning the memory that backs the bitmap array. This requires updating the synopsis of nfsd4_decode_fattr(). Bruce points out that a server needs to be careful to return nfs_ok when a client presents bitmap bits the server doesn't support. This includes bits in bitmap words the server might not yet support. The current READ* based implementation is good about that, but that requirement hasn't been documented. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 82 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 64 insertions(+), 18 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 54481804a096..9b295c810ef3 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -260,6 +260,46 @@ nfsd4_decode_bitmap(struct nfsd4_compoundargs *argp, u32 *bmval) DECODE_TAIL; } +/** + * nfsd4_decode_bitmap4 - Decode an NFSv4 bitmap4 + * @argp: NFSv4 compound argument structure + * @bmval: pointer to an array of u32's to decode into + * @bmlen: size of the @bmval array + * + * The server needs to return nfs_ok rather than nfserr_bad_xdr when + * encountering bitmaps containing bits it does not recognize. This + * includes bits in bitmap words past WORDn, where WORDn is the last + * bitmap WORD the implementation currently supports. Thus we are + * careful here to simply ignore bits in bitmap words that this + * implementation has yet to support explicitly. + * + * Return values: + * %nfs_ok: @bmval populated successfully + * %nfserr_bad_xdr: the encoded bitmap was invalid + */ +static __be32 +nfsd4_decode_bitmap4(struct nfsd4_compoundargs *argp, u32 *bmval, u32 bmlen) +{ + u32 i, count; + __be32 *p; + + if (xdr_stream_decode_u32(argp->xdr, &count) < 0) + return nfserr_bad_xdr; + /* request sanity */ + if (count > 1000) + return nfserr_bad_xdr; + p = xdr_inline_decode(argp->xdr, count << 2); + if (!p) + return nfserr_bad_xdr; + i = 0; + while (i < count) + bmval[i++] = be32_to_cpup(p++); + while (i < bmlen) + bmval[i++] = 0; + + return nfs_ok; +} + static __be32 nfsd4_decode_nfsace4(struct nfsd4_compoundargs *argp, struct nfs4_ace *ace) { @@ -352,17 +392,18 @@ nfsd4_decode_security_label(struct nfsd4_compoundargs *argp, } static __be32 -nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, - struct iattr *iattr, struct nfs4_acl **acl, - struct xdr_netobj *label, int *umask) +nfsd4_decode_fattr4(struct nfsd4_compoundargs *argp, u32 *bmval, u32 bmlen, + struct iattr *iattr, struct nfs4_acl **acl, + struct xdr_netobj *label, int *umask) { unsigned int starting_pos; u32 attrlist4_count; + __be32 *p, status; - DECODE_HEAD; iattr->ia_valid = 0; - if ((status = nfsd4_decode_bitmap(argp, bmval))) - return status; + status = nfsd4_decode_bitmap4(argp, bmval, bmlen); + if (status) + return nfserr_bad_xdr; if (bmval[0] & ~NFSD_WRITEABLE_ATTRS_WORD0 || bmval[1] & ~NFSD_WRITEABLE_ATTRS_WORD1 @@ -490,7 +531,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval, if (attrlist4_count != xdr_stream_pos(argp->xdr) - starting_pos) return nfserr_bad_xdr; - DECODE_TAIL; + return nfs_ok; } static __be32 @@ -690,9 +731,10 @@ nfsd4_decode_create(struct nfsd4_compoundargs *argp, struct nfsd4_create *create if ((status = check_filename(create->cr_name, create->cr_namelen))) return status; - status = nfsd4_decode_fattr(argp, create->cr_bmval, &create->cr_iattr, - &create->cr_acl, &create->cr_label, - &create->cr_umask); + status = nfsd4_decode_fattr4(argp, create->cr_bmval, + ARRAY_SIZE(create->cr_bmval), + &create->cr_iattr, &create->cr_acl, + &create->cr_label, &create->cr_umask); if (status) goto out; @@ -941,9 +983,10 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) switch (open->op_createmode) { case NFS4_CREATE_UNCHECKED: case NFS4_CREATE_GUARDED: - status = nfsd4_decode_fattr(argp, open->op_bmval, - &open->op_iattr, &open->op_acl, &open->op_label, - &open->op_umask); + status = nfsd4_decode_fattr4(argp, open->op_bmval, + ARRAY_SIZE(open->op_bmval), + &open->op_iattr, &open->op_acl, + &open->op_label, &open->op_umask); if (status) goto out; break; @@ -956,9 +999,10 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) goto xdr_error; READ_BUF(NFS4_VERIFIER_SIZE); COPYMEM(open->op_verf.data, NFS4_VERIFIER_SIZE); - status = nfsd4_decode_fattr(argp, open->op_bmval, - &open->op_iattr, &open->op_acl, &open->op_label, - &open->op_umask); + status = nfsd4_decode_fattr4(argp, open->op_bmval, + ARRAY_SIZE(open->op_bmval), + &open->op_iattr, &open->op_acl, + &open->op_label, &open->op_umask); if (status) goto out; break; @@ -1194,8 +1238,10 @@ nfsd4_decode_setattr(struct nfsd4_compoundargs *argp, struct nfsd4_setattr *seta status = nfsd4_decode_stateid(argp, &setattr->sa_stateid); if (status) return status; - return nfsd4_decode_fattr(argp, setattr->sa_bmval, &setattr->sa_iattr, - &setattr->sa_acl, &setattr->sa_label, NULL); + return nfsd4_decode_fattr4(argp, setattr->sa_bmval, + ARRAY_SIZE(setattr->sa_bmval), + &setattr->sa_iattr, &setattr->sa_acl, + &setattr->sa_label, NULL); } static __be32 From patchwork Mon Nov 23 20:05:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E97EEC71155 for ; Mon, 23 Nov 2020 20:05:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C13220717 for ; Mon, 23 Nov 2020 20:05:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S3jZdnmg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728382AbgKWUFs (ORCPT ); Mon, 23 Nov 2020 15:05:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728038AbgKWUFs (ORCPT ); Mon, 23 Nov 2020 15:05:48 -0500 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EEBEC0613CF for ; Mon, 23 Nov 2020 12:05:47 -0800 (PST) Received: by mail-qt1-x843.google.com with SMTP id f93so14311028qtb.10 for ; Mon, 23 Nov 2020 12:05:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=rp5bisnZRIlvkOVcULc9p3rwK/sWuztjt2k1H7KDAfQ=; b=S3jZdnmgKQQeQohuI3wBOCv9WK2XxeOiRlvlTa6yjAZSKK71IzN8iWYhWN090R+r/0 5B3M5uVZkhq9aod7OKBkNdzkMpx0y165AMBe8VizpY09/ie+YCMLgAc1n0Hj4p3+xNTF vVHsH/+OGf1ocEr9VgLwVlSEooK3BgndoLyOryvTJ0sP944Rr74LUxjG4xVmBByKtkH/ p08HMp82ICqGCIc0RjPe5AJ08NTVcdQa7a+8o7ewntwRU8XlwhDNhwoEvHFxQZBiwdfl JX3/1OFaZ+uiJLxigDRVk9NJ4XA0qACtQpdiIErTNynhNX7XTMmgRe0Z41EX5k++2hY2 ORHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=rp5bisnZRIlvkOVcULc9p3rwK/sWuztjt2k1H7KDAfQ=; b=cBFNw8Fd0ioJc7ow/Y2X1WzzKrjTGbdmJeFj5hnDHxmfHozcG1jBCA2I+GhHZ3Qzxh KpP/8P/ppwfWkVriRBtAHoQ4yWEM+EmzxfteWe9BlGi8lHSToRlwXQLBu/wSucvTdufu jdLi9V73r0JtBUQmhHniM0d8lwbo31yRVGF9P7z2gWAF3z1fUt7fGGNruMqytqJh3Rp8 MtLyZl0RXAg8ALGVsWxnzj4iImLSnfRxgqX/LqgCpo89RaQVA8r++77HyBf7siTWEP/Q wyT/xrAjsBuYzmc404qqfTUzCbZGEs1Zg5Hgl+Tqqn66XiHxqTZhlHdHyVGK7r99UVf8 19qQ== X-Gm-Message-State: AOAM531bx1ooJw0m0CDYUc54NBP+gw1TA6oNTi8Vl9TkUoL2B4m+Q1WI NQvQhu2EpUa1rfm79RNyX2vxUL1Y+4U= X-Google-Smtp-Source: ABdhPJwTVN+wi8jQkjmarRFNIV3OaYZvRk1Tl74M8e7Ibeul8aEQeJx6ip506QOlgS45sOWqWwybHg== X-Received: by 2002:ac8:4802:: with SMTP id g2mr844465qtq.235.1606161946045; Mon, 23 Nov 2020 12:05:46 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id q20sm10483657qke.0.2020.11.23.12.05.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:05:45 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK5iiG010328 for ; Mon, 23 Nov 2020 20:05:44 GMT Subject: [PATCH v3 20/85] NFSD: Replace READ* macros in nfsd4_decode_create() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:05:44 -0500 Message-ID: <160616194425.51996.675897939196905539.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org A dedicated decoder for component4 is introduced here, which will be used by other operation decoders in subsequent patches. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 58 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 9b295c810ef3..59f5cd2575bc 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -92,6 +92,8 @@ check_filename(char *str, int len) if (len == 0) return nfserr_inval; + if (len > NFS4_MAXNAMLEN) + return nfserr_nametoolong; if (isdotent(str, len)) return nfserr_badname; for (i = 0; i < len; i++) @@ -205,6 +207,27 @@ static char *savemem(struct nfsd4_compoundargs *argp, __be32 *p, int nbytes) return ret; } +static __be32 +nfsd4_decode_component4(struct nfsd4_compoundargs *argp, char **namp, u32 *lenp) +{ + __be32 *p, status; + + if (xdr_stream_decode_u32(argp->xdr, lenp) < 0) + return nfserr_bad_xdr; + p = xdr_inline_decode(argp->xdr, *lenp); + if (!p) + return nfserr_bad_xdr; + status = check_filename((char *)p, *lenp); + if (status) + return status; + *namp = svcxdr_tmpalloc(argp, *lenp); + if (!*namp) + return nfserr_jukebox; + memcpy(*namp, p, *lenp); + + return nfs_ok; +} + static __be32 nfsd4_decode_time(struct nfsd4_compoundargs *argp, struct timespec64 *tv) { @@ -698,24 +721,27 @@ nfsd4_decode_commit(struct nfsd4_compoundargs *argp, struct nfsd4_commit *commit static __be32 nfsd4_decode_create(struct nfsd4_compoundargs *argp, struct nfsd4_create *create) { - DECODE_HEAD; + __be32 *p, status; - READ_BUF(4); - create->cr_type = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &create->cr_type) < 0) + return nfserr_bad_xdr; switch (create->cr_type) { case NF4LNK: - READ_BUF(4); - create->cr_datalen = be32_to_cpup(p++); - READ_BUF(create->cr_datalen); + if (xdr_stream_decode_u32(argp->xdr, &create->cr_datalen) < 0) + return nfserr_bad_xdr; + p = xdr_inline_decode(argp->xdr, create->cr_datalen); + if (!p) + return nfserr_bad_xdr; create->cr_data = svcxdr_dupstr(argp, p, create->cr_datalen); if (!create->cr_data) return nfserr_jukebox; break; case NF4BLK: case NF4CHR: - READ_BUF(8); - create->cr_specdata1 = be32_to_cpup(p++); - create->cr_specdata2 = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &create->cr_specdata1) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &create->cr_specdata2) < 0) + return nfserr_bad_xdr; break; case NF4SOCK: case NF4FIFO: @@ -723,22 +749,18 @@ nfsd4_decode_create(struct nfsd4_compoundargs *argp, struct nfsd4_create *create default: break; } - - READ_BUF(4); - create->cr_namelen = be32_to_cpup(p++); - READ_BUF(create->cr_namelen); - SAVEMEM(create->cr_name, create->cr_namelen); - if ((status = check_filename(create->cr_name, create->cr_namelen))) + status = nfsd4_decode_component4(argp, &create->cr_name, + &create->cr_namelen); + if (status) return status; - status = nfsd4_decode_fattr4(argp, create->cr_bmval, ARRAY_SIZE(create->cr_bmval), &create->cr_iattr, &create->cr_acl, &create->cr_label, &create->cr_umask); if (status) - goto out; + return status; - DECODE_TAIL; + return nfs_ok; } static inline __be32 From patchwork Mon Nov 23 20:05:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22578C64E8A for ; Mon, 23 Nov 2020 20:05:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9B2A2071E for ; Mon, 23 Nov 2020 20:05:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KOyKRc2B" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728444AbgKWUFw (ORCPT ); Mon, 23 Nov 2020 15:05:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728038AbgKWUFw (ORCPT ); Mon, 23 Nov 2020 15:05:52 -0500 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 315DCC0613CF for ; Mon, 23 Nov 2020 12:05:52 -0800 (PST) Received: by mail-qk1-x743.google.com with SMTP id b144so3719185qkc.13 for ; Mon, 23 Nov 2020 12:05:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=JgH9BpW90l8ZCvcLzt4BID4EhzQfgb2TOjzLRJKep9A=; b=KOyKRc2BnSKfL5VcYdaRZzJQlKxwEenmbwMXyNjYIh5aKlFigXtdIM0tZ86EPfDxUz t6EC+1ktp284tcb9fUM4dMoaS+R8agaDbI046LnfFlqC3YoVK8N/8W9gS0yszqADSL6/ dcZyqa1+Xm+4NJ8dqscFRXKB8C+wYsniu/BqnyJcVp/r/RRf0LUfTo1fZ4jVhU1nNPNQ eeEY4uUMO4v4pVeeqEQXNmBWGzYTYvMKRa2OL+PfSa3U3NKucmppTTLXbeJZ/VeLJKmD tMq6S1hUfjMx7lhhI4bw1Qzq/8F5qcQvT2PifLEJrc4DDaTcEMhoryle9Y+oCr09uh/D /Q1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=JgH9BpW90l8ZCvcLzt4BID4EhzQfgb2TOjzLRJKep9A=; b=P27C5sndSHfI91jMVDusCVw5no8AqV6pFXTDWsO7l5NeEyN0ohIEY6GahaceAFEYmz WJdQDaqZaIee0sYPGqeofEiZm94z49oYGAXU6JSz3C0wb+/lqV3Qf8HYmZojyln9YQtl CBoEz1Wcm7DyP49XsmNi+jwBjo8hhTcB5NQ1ZGlSBU1Pe6Uv78pp+gtw0HGngNEptCjE I/txmBSW9G6uYbOgcDovLQLd+QMNDuWWWmdMCz/VBSFsRKzEKaUG5mQmxelS9p+x4r5i ThrfSeISW4SrshzmlelZ9LhkxU51Jfi6TH+OkhUWP7WnC3QWWaIObQCFEQNWHRLrVhun jhBQ== X-Gm-Message-State: AOAM530srMEty5fSCXCKBAauSTmN5HRA7YXHXrN3tMQ8fT542Lzcv33u JoVix5ud8y4pPWPPVrTWCSfLKtRQNQ8= X-Google-Smtp-Source: ABdhPJz5iX79SDV0wvA8gL2Pb4O2dPZnS+vL78UJ6lPCYcFrJiJask34AOn8zuTeCxKUPOa4/P8XdQ== X-Received: by 2002:a37:793:: with SMTP id 141mr1259847qkh.215.1606161951133; Mon, 23 Nov 2020 12:05:51 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id k4sm10309601qtp.5.2020.11.23.12.05.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:05:50 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK5nKg010331 for ; Mon, 23 Nov 2020 20:05:49 GMT Subject: [PATCH v3 21/85] NFSD: Replace READ* macros in nfsd4_decode_delegreturn() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:05:49 -0500 Message-ID: <160616194954.51996.14513409527990281508.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 59f5cd2575bc..cdddc62a8fb4 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -766,7 +766,7 @@ nfsd4_decode_create(struct nfsd4_compoundargs *argp, struct nfsd4_create *create static inline __be32 nfsd4_decode_delegreturn(struct nfsd4_compoundargs *argp, struct nfsd4_delegreturn *dr) { - return nfsd4_decode_stateid(argp, &dr->dr_stateid); + return nfsd4_decode_stateid4(argp, &dr->dr_stateid); } static inline __be32 From patchwork Mon Nov 23 20:05:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2975C6379F for ; Mon, 23 Nov 2020 20:05:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4A3432071E for ; Mon, 23 Nov 2020 20:05:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UG9rmZmP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728996AbgKWUF5 (ORCPT ); Mon, 23 Nov 2020 15:05:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728023AbgKWUF5 (ORCPT ); Mon, 23 Nov 2020 15:05:57 -0500 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 726DAC0613CF for ; Mon, 23 Nov 2020 12:05:57 -0800 (PST) Received: by mail-qk1-x744.google.com with SMTP id b144so3719517qkc.13 for ; Mon, 23 Nov 2020 12:05:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=dA7k7olRk4kkAkR4xkyhBYkPn9T2qeHnB5GxQHiwkqI=; b=UG9rmZmPEKnONLbYfaZDnTxz9+a5HOJWxJoeq6OGUZ2alzBZ6noQbouRSv+qiakIUr /nESr+sNI1yU8P/f+JmbgS6eVe8eMtoHmnZXFr++Gx8Vfbfharkw4E/kZkVBfIDXrQ/m uL6V5Lvmj4KvOgR9zSetb3SOLYQDjc8qLxmhwwJ4H2lRlFCiYUt2Cd0gNAOTVIU8S5JE TfnTgxBACo1B3zLaD36aKXVd6z3adiL3KMKxGj6Rw5dmZ8iyOIcr53V+gQhku/ylYkO0 fdH/wlk14pCas4e4xtaoy8jc86mFhpAr9T0iVx6mL4zmkOtQ6TU46zZY3/th3CxZD/Gt YBAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=dA7k7olRk4kkAkR4xkyhBYkPn9T2qeHnB5GxQHiwkqI=; b=VgdBDiAM7oh+vUxjEVp9DWhlWIjy8fo+8fgL5/npUmcVb3v+BoSGK8d7vHBLTribYV TPglwgmCLbaBC6DGG2c2jh9NlHspPiQnhFWuG/udEOr7R5PN9rw1xdd1OUo5ELdGbifk VqMKbXfZcLmkOCoXW+hQM4qA/wVT6tbdX+5QmXcCWnDo6PMtiul4GxTO4Ftue3txwom9 GFenUke0fErYnHk8H1eHlw3D7GMGYbKv3Xy0tgAP7ZhF66e+vE/miySsL7qnmbfhNWT7 h3i/npbIUUME+6TfdkONmlhqk4NADssI2k9jF1ugn6Gh//ZLj3L+XPgMsPb2cnpY8Axf K8UA== X-Gm-Message-State: AOAM530TyVfYRCryLTIlHkfvBWlbrC1kYWLztUBag2+PsSE/cPB3qCaJ wg2SkumcMSm9GoDCnuW29wnJ5O9vPqs= X-Google-Smtp-Source: ABdhPJzEoE8wtnSUpbY1dMbkcIqo0OygbJwtRH+lArGCY50hcRtYX4iJtBAW4TRhqW28OMdu+bm3qA== X-Received: by 2002:a37:9d16:: with SMTP id g22mr1281950qke.62.1606161956439; Mon, 23 Nov 2020 12:05:56 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id j17sm10104317qtn.2.2020.11.23.12.05.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:05:55 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK5s1j010334 for ; Mon, 23 Nov 2020 20:05:54 GMT Subject: [PATCH v3 22/85] NFSD: Replace READ* macros in nfsd4_decode_getattr() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:05:54 -0500 Message-ID: <160616195482.51996.18437989779703151829.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index cdddc62a8fb4..52e461969f09 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -772,7 +772,8 @@ nfsd4_decode_delegreturn(struct nfsd4_compoundargs *argp, struct nfsd4_delegretu static inline __be32 nfsd4_decode_getattr(struct nfsd4_compoundargs *argp, struct nfsd4_getattr *getattr) { - return nfsd4_decode_bitmap(argp, getattr->ga_bmval); + return nfsd4_decode_bitmap4(argp, getattr->ga_bmval, + ARRAY_SIZE(getattr->ga_bmval)); } static __be32 From patchwork Mon Nov 23 20:06:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD53AC2D0E4 for ; Mon, 23 Nov 2020 20:06:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C00820717 for ; Mon, 23 Nov 2020 20:06:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NKS8h1r7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728023AbgKWUGD (ORCPT ); Mon, 23 Nov 2020 15:06:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41742 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729117AbgKWUGC (ORCPT ); Mon, 23 Nov 2020 15:06:02 -0500 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C36E6C061A4D for ; Mon, 23 Nov 2020 12:06:02 -0800 (PST) Received: by mail-qt1-x842.google.com with SMTP id f27so4790704qtv.6 for ; Mon, 23 Nov 2020 12:06:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=+C9OJnuEYoXcbVXmnzeB8sVuBQr/3jK7A/BGCrmeWk8=; b=NKS8h1r7S/LfjRLGSvZn46AaTjdDQUuebcA+ZD1inn0+8YDTVUXthkl4FLPg1ChGq0 1GNSwoqBs33l8oI+dHq5AOzeFyybRgIQSv21wn7UCGfih7f5hyTQEI29cANOWO3DdF00 vUNIo2CJL8f2WNvZofB/0AJ0aG+j71+EqSqxMpUQZt1kq0tvmZ2ACPIouMfEP8f7FbZv FxLP4A4/QdsqqXLbTqSrT4aQ2/6RrfjjKJZetf0UJIHcdg4i22TBMA7pkJ5uOZPLfmr7 UJLREHX9d2E4u2WclCETIdKmKA22yZYCpC8wXfm+O9onl4beC3sdKKvbx1BCyYlwhsIy w3CQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=+C9OJnuEYoXcbVXmnzeB8sVuBQr/3jK7A/BGCrmeWk8=; b=Sthw3cuce6a9cQc+Wr+55/IQSrtg3zXeVL87V9ncvYxX3j2AkqAuXDrsRePrCe1LCZ YSKvQBH4mbc58K8bI96pC1XoOnBg5IJPKNBGSsLjzs3DoM3uFtyvontk2UCc6lVsvYyt Y7AHBM+fPm8077iJCgttt35Xfa2+LYiGpDMvjXEMejFUiyXzZJi5Uqf2X7oBJaLboXEv vrcGUeRtgJxcUj2wHyBdCAC7QCN0ee6vZ/zr3dY3DVVMJsmpSUsCZ1ZVk5KtCqL0RmdM 2Z1yOEd5TETMaFKWsi3ETzlkI2qpz9QifdgKXWkuxF1QxiF/nZXDgK/7kp/tHakK/XPW qrRA== X-Gm-Message-State: AOAM530eWvgvAqSQb1T8BXOBpeejthsBDDI6iyFh8rG+00DA9tIgDbvg AguFv2vZXaaThp3K51QXBHU95P9ZXmQ= X-Google-Smtp-Source: ABdhPJwlSiiOIcvx9bzMS4GJEKasiL725u9Z4e6mI+QHCvWL2gQnHkIPciO36/q6bW6rhMMsNo1bDg== X-Received: by 2002:ac8:5411:: with SMTP id b17mr850381qtq.281.1606161961741; Mon, 23 Nov 2020 12:06:01 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id b197sm10546161qkg.65.2020.11.23.12.06.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:06:01 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK60Wm010337 for ; Mon, 23 Nov 2020 20:06:00 GMT Subject: [PATCH v3 23/85] NFSD: Replace READ* macros in nfsd4_decode_link() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:06:00 -0500 Message-ID: <160616196011.51996.16491219201037247295.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 52e461969f09..472d715e8632 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -779,16 +779,7 @@ nfsd4_decode_getattr(struct nfsd4_compoundargs *argp, struct nfsd4_getattr *geta static __be32 nfsd4_decode_link(struct nfsd4_compoundargs *argp, struct nfsd4_link *link) { - DECODE_HEAD; - - READ_BUF(4); - link->li_namelen = be32_to_cpup(p++); - READ_BUF(link->li_namelen); - SAVEMEM(link->li_name, link->li_namelen); - if ((status = check_filename(link->li_name, link->li_namelen))) - return status; - - DECODE_TAIL; + return nfsd4_decode_component4(argp, &link->li_name, &link->li_namelen); } static __be32 From patchwork Mon Nov 23 20:06:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926261 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3887C63777 for ; Mon, 23 Nov 2020 20:06:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86BD82071E for ; Mon, 23 Nov 2020 20:06:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R4N5mxMY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729170AbgKWUGI (ORCPT ); Mon, 23 Nov 2020 15:06:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729117AbgKWUGI (ORCPT ); Mon, 23 Nov 2020 15:06:08 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EE20C0613CF for ; Mon, 23 Nov 2020 12:06:08 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id u184so3652975qkf.3 for ; Mon, 23 Nov 2020 12:06:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=GbbuIt6bNV9R56FKI3sLcSwWIUfDrNRC3We1Pu2tUGg=; b=R4N5mxMYYWuh5n7knvssW+GKhkOALNSbxT8+R0OE7ItZmquE9MgenZM2faZzFZpkzb B7sYL2Gin+BWxMhVkpvKull/bvK/RI9Pj12KybV2LmlcCFonc3RhcyNriIblgr20McW7 hWgEY8GAjbS182ZgsFHTVSi4qDH6KrbwIrcz4ErDF7mLroJ7PzsZ5yqJecAaO83/pKA3 QGxEOl/KO8kT9nmSkBGA/oWzrDc7Z+GBtYPQ2TorO+OZKW2kEcRAl7dIlp/Bl8EDd/Ev OhJfwBbjwv+7Wml/FT321dukZOfkDX3SGis11eEo9wsxApXB3bcFfyL4I2o/w1o5NjTe sy3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=GbbuIt6bNV9R56FKI3sLcSwWIUfDrNRC3We1Pu2tUGg=; b=IlUSiMzg8ajDCfL1RA/Nf9PQRN9Jopitwkrx/DKFoT8yjR7uT55HFqcBV4Y2Q8YKIE hzGFB+ITLdtcLQiRMD3EvzsNMut8Pua6Oo51/WAticbXJ11h+/wuX6DszQZC8LlNs9RU FgC/isld6u2wkj7fS5uZHe+7XTvT2Br2t53dpSaozy5eRCl0K3ExuQFx/g/GAy2AYmAT lkLw1t2hZtPdMwTDNCKTTYHYM18lp9g9wc0+2GYcRdwvcsl05t/DrOKbHuc4qEnlImJL AoBswMZwwFdLMjKw/SpVb/Pb8ujlxw2r0DkPp0zLe6gjKBsyqrup9BBDjFRjnmuS9jqg /JDg== X-Gm-Message-State: AOAM533GvSuTto59uoS4WNH09qUUGwPwaqznUJXPIfvBcVQc4NX/KW1J fkHvUAkQVsf2HsKE03dl9QrGj9TtOG0= X-Google-Smtp-Source: ABdhPJyL7CgiSsEz5nDuHLfQB7TXgox5y+PV7jBIsAWjIcvqAlad3lcv5fbaGZ2jibJCpDL3jDh4TA== X-Received: by 2002:ae9:c001:: with SMTP id u1mr1306105qkk.74.1606161967025; Mon, 23 Nov 2020 12:06:07 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id b64sm10354147qkg.19.2020.11.23.12.06.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:06:06 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK65ei010340 for ; Mon, 23 Nov 2020 20:06:05 GMT Subject: [PATCH v3 24/85] NFSD: Relocate nfsd4_decode_opaque() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:06:05 -0500 Message-ID: <160616196539.51996.2006468103191305772.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Enable nfsd4_decode_opaque() to be used in more decoders, and replace the READ* macros in nfsd4_decode_opaque(). Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 472d715e8632..a8e0cf30b073 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -207,6 +207,33 @@ static char *savemem(struct nfsd4_compoundargs *argp, __be32 *p, int nbytes) return ret; } + +/* + * NFSv4 basic data type decoders + */ + +static __be32 +nfsd4_decode_opaque(struct nfsd4_compoundargs *argp, struct xdr_netobj *o) +{ + __be32 *p; + u32 len; + + if (xdr_stream_decode_u32(argp->xdr, &len) < 0) + return nfserr_bad_xdr; + if (len == 0 || len > NFS4_OPAQUE_LIMIT) + return nfserr_bad_xdr; + p = xdr_inline_decode(argp->xdr, len); + if (!p) + return nfserr_bad_xdr; + o->data = svcxdr_tmpalloc(argp, len); + if (!o->data) + return nfserr_jukebox; + o->len = len; + memcpy(o->data, p, len); + + return nfs_ok; +} + static __be32 nfsd4_decode_component4(struct nfsd4_compoundargs *argp, char **namp, u32 *lenp) { @@ -943,22 +970,6 @@ static __be32 nfsd4_decode_share_deny(struct nfsd4_compoundargs *argp, u32 *x) return nfserr_bad_xdr; } -static __be32 nfsd4_decode_opaque(struct nfsd4_compoundargs *argp, struct xdr_netobj *o) -{ - DECODE_HEAD; - - READ_BUF(4); - o->len = be32_to_cpup(p++); - - if (o->len == 0 || o->len > NFS4_OPAQUE_LIMIT) - return nfserr_bad_xdr; - - READ_BUF(o->len); - SAVEMEM(o->data, o->len); - - DECODE_TAIL; -} - static __be32 nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) { From patchwork Mon Nov 23 20:06:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926265 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 377D0C63697 for ; Mon, 23 Nov 2020 20:06:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C633A20717 for ; Mon, 23 Nov 2020 20:06:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O7b8SDmB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728229AbgKWUGO (ORCPT ); Mon, 23 Nov 2020 15:06:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727976AbgKWUGN (ORCPT ); Mon, 23 Nov 2020 15:06:13 -0500 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7199EC0613CF for ; Mon, 23 Nov 2020 12:06:13 -0800 (PST) Received: by mail-qt1-x841.google.com with SMTP id t5so14378064qtp.2 for ; Mon, 23 Nov 2020 12:06:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=VeDTefz8milJ3+D/S6QPtfef+my+HTG4hC2pLPcIbw8=; b=O7b8SDmBmXcSdF4cxFBv9UhzwMFe9H4cVDC+ja+DbGM5moOM83Fmf+zZBLs6aWsNRA CqK+8KkjSrgsthhNs+mIHlu8upTvNkJrrg2BGG8hSbg4RYY3eC6URmbliixfxizOTxOC 0sDBvvCqXGA5ttHCsgI1CsuePkMNwfeV9kRC8+CW6hvUv3bwbYdqCUgUSmR76yE1CK19 VCxRph6REPL9rt2fXv8le3d1K2GZLSXgH2FFFQblr4byy0cqGwbSoYpS5s8ONaZybOq+ eVIT/lA5NTeI8xM4FGwod9Y3/afzPbx8l3T5KDZKTBhtkjSDyai9cwArCBI/vqiUKtlL JHMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=VeDTefz8milJ3+D/S6QPtfef+my+HTG4hC2pLPcIbw8=; b=PICv0qcdeRjH2hE946S7PWmr/K4uE5IECTp4fqo870sIrxaO0pAf5w+8R7/veHQGPi hwZvZmuLaQCZHkBYpEZMGjz7/ESTzIuTXYGoirYgRUfWArPtrddKK1uusLcpOyutOeFz /IChEfkJSIIrvjmblTGYtQyMrtkd3c59iIatzWbK09w/QkczNg5VtTAGIdPM7Z14+kxT pjb/KMoCdiTpKwJcTQrillxA3XBFuDIXpFqQnkncpOxlfmFK954gyG2NMtn5X04IbWLs u1IsYvhh5cBCNAn0mQ3qzgnuj3VJziyV9lxj0NJ8SlmnJWvLCS6LrGoQxKvYj74v8514 /gZg== X-Gm-Message-State: AOAM530J7Ba4DidmfdRaD3nUXtOsxS9lt+q2FrKq0dmJbqXhHMRC7shO bXkbftEXtUShbCz6jdOc/s93d5kuxjY= X-Google-Smtp-Source: ABdhPJyvBDm+zF0YyDGt0+8pbl+UqCQZ7JP6yzQrIMkRZWFF9uj+BbC3dtAUlLmLqIHBz1L1x2uDtw== X-Received: by 2002:ac8:7604:: with SMTP id t4mr899649qtq.366.1606161972391; Mon, 23 Nov 2020 12:06:12 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id t56sm9482233qth.27.2020.11.23.12.06.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:06:11 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK6Act010343 for ; Mon, 23 Nov 2020 20:06:10 GMT Subject: [PATCH v3 25/85] NFSD: Add helpers to decode a clientid4 and an NFSv4 state owner From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:06:10 -0500 Message-ID: <160616197068.51996.12752805251670283872.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org These helpers will also be used to simplify decoders in subsequent patches. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index a8e0cf30b073..dec383225722 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -609,6 +609,30 @@ nfsd4_decode_stateid4(struct nfsd4_compoundargs *argp, stateid_t *sid) return nfs_ok; } +static __be32 +nfsd4_decode_clientid4(struct nfsd4_compoundargs *argp, clientid_t *clientid) +{ + __be32 *p; + + p = xdr_inline_decode(argp->xdr, sizeof(__be64)); + if (!p) + return nfserr_bad_xdr; + memcpy(clientid, p, sizeof(*clientid)); + return nfs_ok; +} + +static __be32 +nfsd4_decode_state_owner4(struct nfsd4_compoundargs *argp, + clientid_t *clientid, struct xdr_netobj *owner) +{ + __be32 status; + + status = nfsd4_decode_clientid4(argp, clientid); + if (status) + return status; + return nfsd4_decode_opaque(argp, owner); +} + static __be32 nfsd4_decode_cb_sec(struct nfsd4_compoundargs *argp, struct nfsd4_cb_sec *cbs) { DECODE_HEAD; @@ -832,12 +856,12 @@ nfsd4_decode_lock(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock) status = nfsd4_decode_stateid(argp, &lock->lk_new_open_stateid); if (status) return status; - READ_BUF(8 + sizeof(clientid_t)); + READ_BUF(4); lock->lk_new_lock_seqid = be32_to_cpup(p++); - COPYMEM(&lock->lk_new_clientid, sizeof(clientid_t)); - lock->lk_new_owner.len = be32_to_cpup(p++); - READ_BUF(lock->lk_new_owner.len); - READMEM(lock->lk_new_owner.data, lock->lk_new_owner.len); + status = nfsd4_decode_state_owner4(argp, &lock->lk_new_clientid, + &lock->lk_new_owner); + if (status) + return status; } else { status = nfsd4_decode_stateid(argp, &lock->lk_old_lock_stateid); if (status) From patchwork Mon Nov 23 20:06:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926267 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75101C63798 for ; Mon, 23 Nov 2020 20:06:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19A462071E for ; Mon, 23 Nov 2020 20:06:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="stJxWUGi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729117AbgKWUGT (ORCPT ); Mon, 23 Nov 2020 15:06:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728360AbgKWUGS (ORCPT ); Mon, 23 Nov 2020 15:06:18 -0500 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F202C0613CF for ; Mon, 23 Nov 2020 12:06:18 -0800 (PST) Received: by mail-qt1-x842.google.com with SMTP id g17so14367211qts.5 for ; Mon, 23 Nov 2020 12:06:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=QZScK38Ffc/kD+dSDrz6Tn8jmqVc0fYHXXAEhUoDq1g=; b=stJxWUGiJIxzt3rJIG4qTZpbmUB9C9Fpd6iBw621ukf7XrbDUtznFf3WmMUzsWEQiQ bErQSmpAJh1nkFjcnlcOlgelomoUgOqG/qH/JU11wySgfjcJOONWRcv9dUuvE1h+Dyj8 YgENjV8MGyK8FpEjNFcBZiTpAF2CHG43U0KzayFO6gQT/85ozQreh4kNsV4f1V0kBkHd mq17jO+9OWxYmDZ29jsBYuBRg0F6ngy1ZjehIHeLiv90+QgVlNlIzJDralpeHkMJv1Ih Zgieq6vhlV0TaW9QX197tMVJ60X1HI7Eodfvljg2fr8yL6JNUTWKe5gMmir8rctba8Cb N4kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=QZScK38Ffc/kD+dSDrz6Tn8jmqVc0fYHXXAEhUoDq1g=; b=iSWxm/NrUJuYDYN9Ezh/FVca/EtelJ1qVnAfPCccDkyU6j2w5aHChwRTENWv48yxS/ 4D6cpN1SXNqfs+gskNqvrXHP/DyLSeefw5pADXBGyD3UbapHpemq1bRTDG4qXP2W4XNo 5dHuy46FlEx8GBkMViyKfb/sN7Q42s/+4CyP5rNSkBfFOYorHfjUXhWXr9XclkKXkpB0 ETdtBA5CCnkW133q4TI5xpUh+jj7qoeEhFDK1y5tlps+9ocWBu2LvSXUgLGW8S8INWZd sjMW7YBL7H5ZXgKDpyaou0RdQOgxW3fe2Y8OAepr0bWxMtWiW9p9Om+MDL+nh39PFdBL nSpQ== X-Gm-Message-State: AOAM530udOp+EKYGTjUvu1MBEe17s9b9VtNWoqe/iRkHccZvHI/r9NnU DNhqroXAEYwpbPUy8jzyxFNelMjzq30= X-Google-Smtp-Source: ABdhPJygwH6mUDsLmEGyCMxN0ayYU+/lsnr11ZxIK/3UXkEJVkFeOe8GVpG3sHDx5vQ+Ruge28PxbQ== X-Received: by 2002:ac8:380f:: with SMTP id q15mr893233qtb.102.1606161977566; Mon, 23 Nov 2020 12:06:17 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id t51sm9704694qtb.11.2020.11.23.12.06.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:06:16 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK6FSR010346 for ; Mon, 23 Nov 2020 20:06:15 GMT Subject: [PATCH v3 26/85] NFSD: Add helper for decoding locker4 From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:06:15 -0500 Message-ID: <160616197596.51996.1992350133667838568.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Refactor for clarity. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 64 ++++++++++++++++++++++++++++++-------------- include/linux/sunrpc/xdr.h | 21 ++++++++++++++ 2 files changed, 64 insertions(+), 21 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index dec383225722..a209f3c8ec06 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -833,6 +833,48 @@ nfsd4_decode_link(struct nfsd4_compoundargs *argp, struct nfsd4_link *link) return nfsd4_decode_component4(argp, &link->li_name, &link->li_namelen); } +static __be32 +nfsd4_decode_open_to_lock_owner4(struct nfsd4_compoundargs *argp, + struct nfsd4_lock *lock) +{ + __be32 status; + + if (xdr_stream_decode_u32(argp->xdr, &lock->lk_new_open_seqid) < 0) + return nfserr_bad_xdr; + status = nfsd4_decode_stateid4(argp, &lock->lk_new_open_stateid); + if (status) + return status; + if (xdr_stream_decode_u32(argp->xdr, &lock->lk_new_lock_seqid) < 0) + return nfserr_bad_xdr; + return nfsd4_decode_state_owner4(argp, &lock->lk_new_clientid, + &lock->lk_new_owner); +} + +static __be32 +nfsd4_decode_exist_lock_owner4(struct nfsd4_compoundargs *argp, + struct nfsd4_lock *lock) +{ + __be32 status; + + status = nfsd4_decode_stateid4(argp, &lock->lk_old_lock_stateid); + if (status) + return status; + if (xdr_stream_decode_u32(argp->xdr, &lock->lk_old_lock_seqid) < 0) + return nfserr_bad_xdr; + + return nfs_ok; +} + +static __be32 +nfsd4_decode_locker4(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock) +{ + if (xdr_stream_decode_bool(argp->xdr, &lock->lk_is_new) < 0) + return nfserr_bad_xdr; + if (lock->lk_is_new) + return nfsd4_decode_open_to_lock_owner4(argp, lock); + return nfsd4_decode_exist_lock_owner4(argp, lock); +} + static __be32 nfsd4_decode_lock(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock) { @@ -848,27 +890,7 @@ nfsd4_decode_lock(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock) lock->lk_reclaim = be32_to_cpup(p++); p = xdr_decode_hyper(p, &lock->lk_offset); p = xdr_decode_hyper(p, &lock->lk_length); - lock->lk_is_new = be32_to_cpup(p++); - - if (lock->lk_is_new) { - READ_BUF(4); - lock->lk_new_open_seqid = be32_to_cpup(p++); - status = nfsd4_decode_stateid(argp, &lock->lk_new_open_stateid); - if (status) - return status; - READ_BUF(4); - lock->lk_new_lock_seqid = be32_to_cpup(p++); - status = nfsd4_decode_state_owner4(argp, &lock->lk_new_clientid, - &lock->lk_new_owner); - if (status) - return status; - } else { - status = nfsd4_decode_stateid(argp, &lock->lk_old_lock_stateid); - if (status) - return status; - READ_BUF(4); - lock->lk_old_lock_seqid = be32_to_cpup(p++); - } + status = nfsd4_decode_locker4(argp, lock); DECODE_TAIL; } diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index cc669d95c484..9b35ce50cf2b 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -550,6 +550,27 @@ static inline bool xdr_item_is_present(const __be32 *p) return *p != xdr_zero; } +/** + * xdr_stream_decode_bool - Decode a boolean + * @xdr: pointer to xdr_stream + * @ptr: pointer to a u32 in which to store the result + * + * Return values: + * %0 on success + * %-EBADMSG on XDR buffer overflow + */ +static inline ssize_t +xdr_stream_decode_bool(struct xdr_stream *xdr, __u32 *ptr) +{ + const size_t count = sizeof(*ptr); + __be32 *p = xdr_inline_decode(xdr, count); + + if (unlikely(!p)) + return -EBADMSG; + *ptr = (*p != xdr_zero); + return 0; +} + /** * xdr_stream_decode_u32 - Decode a 32-bit integer * @xdr: pointer to xdr_stream From patchwork Mon Nov 23 20:06:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926263 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA148C6379F for ; Mon, 23 Nov 2020 20:06:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5568F20717 for ; Mon, 23 Nov 2020 20:06:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IEp3LFTJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728882AbgKWUGY (ORCPT ); Mon, 23 Nov 2020 15:06:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728360AbgKWUGY (ORCPT ); Mon, 23 Nov 2020 15:06:24 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36454C0613CF for ; Mon, 23 Nov 2020 12:06:24 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id v143so18259178qkb.2 for ; Mon, 23 Nov 2020 12:06:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=SjMO1Gd0veW9RySsvYEzSSao9vGqUk4dSoiUgcwekcs=; b=IEp3LFTJ3trN33al2uOHPkBeODmzQCEjAUUefhzg9VdLOghbgJVRGeB3yrODjcc0xE FFSRIST+PdRjZvEp2j06Tond3pISIe7PcVnVdlXs92jlFvCNYDHmCajZOFkwH3njghMI kolaru+/x3BSKC2WJZCGNstWYNkzuyre1wVYUY9yPfC3hB7AoqBFwwxXQQXk0gDCGhGj laJ/fSob4clC99J7BqHnMQgZOzfILsq6Ohzr/0huyilHsk09v7bNDdcxizBYQJYZjek9 NLVHpfqmdKWXM8IxfHcPvGgNJsWtj5yFaTXhgWZauvbzYsv8UoRVx+tSI3UQ469lqfdB g3Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=SjMO1Gd0veW9RySsvYEzSSao9vGqUk4dSoiUgcwekcs=; b=stNXyH/qVWDmT6NR4IoGc4+Vhb5v3vDtiFUSXzh+3chgCq6gdOr4x1mXwwmVHBhE2R l8+llOQ+SerFPXeq0GcaHfSI4E+pkCE/9fHfQryVT2oUKNQQwZ5NPwIqJWjym3wQcNcD pZIfJtEevJTy/KG8TTXhQg3ZVdCFjMQH81H53GRUW2kVEAZy7lXCyUEWp94X8NVcttSc CK5RbXC4MLvzOPvybGYSlABapSQC7mJBCepk9RqVCoMzJUFrX5rjnypWwR7PE9N+iWIW j9irkMF9HMk8s0ee1HADRWvSs9Hmu49FgLFntWYjykOY8725iHyj4PAvY8SiMdr09Ygn nbOQ== X-Gm-Message-State: AOAM531Z+M0T0LVG3mFq3MteQLOuORZ/Z2wPPKtt0ad62nuC8o72NUeF 62v/h7MTZLNf10gasEja/MC76oLHLyI= X-Google-Smtp-Source: ABdhPJyoKlupbwtVWLfX4amMJQ85qzTidF4dmqGg1yUsSFUjbWtMKiCSSf6bMpZp0UU6KlMHBVQoSA== X-Received: by 2002:a05:620a:1590:: with SMTP id d16mr1296447qkk.88.1606161983088; Mon, 23 Nov 2020 12:06:23 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id a20sm9696207qta.6.2020.11.23.12.06.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:06:22 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK6Lmo010349 for ; Mon, 23 Nov 2020 20:06:21 GMT Subject: [PATCH v3 27/85] NFSD: Replace READ* macros in nfsd4_decode_lock() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:06:21 -0500 Message-ID: <160616198125.51996.11334770723860822177.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index a209f3c8ec06..884ab920bcf8 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -878,21 +878,17 @@ nfsd4_decode_locker4(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock) static __be32 nfsd4_decode_lock(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock) { - DECODE_HEAD; - - /* - * type, reclaim(boolean), offset, length, new_lock_owner(boolean) - */ - READ_BUF(28); - lock->lk_type = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &lock->lk_type) < 0) + return nfserr_bad_xdr; if ((lock->lk_type < NFS4_READ_LT) || (lock->lk_type > NFS4_WRITEW_LT)) - goto xdr_error; - lock->lk_reclaim = be32_to_cpup(p++); - p = xdr_decode_hyper(p, &lock->lk_offset); - p = xdr_decode_hyper(p, &lock->lk_length); - status = nfsd4_decode_locker4(argp, lock); - - DECODE_TAIL; + return nfserr_bad_xdr; + if (xdr_stream_decode_bool(argp->xdr, &lock->lk_reclaim) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, &lock->lk_offset) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, &lock->lk_length) < 0) + return nfserr_bad_xdr; + return nfsd4_decode_locker4(argp, lock); } static __be32 From patchwork Mon Nov 23 20:06:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926269 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF386C6379D for ; Mon, 23 Nov 2020 20:06:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8AE3D2071E for ; Mon, 23 Nov 2020 20:06:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="oPXxyqCM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728360AbgKWUG3 (ORCPT ); Mon, 23 Nov 2020 15:06:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727976AbgKWUG3 (ORCPT ); Mon, 23 Nov 2020 15:06:29 -0500 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FB0BC0613CF for ; Mon, 23 Nov 2020 12:06:29 -0800 (PST) Received: by mail-qt1-x843.google.com with SMTP id p12so14334406qtp.7 for ; Mon, 23 Nov 2020 12:06:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=oMBp0l5ZIbayyU9TIa/DdEj+TEEASDrEhSoGu12Mdvo=; b=oPXxyqCMTagawatDsHIFkPqvBPgvga/zWZLBrI5MMNw+BxirlpcFQvHR8zqOa2CnBu ASCR6mNhtUDffu+JB94me4Gf1fnlCC2z3KScIeCjhMRO+ZcsBZ+V5aFJ/VTIJc38/WOU lbpH+twurEFmBpnvTNC7249I5yQHx2gUrM/B4ucXuKmBvl+PaDIfkzlIZTQiHzrE5Gtw PrGx7tbSHu3W4/Y9RhlqLAW6dvBU7Dc47NHJUgCyCXgJVz8CUyEaXhqYpR0s5MB2ZJZG akvDgNYoeG/UNWm+RWiTSXTVR9d/WyVYfsCrnStMt6HfEMVYhWhkCrW6Nx4c4NBOhNUT Dl9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=oMBp0l5ZIbayyU9TIa/DdEj+TEEASDrEhSoGu12Mdvo=; b=biR0V3Lkc9PepX/XmS7wTi17/OsoupO4W4aBKJUeWe7qz/QdwMGiaXzaiZKnQWxxoF wxpxeoI+esg2o7mu9M19TCplcZPev6ZDu6WAC8SFNWJgsSjZtSmbDSWO0RQyjWXrwLcS JPQ89xHiZAcPfPcRIx707QajMLfEGZnsRr1BT8enhz+kiTULsROX0wB35ZWwvNNwBUy3 4Yra99jJpUKpen61vUKVI+SMIdYtsir5V+uqWQ7XB9AouP7ccAZ2HnZM17x236O2VhLh gpHg5TXbNZkdLPIt83h4SLblwT1yBjQ/Yn71UGE0b5w4Z0Vk7k8V+R9/ICbxDYUVdJyB lmlw== X-Gm-Message-State: AOAM533Mb2ywOiTTUCVWk71ZoNwsybgfqwiCKNIQLcOUkBhp4yKsInZ2 qqkHVH+qelvThrmsFO29+CCZ47KlJQ8= X-Google-Smtp-Source: ABdhPJwqZ+mM8penVSDzVpGuXCG2W1CtWJLeSCckk5/gELHMxbl+A8qQBBbb5sV+b0fGb508TuS8XQ== X-Received: by 2002:ac8:590f:: with SMTP id 15mr889768qty.249.1606161988198; Mon, 23 Nov 2020 12:06:28 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id a85sm10632572qkg.3.2020.11.23.12.06.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:06:27 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK6QMZ010352 for ; Mon, 23 Nov 2020 20:06:26 GMT Subject: [PATCH v3 28/85] NFSD: Replace READ* macros in nfsd4_decode_lockt() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:06:26 -0500 Message-ID: <160616198654.51996.6109418844758808320.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 884ab920bcf8..e2bdc69db4f9 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -894,20 +894,16 @@ nfsd4_decode_lock(struct nfsd4_compoundargs *argp, struct nfsd4_lock *lock) static __be32 nfsd4_decode_lockt(struct nfsd4_compoundargs *argp, struct nfsd4_lockt *lockt) { - DECODE_HEAD; - - READ_BUF(32); - lockt->lt_type = be32_to_cpup(p++); - if((lockt->lt_type < NFS4_READ_LT) || (lockt->lt_type > NFS4_WRITEW_LT)) - goto xdr_error; - p = xdr_decode_hyper(p, &lockt->lt_offset); - p = xdr_decode_hyper(p, &lockt->lt_length); - COPYMEM(&lockt->lt_clientid, 8); - lockt->lt_owner.len = be32_to_cpup(p++); - READ_BUF(lockt->lt_owner.len); - READMEM(lockt->lt_owner.data, lockt->lt_owner.len); - - DECODE_TAIL; + if (xdr_stream_decode_u32(argp->xdr, &lockt->lt_type) < 0) + return nfserr_bad_xdr; + if ((lockt->lt_type < NFS4_READ_LT) || (lockt->lt_type > NFS4_WRITEW_LT)) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, &lockt->lt_offset) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, &lockt->lt_length) < 0) + return nfserr_bad_xdr; + return nfsd4_decode_state_owner4(argp, &lockt->lt_clientid, + &lockt->lt_owner); } static __be32 From patchwork Mon Nov 23 20:06:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926271 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29ED3C2D0E4 for ; Mon, 23 Nov 2020 20:06:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C545920717 for ; Mon, 23 Nov 2020 20:06:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QN7aCGWL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729235AbgKWUGf (ORCPT ); Mon, 23 Nov 2020 15:06:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729158AbgKWUGe (ORCPT ); Mon, 23 Nov 2020 15:06:34 -0500 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82E42C0613CF for ; Mon, 23 Nov 2020 12:06:34 -0800 (PST) Received: by mail-qt1-x843.google.com with SMTP id f93so14313340qtb.10 for ; Mon, 23 Nov 2020 12:06:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=2LwNUUWkDti5LAK63SJ53gwcMiEFz/uOOwzDlwjofOA=; b=QN7aCGWLmXeSmelozR6pCsvXGEKvV+F7bhpZA6yJcwiuek4mDGx2MBE0f2E5Ve0NIR 7sA7F2y371+YgP2wKYQbcbFxC4MlUQThTy0MyGX2YXXEo8mATK0BMv37TL/Qh4rii1aN 6OBMs9GQlcrXl9IdfFM+Gc3VADIWbAZ6+uvts1eIYposMA3mJ/h0TEhVb7Nc1aVu9Jdh YurBSqvP8YnQKse6F9/Qcv07NUtTBfJNHppjJIiV2MFD17hD63MQQoa9ESU66fUUVopt yhgnoISgQzgwE8UlFfLeg53qh8wNBGXaihqnrOPyiXP9rnfpdYIUVZu8DOECgpCLIwRj 7NHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=2LwNUUWkDti5LAK63SJ53gwcMiEFz/uOOwzDlwjofOA=; b=hHcgLgfFKALwtESrSi/ypVh7ASPl23+TWWDV66jBrAr+xG28z6ST+GN3AyoefA4bbD 4fW5x6IoYuNlniFmI6Q6MmFLaBSSgD595RS5J+4SfD3kjl6jvKTM6OiSJrgxxp9z/RIx YT7LdfXS5dz6kX5/d8G19SrvgQWefvBDGEyAoWQEKkuQR5TcjHCBaXJkJ05OKyKR3uS9 L6+K902ujvNQF3fgKMi83FabOVrqp2f2SWB+K4X7J+nO/mdquTaHo1gGoBy1m7hvU1c7 RCKbcdTTHoJpPXNG9MASJSeJmZYGsFaKgyUzGL0ZWDj37/9Fm7tpN0lD4YuCqyzlhnLl Gbsg== X-Gm-Message-State: AOAM530nM0+q28hxu2Kbv/pJM3B3xPxu7TN9O0LoNjp5lpf6UtdM4y5Z t2EnyQEQ4Eyuz4KM8sqGyrcNLHmNPug= X-Google-Smtp-Source: ABdhPJy4qAq2fwhIyiwThH/NLMYWjs9N4BvB+X5yq6Et5VaGOa3UF6T6IRxB68jJP6GyC1z+A9BbHA== X-Received: by 2002:ac8:130d:: with SMTP id e13mr883844qtj.3.1606161993489; Mon, 23 Nov 2020 12:06:33 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id r190sm10255717qkf.101.2020.11.23.12.06.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:06:32 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK6VuT010355 for ; Mon, 23 Nov 2020 20:06:31 GMT Subject: [PATCH v3 29/85] NFSD: Replace READ* macros in nfsd4_decode_locku() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:06:31 -0500 Message-ID: <160616199182.51996.8327994885103199696.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index e2bdc69db4f9..0e7032030cec 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -909,21 +909,23 @@ nfsd4_decode_lockt(struct nfsd4_compoundargs *argp, struct nfsd4_lockt *lockt) static __be32 nfsd4_decode_locku(struct nfsd4_compoundargs *argp, struct nfsd4_locku *locku) { - DECODE_HEAD; + __be32 status; - READ_BUF(8); - locku->lu_type = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &locku->lu_type) < 0) + return nfserr_bad_xdr; if ((locku->lu_type < NFS4_READ_LT) || (locku->lu_type > NFS4_WRITEW_LT)) - goto xdr_error; - locku->lu_seqid = be32_to_cpup(p++); - status = nfsd4_decode_stateid(argp, &locku->lu_stateid); + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &locku->lu_seqid) < 0) + return nfserr_bad_xdr; + status = nfsd4_decode_stateid4(argp, &locku->lu_stateid); if (status) return status; - READ_BUF(16); - p = xdr_decode_hyper(p, &locku->lu_offset); - p = xdr_decode_hyper(p, &locku->lu_length); + if (xdr_stream_decode_u64(argp->xdr, &locku->lu_offset) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, &locku->lu_length) < 0) + return nfserr_bad_xdr; - DECODE_TAIL; + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:06:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926273 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64620C63697 for ; Mon, 23 Nov 2020 20:06:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0DE6C20717 for ; Mon, 23 Nov 2020 20:06:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PSL/YOXX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728502AbgKWUGk (ORCPT ); Mon, 23 Nov 2020 15:06:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727070AbgKWUGk (ORCPT ); Mon, 23 Nov 2020 15:06:40 -0500 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5597C0613CF for ; Mon, 23 Nov 2020 12:06:39 -0800 (PST) Received: by mail-qv1-xf44.google.com with SMTP id n9so3154166qvp.5 for ; Mon, 23 Nov 2020 12:06:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=IHFKLqLkvQvOcOozT93LaBtAQD1dnOCJbXIkFKB9a1g=; b=PSL/YOXXp8GgyMIRE3F2BJM9JW8ZdYUxGWPQZNapdFRD3PeQYpPX6h+wSa0Yc5a/Nc QnAv0S6aj4S/4MY//caFF8PODJTl5sRgFgK4DEHJh0f0vDf15IrA0tCVQsn+A1LrhGoO 7sPgUj13TRtPl0ybZsh24ZrdvyV6yi5TPi6gsWreuxmVoy540mcVjAT+5JOfzoi7GVMq b1R90vHzf6UWquQGAKxUmrM/SPxaSjvMxJraNWTdGIoR2eZPAolEueVcVWOxph18DyA5 PWqOiLBImS0JAI6o08BOSRaja/mdD6kTCmeTHXhORzyD2iuQPzmXKWmdKJSHTI3/XUCK EESA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=IHFKLqLkvQvOcOozT93LaBtAQD1dnOCJbXIkFKB9a1g=; b=TLkcK/ipMmM66NGJkIusM6balveBAiAM1sAbkZHZZvQVmKMEV2cvEYHgd1gmjbH9YT NxeaL0bSrodgnnqaCDm5U6eXJgj9Hv3BuKUny/UnmIGbX1eDVAmwkRq628jV11mhHtac pCiYTPUj2E9c31TH+WX/j/xEMI/Sjz1b55nxxWahdS7lihKAULTactkbwvi8mhQxFtHz d9BIeIJ05CM11gKy7LYE6SPbmdnjQCn++RNsT3j8llaF7CwVZJfKMBTGmW6IZe/alGT2 vfkiT+JJqH/ziY/Wye5dIKD3Tqo31PsbSUlOkiec+edOx+XqULxn5fSS4fe01DsMj5bK vSeg== X-Gm-Message-State: AOAM533RG64bT6IZb4VSR5AfKJ1aUtd/LBy7gDpzeP5IcCJQJ9esbNSR X0orBDsrvLSd2HZA9qfo6YfyokVBs4w= X-Google-Smtp-Source: ABdhPJy5ihTgP4WXDSnrv6xZOjJ6Fen+ROAWRNtcpYIEotGCfdlHtGSlc+Tl8yGmT1JyNUrKUeJHyA== X-Received: by 2002:a0c:b29b:: with SMTP id r27mr1111262qve.50.1606161998882; Mon, 23 Nov 2020 12:06:38 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id a83sm10494899qkc.77.2020.11.23.12.06.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:06:38 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK6b4q010358 for ; Mon, 23 Nov 2020 20:06:37 GMT Subject: [PATCH v3 30/85] NFSD: Replace READ* macros in nfsd4_decode_lookup() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:06:37 -0500 Message-ID: <160616199710.51996.15161127418429912657.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 0e7032030cec..4c2a7b4877ad 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -931,16 +931,7 @@ nfsd4_decode_locku(struct nfsd4_compoundargs *argp, struct nfsd4_locku *locku) static __be32 nfsd4_decode_lookup(struct nfsd4_compoundargs *argp, struct nfsd4_lookup *lookup) { - DECODE_HEAD; - - READ_BUF(4); - lookup->lo_len = be32_to_cpup(p++); - READ_BUF(lookup->lo_len); - SAVEMEM(lookup->lo_name, lookup->lo_len); - if ((status = check_filename(lookup->lo_name, lookup->lo_len))) - return status; - - DECODE_TAIL; + return nfsd4_decode_component4(argp, &lookup->lo_name, &lookup->lo_len); } static __be32 nfsd4_decode_share_access(struct nfsd4_compoundargs *argp, u32 *share_access, u32 *deleg_want, u32 *deleg_when) From patchwork Mon Nov 23 20:06:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926275 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E62B7C2D0E4 for ; Mon, 23 Nov 2020 20:06:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91DE720717 for ; Mon, 23 Nov 2020 20:06:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xok1TxWb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727985AbgKWUGq (ORCPT ); Mon, 23 Nov 2020 15:06:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727070AbgKWUGq (ORCPT ); Mon, 23 Nov 2020 15:06:46 -0500 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47D8DC0613CF for ; Mon, 23 Nov 2020 12:06:45 -0800 (PST) Received: by mail-qk1-x744.google.com with SMTP id b144so3722489qkc.13 for ; Mon, 23 Nov 2020 12:06:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=7TwKR+cqMLnMzIbY8s27CBZOggaFds2ujj1KFsTMYhM=; b=Xok1TxWbvg189mMty2hYBAU0F6hOc871mXjfDPJlTrOTgN9cV/A8Kfemq8SdZ3Cdj7 BCxv4OZVQGC32fshWavro6LO3YYW+KIslIDudWKTNb87ikgKEi9ppsHUYf9t+u+2C+Vh xJNVDwOvo3TwiVicBs0jxq4i/Od/V6T/LWoJoui4QdlkuaGkUo4UISR/bLjI+/5up4Cl IsrAnwTRNlRFYuvGnbl4oICnHrmwGr51IIuZGBPn73/Ac0TU3TyuE/dNv3xpEbd7zp4G 8mHVIREuwaZ+f6QSYgodpdq4J3LdhDdZ8iC+HPjMLEtxtKVsekQg/T55pGnly3y7WBhU GFcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=7TwKR+cqMLnMzIbY8s27CBZOggaFds2ujj1KFsTMYhM=; b=Pc/RzuDHmuJgOrGiQpE8FtK0DnfqG86uUhOmRzN9DYMGRenLW7zxJkBzSPrsyWcfUO 6nlwMgG4nYkfHOSorGtksGI1YzpJNwYxgEoWAa7QEANtZXRhy+flZGOR26IsHjtuNPQP uzfwPRsiV/+3YqmnPQ3glE6/o/w/kzcgV3WWdWsQl8ztTGu2cE/pXGJ0DAo+xe7Ior1q Pd/V8cBBYwnyPXGmYkQCbkLYCB75FUd1gEkmWtFUPW7CO0jHFvA/gxew4uFO+j6OMYuz 1U5Tffc780u+dQO05z01YO8ulguC7nyGHuJpveuY4K44ZbIjbtEVm2iHh68ktARZqAm4 aVDQ== X-Gm-Message-State: AOAM530qRNBjhjL+Y/9dIHe3bgvsU3TsnByF9+yXIwAmCr5pxxjwRM2C f+32LwmzySqxRfs42m7caF6Q1bCeLlI= X-Google-Smtp-Source: ABdhPJzACqnVotwnCQhQlnZJU0K/6g+NPrDiyZuyDrYLlZfmbI409HbClHWd3JofBHIIg8DYhskmLA== X-Received: by 2002:a37:6697:: with SMTP id a145mr1286135qkc.296.1606162004120; Mon, 23 Nov 2020 12:06:44 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id p128sm6173745qkc.47.2020.11.23.12.06.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:06:43 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK6go2010361 for ; Mon, 23 Nov 2020 20:06:42 GMT Subject: [PATCH v3 31/85] NFSD: Add helper to decode NFSv4 verifiers From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:06:42 -0500 Message-ID: <160616200239.51996.5356570219804246528.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org This helper will be used to simplify decoders in subsequent patches. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 4c2a7b4877ad..7254c9e4e825 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -284,6 +284,18 @@ nfsd4_decode_nfstime4(struct nfsd4_compoundargs *argp, struct timespec64 *tv) return nfs_ok; } +static __be32 +nfsd4_decode_verifier4(struct nfsd4_compoundargs *argp, nfs4_verifier *verf) +{ + __be32 *p; + + p = xdr_inline_decode(argp->xdr, NFS4_VERIFIER_SIZE); + if (!p) + return nfserr_bad_xdr; + memcpy(verf->data, p, sizeof(verf->data)); + return nfs_ok; +} + static __be32 nfsd4_decode_bitmap(struct nfsd4_compoundargs *argp, u32 *bmval) { @@ -1047,14 +1059,16 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) goto out; break; case NFS4_CREATE_EXCLUSIVE: - READ_BUF(NFS4_VERIFIER_SIZE); - COPYMEM(open->op_verf.data, NFS4_VERIFIER_SIZE); + status = nfsd4_decode_verifier4(argp, &open->op_verf); + if (status) + return status; break; case NFS4_CREATE_EXCLUSIVE4_1: if (argp->minorversion < 1) goto xdr_error; - READ_BUF(NFS4_VERIFIER_SIZE); - COPYMEM(open->op_verf.data, NFS4_VERIFIER_SIZE); + status = nfsd4_decode_verifier4(argp, &open->op_verf); + if (status) + return status; status = nfsd4_decode_fattr4(argp, open->op_bmval, ARRAY_SIZE(open->op_bmval), &open->op_iattr, &open->op_acl, From patchwork Mon Nov 23 20:06:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 563FAC63697 for ; Mon, 23 Nov 2020 20:06:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE0B420717 for ; Mon, 23 Nov 2020 20:06:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kDrwvQ6T" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728003AbgKWUGv (ORCPT ); Mon, 23 Nov 2020 15:06:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727070AbgKWUGu (ORCPT ); Mon, 23 Nov 2020 15:06:50 -0500 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D866C0613CF for ; Mon, 23 Nov 2020 12:06:50 -0800 (PST) Received: by mail-qt1-x844.google.com with SMTP id p12so14335433qtp.7 for ; Mon, 23 Nov 2020 12:06:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=DoH1LJ+J6z+aK1+GGXSqu4NL2ViFiMSAjVGf3jGoDEI=; b=kDrwvQ6TXNr17fJPA+48svunq7ZCiAu318I/8pXA55wfoUdn/mOfTudoGe/YYRqoMY FZX7Wa0jBtvwgBjSOUsz29Y5lZRfvIDFMc/VACGGmwi3N+n0exyU/UMwMIcXoWcw8prB sIrzVmvzAbv51t33ZqxcYQyumTyKJEiFKxS3z8V5k3qcz8bL2jvPIoPIDEcv5EN2xChL mBWwVEmaY6fDFICU3K+ohYZXfNFFYOV+hsiASsUg0lc6W78c1ERg8BLQzH9sLYMKCyPv D/ISn78Qoh1m66DIHxMw3y35e67eXSjFIjvaNVa/vNO/zST3V3Ipyp1+Fg0Kr4bThqbn keFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=DoH1LJ+J6z+aK1+GGXSqu4NL2ViFiMSAjVGf3jGoDEI=; b=rP4qdYPWgdqUb/r6M7cqTy/koicjWxUJxnaSyF1Qim9vZSKHeoHuxk/DMYxaDaAZUr azb6nN5xyzR88Z+/YZQWh1AsZgNh7vs4GCespZdqCTX2Su1oDvDXXIgZve2hcRYRljY7 sgl4sYhk/AxU5p8KHm8kFnpiw57T4cN0bOPZKhjDibvbuqkaKU6NPxRmRZHLIo1H6S93 rdR4qE2Z+1daPxoyVwnHRHw9U+hKXLhD1Akx+QiSrem0+WLmr/STOEdjAI4ENb2MJAlr g3xF4YSEPh9YVwzRKDKPPI80CokMJn/9yVNGZbFKuU1LqF2pOMkEJoOLnOToW20bcFBf w1Ew== X-Gm-Message-State: AOAM530oKIjkikMNh5ZKGv8oWYNYXk68lofjDvsH+t2l9u919VUvn2DR /TVdYrJ7Oz62L47tYjwJDDPMhGlXliw= X-Google-Smtp-Source: ABdhPJxf2wJ8f2ebRxQsDpxKSnSo8vdUMnGUCrrehipG5+DbPEF+6RMaoQWJOvHU5EMxKV6omhKMbQ== X-Received: by 2002:ac8:678c:: with SMTP id b12mr902583qtp.258.1606162009382; Mon, 23 Nov 2020 12:06:49 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id y44sm11541260qtb.50.2020.11.23.12.06.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:06:48 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK6lQ8010364 for ; Mon, 23 Nov 2020 20:06:47 GMT Subject: [PATCH v3 32/85] NFSD: Add helper to decode OPEN's createhow4 argument From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:06:47 -0500 Message-ID: <160616200767.51996.18156890288117799942.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Refactor for clarity. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 78 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 7254c9e4e825..579139d727ea 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -946,6 +946,48 @@ nfsd4_decode_lookup(struct nfsd4_compoundargs *argp, struct nfsd4_lookup *lookup return nfsd4_decode_component4(argp, &lookup->lo_name, &lookup->lo_len); } +static __be32 +nfsd4_decode_createhow4(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) +{ + __be32 status; + + if (xdr_stream_decode_u32(argp->xdr, &open->op_createmode) < 0) + return nfserr_bad_xdr; + switch (open->op_createmode) { + case NFS4_CREATE_UNCHECKED: + case NFS4_CREATE_GUARDED: + status = nfsd4_decode_fattr4(argp, open->op_bmval, + ARRAY_SIZE(open->op_bmval), + &open->op_iattr, &open->op_acl, + &open->op_label, &open->op_umask); + if (status) + return status; + break; + case NFS4_CREATE_EXCLUSIVE: + status = nfsd4_decode_verifier4(argp, &open->op_verf); + if (status) + return status; + break; + case NFS4_CREATE_EXCLUSIVE4_1: + if (argp->minorversion < 1) + return nfserr_bad_xdr; + status = nfsd4_decode_verifier4(argp, &open->op_verf); + if (status) + return status; + status = nfsd4_decode_fattr4(argp, open->op_bmval, + ARRAY_SIZE(open->op_bmval), + &open->op_iattr, &open->op_acl, + &open->op_label, &open->op_umask); + if (status) + return status; + break; + default: + return nfserr_bad_xdr; + } + + return nfs_ok; +} + static __be32 nfsd4_decode_share_access(struct nfsd4_compoundargs *argp, u32 *share_access, u32 *deleg_want, u32 *deleg_when) { __be32 *p; @@ -1046,39 +1088,9 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) case NFS4_OPEN_NOCREATE: break; case NFS4_OPEN_CREATE: - READ_BUF(4); - open->op_createmode = be32_to_cpup(p++); - switch (open->op_createmode) { - case NFS4_CREATE_UNCHECKED: - case NFS4_CREATE_GUARDED: - status = nfsd4_decode_fattr4(argp, open->op_bmval, - ARRAY_SIZE(open->op_bmval), - &open->op_iattr, &open->op_acl, - &open->op_label, &open->op_umask); - if (status) - goto out; - break; - case NFS4_CREATE_EXCLUSIVE: - status = nfsd4_decode_verifier4(argp, &open->op_verf); - if (status) - return status; - break; - case NFS4_CREATE_EXCLUSIVE4_1: - if (argp->minorversion < 1) - goto xdr_error; - status = nfsd4_decode_verifier4(argp, &open->op_verf); - if (status) - return status; - status = nfsd4_decode_fattr4(argp, open->op_bmval, - ARRAY_SIZE(open->op_bmval), - &open->op_iattr, &open->op_acl, - &open->op_label, &open->op_umask); - if (status) - goto out; - break; - default: - goto xdr_error; - } + status = nfsd4_decode_createhow4(argp, open); + if (status) + return status; break; default: goto xdr_error; From patchwork Mon Nov 23 20:06:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926279 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4208EC63697 for ; Mon, 23 Nov 2020 20:06:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D962820717 for ; Mon, 23 Nov 2020 20:06:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EncbxYql" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726771AbgKWUG4 (ORCPT ); Mon, 23 Nov 2020 15:06:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726529AbgKWUGz (ORCPT ); Mon, 23 Nov 2020 15:06:55 -0500 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9041C0613CF for ; Mon, 23 Nov 2020 12:06:55 -0800 (PST) Received: by mail-qk1-x743.google.com with SMTP id q22so18249206qkq.6 for ; Mon, 23 Nov 2020 12:06:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=zORj2Xanw0mtJNqfHptijg9zAmhYsmAdanYLTZ8d/qQ=; b=EncbxYqlR2qyTNv8Qaw9yIVlWxYlN3pS9Hp0uHGaX5SZ5NWr5smkg+7TqSWVNlJR67 1FSpi8H+c7d6sAWWjqDuXWD4iM9VQm+XtppZdD+1I3Lceg6v8Q5lQmxLXAkTB69IEP23 SNyVmWY/BgjwZgnJY9AsJV7TZpZinoao0auaHdASUZcae4NGtRl8yuFVvKCXoSXGMs4q v0MHke9xUgmuVd0+z7yNAEJT1t7eU6o8HxMRuuR/Htd98LvXCcLTMR9LqOuRVurdtkc2 woXnyOHerqx/yd9l4EOzgnqIj++1xJzcOZywkLQZnYVglghj9HL6deUXr+E6JbtReJB2 wf+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=zORj2Xanw0mtJNqfHptijg9zAmhYsmAdanYLTZ8d/qQ=; b=gTRnWhQNrn1gToxc4eSwJoOSUndRVDlyD+Anf3mwBcYxzuf5W5JrIZ4rNLJtmBGkEA sZ7MAXJaY5LRHgdct77Il5n6DD6eRjtc46XVPfGvJr4Wx1+Aww2Lq8WBuxZL+3lfQKy/ sVsYXwkDoDZ8OKFACnq4IZazsrEKVQSg0beyVnQyOTdZ+tUAqJjcYswQXdYW8ozlmbd9 KmEQMot2SZ3IiulEo1NDtdsCjnu2jKVhKa4q+uCixsfJ+R/crmDEJ9THe9sZt0/aRiK4 751n0N81GMBfI6r7O1z0Hxs4U9hPuNbX0gKYTHeClN9DseuXVbN4AETT+IhHD/rTQwux 8XQA== X-Gm-Message-State: AOAM533NkvnAx/b6T7HTyG87+N6l1FT7WmAsXmZev6MYNmGAO73jTYqR O9yj8kJ6JyXoiwaS2aCBrC3pPjY9fkE= X-Google-Smtp-Source: ABdhPJyY6M3srhAFB3mZ8X4py6n29vZrTe+/Wb3gvKGUMtEvF5Rs3k76ALle45oSuBfQBgwsMlzh2w== X-Received: by 2002:a37:8c05:: with SMTP id o5mr1289182qkd.396.1606162014651; Mon, 23 Nov 2020 12:06:54 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id w54sm11405259qtb.0.2020.11.23.12.06.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:06:54 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK6q59010367 for ; Mon, 23 Nov 2020 20:06:52 GMT Subject: [PATCH v3 33/85] NFSD: Add helper to decode OPEN's openflag4 argument From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:06:52 -0500 Message-ID: <160616201296.51996.17429441794086812436.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Refactor for clarity. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 579139d727ea..192bce6d359a 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -988,6 +988,28 @@ nfsd4_decode_createhow4(struct nfsd4_compoundargs *argp, struct nfsd4_open *open return nfs_ok; } +static __be32 +nfsd4_decode_openflag4(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) +{ + __be32 status; + + if (xdr_stream_decode_u32(argp->xdr, &open->op_create) < 0) + return nfserr_bad_xdr; + switch (open->op_create) { + case NFS4_OPEN_NOCREATE: + break; + case NFS4_OPEN_CREATE: + status = nfsd4_decode_createhow4(argp, open); + if (status) + return status; + break; + default: + return nfserr_bad_xdr; + } + + return nfs_ok; +} + static __be32 nfsd4_decode_share_access(struct nfsd4_compoundargs *argp, u32 *share_access, u32 *deleg_want, u32 *deleg_when) { __be32 *p; @@ -1082,19 +1104,9 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) status = nfsd4_decode_opaque(argp, &open->op_owner); if (status) goto xdr_error; - READ_BUF(4); - open->op_create = be32_to_cpup(p++); - switch (open->op_create) { - case NFS4_OPEN_NOCREATE: - break; - case NFS4_OPEN_CREATE: - status = nfsd4_decode_createhow4(argp, open); - if (status) - return status; - break; - default: - goto xdr_error; - } + status = nfsd4_decode_openflag4(argp, open); + if (status) + return status; /* open_claim */ READ_BUF(4); From patchwork Mon Nov 23 20:06:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43E2BC2D0E4 for ; Mon, 23 Nov 2020 20:07:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBEC120717 for ; Mon, 23 Nov 2020 20:07:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cLjlvtUo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727070AbgKWUHB (ORCPT ); Mon, 23 Nov 2020 15:07:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726529AbgKWUHA (ORCPT ); Mon, 23 Nov 2020 15:07:00 -0500 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE2ABC0613CF for ; Mon, 23 Nov 2020 12:07:00 -0800 (PST) Received: by mail-qt1-x844.google.com with SMTP id d5so5319681qtn.0 for ; Mon, 23 Nov 2020 12:07:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=iN/sh8i2iCDijW27Jc/LaAyoKa7EvmxTyzzCXonMtz4=; b=cLjlvtUo4+3OoGHkBTlhTyOeWd7i6Gjxynt9/O+gxjjnRMZK7F3PTAtXLCA87palsy 7uzai/zMmjW9n3Jzo/Bvnb26POtAt9UXAIrYsJ+ULIOpt/DpTVbcGr2QElB3d7cP8YtR e+qrsYGy+wYZmFkLUyy1QqdbBULE2Le2IyIitDxxvLoq7IqR2GLHUhn1c+IAWLQ6tcMu bhaMczNs8Nn/vs/R2gCff0zA2kHvR81HhUqqOCf/O+XVjGSpxrIhAUb6lWj/MbPIXuCI yAd3LeIxwXsFNo6VxgElo1RVtHS0W2nvytyLIaUZWo1Xd2XRGkeOWZw03DqBCXQPY3iJ 0XWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=iN/sh8i2iCDijW27Jc/LaAyoKa7EvmxTyzzCXonMtz4=; b=PAa/Yy78a/sywskUYcGUNOi5xxI0W9STgsz7opbmiSEF8n07dwmCiLn0mLqynLehVr J1DQHp8qoTyNELeRdMP6jPcqGEoBlT5tTifHEyYicXEAhikSwboF4aXGxJWjoKPlMkaX aj813bByae1pjaw5LfqreipN1kFmFZQkN5Chl8CXrLNeL2q3EVXq7BjCsKtkEQY5HbSe CCJR097p8wPISNFMipHyKt1bJexXdrX/iL7B1DPZoQ5sFEU7c9HoSi6NXPgAOcP7IZPl X/p9mldwhoQuzM8vitLxhSMb0n4Nye3Tf53GxbmYEh32sA1X0Gg2/v5HndMkGmfGPZNS lx/A== X-Gm-Message-State: AOAM532a8Q9yi/BXM7Ry8QNJiINqus9MFO6oM3e84Nq4SHTsFRy2YOHr +hb0rlxM2XY39ZHFWR9xyj7PkEVCkI8= X-Google-Smtp-Source: ABdhPJwLWa4FgmHKg+If1kWQXc2SLX0b9ocL2+oMUI7QcoBfGdZPadsoOOsGp8EflX/oJHO4mFDDmw== X-Received: by 2002:ac8:58d1:: with SMTP id u17mr911089qta.158.1606162019663; Mon, 23 Nov 2020 12:06:59 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id y3sm3991768qkl.110.2020.11.23.12.06.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:06:59 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK6wUL010370 for ; Mon, 23 Nov 2020 20:06:58 GMT Subject: [PATCH v3 34/85] NFSD: Replace READ* macros in nfsd4_decode_share_access() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:06:58 -0500 Message-ID: <160616201825.51996.13280386626905277864.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 192bce6d359a..b1a4d3b85900 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1012,11 +1012,10 @@ nfsd4_decode_openflag4(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) static __be32 nfsd4_decode_share_access(struct nfsd4_compoundargs *argp, u32 *share_access, u32 *deleg_want, u32 *deleg_when) { - __be32 *p; u32 w; - READ_BUF(4); - w = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &w) < 0) + return nfserr_bad_xdr; *share_access = w & NFS4_SHARE_ACCESS_MASK; *deleg_want = w & NFS4_SHARE_WANT_MASK; if (deleg_when) @@ -1059,7 +1058,6 @@ static __be32 nfsd4_decode_share_access(struct nfsd4_compoundargs *argp, u32 *sh NFS4_SHARE_PUSH_DELEG_WHEN_UNCONTENDED): return nfs_ok; } -xdr_error: return nfserr_bad_xdr; } From patchwork Mon Nov 23 20:07:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926283 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 573BFC63697 for ; Mon, 23 Nov 2020 20:07:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D44720717 for ; Mon, 23 Nov 2020 20:07:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JsKSpnNH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727558AbgKWUHG (ORCPT ); Mon, 23 Nov 2020 15:07:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727156AbgKWUHG (ORCPT ); Mon, 23 Nov 2020 15:07:06 -0500 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0EA06C0613CF for ; Mon, 23 Nov 2020 12:07:06 -0800 (PST) Received: by mail-qv1-xf44.google.com with SMTP id n9so3154857qvp.5 for ; Mon, 23 Nov 2020 12:07:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=9tvn62bV/+P20BgOBhg5EKe7ylbarIRTZ6z+hr/V6Wo=; b=JsKSpnNHkJFBg3Sdwgx6yfotiuX7l2NvC5as7cdv/G0VxS9fgqjBaSHFPuuaXvfSU2 fH+Yg21h597f8XMoo0VUFSwre15sxdHXq3zNhv3jPi5HLWFbqOTE8osfqGBeS6sbBKnv x4usNJ5teVPJ/FLif/AEj4Cg1Vzrdu4gCUUjUh+OZGBq/HbFtqWKQZlIu0TjnJIsgN0E C1ZhvVAcq8yis//t3Rf35j1fbE2XH2wZ2EiJvok8mPTOngIF3UNfJSk3fljPF4mZws8g LWml4ElQ0eg+ZktZEcYT9hNlWphxkY/rvo/KbDlpeEeDXPM+O959P5XtC/OWJvFoavEf 0o7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=9tvn62bV/+P20BgOBhg5EKe7ylbarIRTZ6z+hr/V6Wo=; b=C91l4dXISCCn9BRv4uOiwRf0AoAq8WDHPnoU86cDLwBAEj3oC0t5dE+uWcehQTTvX7 EsxikcNoFlr9+3LmwKvBktthReRMsp70sNu8bDDjYP+NaBCWHOGUevGaZWI/NjmA6twP nGXPCe9vEPQVm/0R6V7PUh4t2LravAKlPvAdNNvmcQo4V490TbBHvY3HlnUguxH2CA4V Zu57Cbb8huMSQyM49P3w3XZhUJ7HL15uKDrqMDkviCxUnmxNnA8qoFX84lBY9DiRTYE9 wtg5gDEPELgSw3zWGs1c60iuA7o8jdAa+M4I12tEDpGAF9jRHcYtoZb3AjIWviKNIH8V 9Rcw== X-Gm-Message-State: AOAM531P1LxNAW0XT6IGYPEP5AIn0p6iB/PJXBy5YP5kT21nGcXV26zS R96ea8QcY0yAlMTu2GixbeP+/WqjnJc= X-Google-Smtp-Source: ABdhPJxdRQwmfHieZdjpYSawgytJN6jYKgunM2To1+fDibTLeFfKxX0+dqAfxo6CmalKBntkWWFrAQ== X-Received: by 2002:ad4:4cd0:: with SMTP id i16mr1108482qvz.13.1606162025031; Mon, 23 Nov 2020 12:07:05 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id w192sm10513356qkb.17.2020.11.23.12.07.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:07:04 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK73dd010373 for ; Mon, 23 Nov 2020 20:07:03 GMT Subject: [PATCH v3 35/85] NFSD: Replace READ* macros in nfsd4_decode_share_deny() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:07:03 -0500 Message-ID: <160616202332.51996.15963677065764215766.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index b1a4d3b85900..521b51b5607b 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1063,16 +1063,13 @@ static __be32 nfsd4_decode_share_access(struct nfsd4_compoundargs *argp, u32 *sh static __be32 nfsd4_decode_share_deny(struct nfsd4_compoundargs *argp, u32 *x) { - __be32 *p; - - READ_BUF(4); - *x = be32_to_cpup(p++); - /* Note: unlinke access bits, deny bits may be zero. */ + if (xdr_stream_decode_u32(argp->xdr, x) < 0) + return nfserr_bad_xdr; + /* Note: unlike access bits, deny bits may be zero. */ if (*x & ~NFS4_SHARE_DENY_BOTH) return nfserr_bad_xdr; + return nfs_ok; -xdr_error: - return nfserr_bad_xdr; } static __be32 From patchwork Mon Nov 23 20:07:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926285 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AADF3C63697 for ; Mon, 23 Nov 2020 20:07:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4EA8720717 for ; Mon, 23 Nov 2020 20:07:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NHDCHw5n" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727156AbgKWUHN (ORCPT ); Mon, 23 Nov 2020 15:07:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726529AbgKWUHM (ORCPT ); Mon, 23 Nov 2020 15:07:12 -0500 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FB83C0613CF for ; Mon, 23 Nov 2020 12:07:11 -0800 (PST) Received: by mail-qv1-xf43.google.com with SMTP id ek7so9447486qvb.6 for ; Mon, 23 Nov 2020 12:07:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=AUbsZ02sDEi1GQRus2wgYpQEhoYGOHNoJui9oe8tnp8=; b=NHDCHw5nQcaEFoxZ0tq2NwSvVFnhXPibFm0tgA2kE3sM0JCpqgAxKUmFJeFlEt3Zo3 wsP0UHIC8dTM52KUpQTMqMia/6nQOcpuTgn03oSSJvIIt0rMnmuRA+pFvh7ADeEvNtKX QK61U5c9zW86T4NzigjeBRyLfTgR/95yzthepkmgEsbv1KPUCSOQirMMB7QehUNqBJlg fjdkRE0r/vxTTi+RnFP51BxSNI79kfdqXVP8bW02BV8nUYI4Z1ynuTg22DAQuamm2fbc H00xvWmNE8z9JqLEaEkJpMhdRnf/3/cpAFP0NrjRnx7FbeYPS1exwiHSNv9v8tjdnP/9 eIXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=AUbsZ02sDEi1GQRus2wgYpQEhoYGOHNoJui9oe8tnp8=; b=UgATdAYGDMkR247W1xewciZMcuG08UAF1T9M0aTQmn2yttFP520bqxXv6sXvoQ4LMh HP8APtdBjKvXr3Fra2TXh9YhisZUhvpxF1neHiBAUipQpxAtih04McyFux30Dau7RZzj jOVxp/LfIAiI0zeqPgt0eJqud044Zca+OdkpO86qRYbT0DmNcxLRNj4x+AsaonFGJO2V wXch3OkCwcX8WsT9dkFF5ZlFqmR4z/By3CC/3a2Pcz2M5LgHSyUH/LMedcY8zMglOSf2 SXwvdwTcBL2QAPCOMteWFdNL0d2AnLgMeur0mKaSj8I9MGvPm1Fx974m+tEus3YyzKuL j4fw== X-Gm-Message-State: AOAM530qvgpmlhdWZa+7gGcrV14f5VFFYsQ9ICOeScbvg7DPQBk9/yiz XnK8M/xrLgZxsaRPciFtLizugO+WhRY= X-Google-Smtp-Source: ABdhPJxPLMEfXzHnuanvhKGNC4BvW1zvj/TObPoyeeunKGTEPyRST3F1ND31ONTcLlE9E+irx9cMqA== X-Received: by 2002:a05:6214:17c1:: with SMTP id cu1mr1306279qvb.32.1606162030376; Mon, 23 Nov 2020 12:07:10 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id k31sm10421101qtd.40.2020.11.23.12.07.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:07:09 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK78oX010376 for ; Mon, 23 Nov 2020 20:07:08 GMT Subject: [PATCH v3 36/85] NFSD: Add helper to decode OPEN's open_claim4 argument From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:07:08 -0500 Message-ID: <160616202867.51996.9303361629968265860.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Refactor for clarity. Note that op_fname is the only instance of an NFSv4 filename stored in a struct xdr_netobj. Convert it to a u32/char * pair so that the new nfsd4_decode_filename() helper can be used. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4proc.c | 8 ++-- fs/nfsd/nfs4xdr.c | 95 +++++++++++++++++++++++++++------------------------- fs/nfsd/xdr4.h | 3 +- 3 files changed, 56 insertions(+), 50 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index df2d6f70c8d4..56d074a6cb31 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -257,8 +257,8 @@ do_open_lookup(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, stru * in NFSv4 as in v3 except EXCLUSIVE4_1. */ current->fs->umask = open->op_umask; - status = do_nfsd_create(rqstp, current_fh, open->op_fname.data, - open->op_fname.len, &open->op_iattr, + status = do_nfsd_create(rqstp, current_fh, open->op_fname, + open->op_fnamelen, &open->op_iattr, *resfh, open->op_createmode, (u32 *)open->op_verf.data, &open->op_truncate, &open->op_created); @@ -283,7 +283,7 @@ do_open_lookup(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, stru * a chance to an acquire a delegation if appropriate. */ status = nfsd_lookup(rqstp, current_fh, - open->op_fname.data, open->op_fname.len, *resfh); + open->op_fname, open->op_fnamelen, *resfh); if (status) goto out; status = nfsd_check_obj_isreg(*resfh); @@ -360,7 +360,7 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, bool reclaim = false; dprintk("NFSD: nfsd4_open filename %.*s op_openowner %p\n", - (int)open->op_fname.len, open->op_fname.data, + (int)open->op_fnamelen, open->op_fname, open->op_openowner); /* This check required by spec. */ diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 521b51b5607b..efd8ae108b2d 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1072,6 +1072,55 @@ static __be32 nfsd4_decode_share_deny(struct nfsd4_compoundargs *argp, u32 *x) return nfs_ok; } +static __be32 +nfsd4_decode_open_claim4(struct nfsd4_compoundargs *argp, + struct nfsd4_open *open) +{ + __be32 status; + + if (xdr_stream_decode_u32(argp->xdr, &open->op_claim_type) < 0) + return nfserr_bad_xdr; + switch (open->op_claim_type) { + case NFS4_OPEN_CLAIM_NULL: + case NFS4_OPEN_CLAIM_DELEGATE_PREV: + status = nfsd4_decode_component4(argp, &open->op_fname, + &open->op_fnamelen); + if (status) + return status; + break; + case NFS4_OPEN_CLAIM_PREVIOUS: + if (xdr_stream_decode_u32(argp->xdr, &open->op_delegate_type) < 0) + return nfserr_bad_xdr; + break; + case NFS4_OPEN_CLAIM_DELEGATE_CUR: + status = nfsd4_decode_stateid4(argp, &open->op_delegate_stateid); + if (status) + return status; + status = nfsd4_decode_component4(argp, &open->op_fname, + &open->op_fnamelen); + if (status) + return status; + break; + case NFS4_OPEN_CLAIM_FH: + case NFS4_OPEN_CLAIM_DELEG_PREV_FH: + if (argp->minorversion < 1) + return nfserr_bad_xdr; + /* void */ + break; + case NFS4_OPEN_CLAIM_DELEG_CUR_FH: + if (argp->minorversion < 1) + return nfserr_bad_xdr; + status = nfsd4_decode_stateid4(argp, &open->op_delegate_stateid); + if (status) + return status; + break; + default: + return nfserr_bad_xdr; + } + + return nfs_ok; +} + static __be32 nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) { @@ -1102,51 +1151,7 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) status = nfsd4_decode_openflag4(argp, open); if (status) return status; - - /* open_claim */ - READ_BUF(4); - open->op_claim_type = be32_to_cpup(p++); - switch (open->op_claim_type) { - case NFS4_OPEN_CLAIM_NULL: - case NFS4_OPEN_CLAIM_DELEGATE_PREV: - READ_BUF(4); - open->op_fname.len = be32_to_cpup(p++); - READ_BUF(open->op_fname.len); - SAVEMEM(open->op_fname.data, open->op_fname.len); - if ((status = check_filename(open->op_fname.data, open->op_fname.len))) - return status; - break; - case NFS4_OPEN_CLAIM_PREVIOUS: - READ_BUF(4); - open->op_delegate_type = be32_to_cpup(p++); - break; - case NFS4_OPEN_CLAIM_DELEGATE_CUR: - status = nfsd4_decode_stateid(argp, &open->op_delegate_stateid); - if (status) - return status; - READ_BUF(4); - open->op_fname.len = be32_to_cpup(p++); - READ_BUF(open->op_fname.len); - SAVEMEM(open->op_fname.data, open->op_fname.len); - if ((status = check_filename(open->op_fname.data, open->op_fname.len))) - return status; - break; - case NFS4_OPEN_CLAIM_FH: - case NFS4_OPEN_CLAIM_DELEG_PREV_FH: - if (argp->minorversion < 1) - goto xdr_error; - /* void */ - break; - case NFS4_OPEN_CLAIM_DELEG_CUR_FH: - if (argp->minorversion < 1) - goto xdr_error; - status = nfsd4_decode_stateid(argp, &open->op_delegate_stateid); - if (status) - return status; - break; - default: - goto xdr_error; - } + status = nfsd4_decode_open_claim4(argp, open); DECODE_TAIL; } diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 0eb13bd603ea..6245004a9993 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -252,7 +252,8 @@ struct nfsd4_listxattrs { struct nfsd4_open { u32 op_claim_type; /* request */ - struct xdr_netobj op_fname; /* request - everything but CLAIM_PREV */ + u32 op_fnamelen; + char * op_fname; /* request - everything but CLAIM_PREV */ u32 op_delegate_type; /* request - CLAIM_PREV only */ stateid_t op_delegate_stateid; /* request - response */ u32 op_why_no_deleg; /* response - DELEG_NONE_EXT only */ From patchwork Mon Nov 23 20:07:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926287 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3CAD8C2D0E4 for ; Mon, 23 Nov 2020 20:07:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DA85520717 for ; Mon, 23 Nov 2020 20:07:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CruwXpll" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726529AbgKWUHR (ORCPT ); Mon, 23 Nov 2020 15:07:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727725AbgKWUHQ (ORCPT ); Mon, 23 Nov 2020 15:07:16 -0500 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C84ECC0613CF for ; Mon, 23 Nov 2020 12:07:16 -0800 (PST) Received: by mail-qk1-x744.google.com with SMTP id n132so18280649qke.1 for ; Mon, 23 Nov 2020 12:07:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=9Zur4rLgsmsi+76cQ7Dymuzv8Z04tb3Sv3g444mU0HI=; b=CruwXpllkk420eRzqpcHrKZDDCS3O8aWIy9oiy+vDWSJBRrTT6R0GTFDHEeBePKN65 trfv8aq98GLQGj0SDJTZBBUNAKuMOYGqgpg6nAmZ5/uAMUq9Y3hHy45ZDtSjB8HNsEDo zPj90aYrQInFeyyjuF/hkIf+VQr8PPL/I6S+0ez6QglwDtm5Hu6+9h5AgZyTdM1Yz2i2 QtvRyMLnnOEaoXFOA/zwFmJGebgmHPkcDam4BHL9OU3Qo9+Z0SbevCC/yLQcfI3Phksw JAlxqJrgPVUem8g1SyVOUrV1aHMeO4BlW9296X4gk3mBwoqI/Y53H81LRzRQwemscVYb ZgGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=9Zur4rLgsmsi+76cQ7Dymuzv8Z04tb3Sv3g444mU0HI=; b=LRUr+iUgTLwKh1NoCXVThqvbIYXs+bcZ5oDoCHQK3jTtb1QgImDY2z3UMH2NS3idQS mJFTMFINi9ubE5jv5BHzCMkELRD9GH3qkEMtjV8OGN+oiS8d/DkzB78nUxbkvHcCH8Rv XoMtFjb6wpOph79Y2U7Ck6G6RH26wyuHHB1RWzpwO488xzU2786m1NyltSI6T8vxeEYZ GSyBFwGjctSC6c45WZQb1viBZCng81fBpEBOdRGE6DvrGMnDPfceXLAsSV/WJc19ZYRs wmORagHWDwRH20SmVkiZyOvNG/i1nDKbA9KDqPwSG3lAleu68mZ4KP2yN/HaG48QRYgR v/XQ== X-Gm-Message-State: AOAM532QOdgACaRNfWvGQmW6Hq4HVDJCjNU8aMtYVcJOVcL41xnssTHI BjaTR/zmsT/Q6ql1ohoOYKpH0cNVQs4= X-Google-Smtp-Source: ABdhPJzUdpBrZ4GW6B6eJJ9C57lqJjLjJuFut/3lhTABdVpsFR5k5eHZ5fq2EL5uOBbkbZO8FKHjHg== X-Received: by 2002:a37:9b06:: with SMTP id d6mr1241179qke.116.1606162035748; Mon, 23 Nov 2020 12:07:15 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id 9sm9806308qty.30.2020.11.23.12.07.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:07:15 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK7EU5010379 for ; Mon, 23 Nov 2020 20:07:14 GMT Subject: [PATCH v3 37/85] NFSD: Replace READ* macros in nfsd4_decode_open() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:07:14 -0500 Message-ID: <160616203402.51996.6916215265413569824.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index efd8ae108b2d..fc244661b048 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1124,7 +1124,7 @@ nfsd4_decode_open_claim4(struct nfsd4_compoundargs *argp, static __be32 nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) { - DECODE_HEAD; + __be32 status; u32 dummy; memset(open->op_bmval, 0, sizeof(open->op_bmval)); @@ -1132,28 +1132,24 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) open->op_openowner = NULL; open->op_xdr_error = 0; - /* seqid, share_access, share_deny, clientid, ownerlen */ - READ_BUF(4); - open->op_seqid = be32_to_cpup(p++); - /* decode, yet ignore deleg_when until supported */ + if (xdr_stream_decode_u32(argp->xdr, &open->op_seqid) < 0) + return nfserr_bad_xdr; + /* deleg_want is ignored */ status = nfsd4_decode_share_access(argp, &open->op_share_access, &open->op_deleg_want, &dummy); if (status) - goto xdr_error; + return status; status = nfsd4_decode_share_deny(argp, &open->op_share_deny); if (status) - goto xdr_error; - READ_BUF(sizeof(clientid_t)); - COPYMEM(&open->op_clientid, sizeof(clientid_t)); - status = nfsd4_decode_opaque(argp, &open->op_owner); + return status; + status = nfsd4_decode_state_owner4(argp, &open->op_clientid, + &open->op_owner); if (status) - goto xdr_error; + return status; status = nfsd4_decode_openflag4(argp, open); if (status) return status; - status = nfsd4_decode_open_claim4(argp, open); - - DECODE_TAIL; + return nfsd4_decode_open_claim4(argp, open); } static __be32 From patchwork Mon Nov 23 20:07:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926289 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 75358C2D0E4 for ; Mon, 23 Nov 2020 20:07:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E63B20717 for ; Mon, 23 Nov 2020 20:07:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lFGyRTfw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727869AbgKWUHW (ORCPT ); Mon, 23 Nov 2020 15:07:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727725AbgKWUHW (ORCPT ); Mon, 23 Nov 2020 15:07:22 -0500 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B8C2C0613CF for ; Mon, 23 Nov 2020 12:07:22 -0800 (PST) Received: by mail-qv1-xf41.google.com with SMTP id n9so3155265qvp.5 for ; Mon, 23 Nov 2020 12:07:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=R0OUPEJNqWMapI2K2ucv9jX1Umz8GgkM84dNcE1MLeY=; b=lFGyRTfwojIOQCdZ8BXPpt4Ispc0srvjZGRbXczd6cokaXaOEKOLvZFp3QXbzAZxxG Z2S6NFi2Ek37lkBw33wmvWYt8tMpZdYJ6gc+Ys3kFZmkJv73ZNuiOolU7lBQ/SqGAMHL epdOX36BWOruLne5AbJIXwsSvXAeDKBjp/aMWvI8xHaAyQ6zZ6iLjehSNKv7Ju2geiy+ OQNqL/bcBAlx5xxKZLnkMvpOIVAX6g5Xe3aDZbvXb7zL9sXvKDtE/TBTTiANJWIFhYRW XHDIPdxJc5JyI5uuSHkjMkDgdR3cZ2XBGfCixTrsYxck+pJvfCNU3JK7eFDu2A7IXwt9 DjWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=R0OUPEJNqWMapI2K2ucv9jX1Umz8GgkM84dNcE1MLeY=; b=p0n784PDhibebgA6GhPNKr2VMEj532DI2r1MydTbflRuTF6xXUq+8+cyUrft5TSCoY VHBR4yLNe5TMCxUIrSNXwEpMNAV71HEwVo/mX9rH0vQdV5FOeGo7CuYUsjcti98LPXYK dRN9Xwuo/oeI2HDhq43jxuBbptvaf3RRMjgRThvrcipI6y30/6ZXfy4K8Yikp2qvqnPG 7ir5DyczZ1T8q/PLEsuaMsaBnNdR91Oz0jlCHpJLNYfcZsbmkVdBHnih6trBhmeTkKwt zbl0De0ZCN1sgnBqwVLKywGAPldM0IJ1EbFNyWeHbghghjgJ3fzPLH9oa9ASvrDr7dTC gFmg== X-Gm-Message-State: AOAM530XWxmdQKrF9crCP8d0c/vn2WmKfgiT5bVwAr9Tz1gKiO401WAQ oSPVmlFp0VFPCg05AxpnrJIE6yNGqts= X-Google-Smtp-Source: ABdhPJzEB3i615EjY/gB5YOyY3yFKfQxVs34F/OkBrLz2D5m1aoKmT+pV3e+jS4K9kEh2H1fh5x4Og== X-Received: by 2002:ad4:5483:: with SMTP id q3mr1228665qvy.24.1606162041086; Mon, 23 Nov 2020 12:07:21 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id l22sm10491291qke.118.2020.11.23.12.07.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:07:20 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK7JWJ010382 for ; Mon, 23 Nov 2020 20:07:19 GMT Subject: [PATCH v3 38/85] NFSD: Replace READ* macros in nfsd4_decode_open_confirm() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:07:19 -0500 Message-ID: <160616203937.51996.12129336772635835508.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index fc244661b048..f0484d9c7b78 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1155,18 +1155,18 @@ nfsd4_decode_open(struct nfsd4_compoundargs *argp, struct nfsd4_open *open) static __be32 nfsd4_decode_open_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_open_confirm *open_conf) { - DECODE_HEAD; + __be32 status; if (argp->minorversion >= 1) return nfserr_notsupp; - status = nfsd4_decode_stateid(argp, &open_conf->oc_req_stateid); + status = nfsd4_decode_stateid4(argp, &open_conf->oc_req_stateid); if (status) return status; - READ_BUF(4); - open_conf->oc_seqid = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &open_conf->oc_seqid) < 0) + return nfserr_bad_xdr; - DECODE_TAIL; + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:07:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926291 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8617C2D0E4 for ; Mon, 23 Nov 2020 20:07:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5B8DF20717 for ; Mon, 23 Nov 2020 20:07:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O10YyuWE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727914AbgKWUH1 (ORCPT ); Mon, 23 Nov 2020 15:07:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727725AbgKWUH1 (ORCPT ); Mon, 23 Nov 2020 15:07:27 -0500 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30D47C0613CF for ; Mon, 23 Nov 2020 12:07:27 -0800 (PST) Received: by mail-qk1-x744.google.com with SMTP id y197so18232570qkb.7 for ; Mon, 23 Nov 2020 12:07:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=g6rdx9vnEwrtoKkJfxVy0nAKUPNObAz6vDgZBwi55mA=; b=O10YyuWEORmLwXSsfI4bqxs7DnZXc/UIca+fgQoeLiLdYoILgXFj56Ob9L2OzcLOEz CvThOy/O9rppIgezuRuaGTUf3WevvenGzRicTwrPbOeclThreCAqs6DKutZw6gDnNIwG ZbgTt3tm2iSTKL1NzfCIQF9cmiEiHR4dVhdA/Gvia9MdtZ2g/F+fLn4EoIFGs3obTpWM lQScEnqcRQX8uBVPTz2SIbh+UXXL0wOAr3AqK74I0bdPsNeO2CSI+1UuFI6BbyH1sD4m 0Cf1yUs7DjqnqnbuY9Wp8FIzFP3FSPG0zFnmidq8RPkhhEfsGqpkHVE77GC0cL2EtHX4 UkcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=g6rdx9vnEwrtoKkJfxVy0nAKUPNObAz6vDgZBwi55mA=; b=PjjrNwvfKSs135MRhEftcAhBMumvN/1P4TahlXYy2p7/hbsFLky6ePTlY+ljVHOWla zI+lXwIVDyjrMABSB8dS4I18B5jsLibL965vXh7DL7/w+S4+u8rUesYdr9xNiWeh4WEN R1dwTYbsudzpsBWIZGwyVV76ZaC83JOzCKfB1Haa1Q0lfaLgcwQb20uSI4wmYylZf0RU ZNhbWd2lNA5nhvPyB6B4hN3Gl+9dmeC4mAyRxNlYxebHFHlMRhXssq627I8no5e2tOeY B53gEegXyBNaHLwVbPU/kVOssYhl8P9aj2ezqcE5LUUULkHTZ5pWoFVgL1QFnpMaSOMG yM/A== X-Gm-Message-State: AOAM531qBXG0ZaonxvKpiheRGD9JtVKh6XAaVVu2hIkbwMPQFOVuwe5L Tf0XLm9zcIQkDWA5yofNbLGiRHCS7ho= X-Google-Smtp-Source: ABdhPJyRlyYMWMi9ssaHHt1qh0/yr+32lnmUHvbnoUk8CNJI1b++tXw0Vymp3N/Xdqg4wv3z3OB/AQ== X-Received: by 2002:a37:9e16:: with SMTP id h22mr1166981qke.481.1606162046132; Mon, 23 Nov 2020 12:07:26 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id n21sm10738192qke.21.2020.11.23.12.07.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:07:25 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK7OTB010385 for ; Mon, 23 Nov 2020 20:07:24 GMT Subject: [PATCH v3 39/85] NFSD: Replace READ* macros in nfsd4_decode_open_downgrade() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:07:24 -0500 Message-ID: <160616204472.51996.10477496304909146320.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index f0484d9c7b78..54bde3ac92f1 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1172,21 +1172,19 @@ nfsd4_decode_open_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_open_con static __be32 nfsd4_decode_open_downgrade(struct nfsd4_compoundargs *argp, struct nfsd4_open_downgrade *open_down) { - DECODE_HEAD; - - status = nfsd4_decode_stateid(argp, &open_down->od_stateid); + __be32 status; + + status = nfsd4_decode_stateid4(argp, &open_down->od_stateid); if (status) return status; - READ_BUF(4); - open_down->od_seqid = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &open_down->od_seqid) < 0) + return nfserr_bad_xdr; + /* deleg_want is ignored */ status = nfsd4_decode_share_access(argp, &open_down->od_share_access, &open_down->od_deleg_want, NULL); if (status) return status; - status = nfsd4_decode_share_deny(argp, &open_down->od_share_deny); - if (status) - return status; - DECODE_TAIL; + return nfsd4_decode_share_deny(argp, &open_down->od_share_deny); } static __be32 From patchwork Mon Nov 23 20:07:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926293 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4486C2D0E4 for ; Mon, 23 Nov 2020 20:07:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 45CEF2071E for ; Mon, 23 Nov 2020 20:07:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Uhecs5dv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727976AbgKWUHf (ORCPT ); Mon, 23 Nov 2020 15:07:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42008 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727725AbgKWUHe (ORCPT ); Mon, 23 Nov 2020 15:07:34 -0500 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92F16C0613CF for ; Mon, 23 Nov 2020 12:07:32 -0800 (PST) Received: by mail-qk1-x742.google.com with SMTP id l2so18302491qkf.0 for ; Mon, 23 Nov 2020 12:07:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=q96JdHd2+337Gqa0MlwklQMDQGubVtjjUSlxUx6pbOY=; b=Uhecs5dvE52cwth9QJmZsPuZazPJaev9oU6kwJJEUztU7j1hjcaw+AuTmdXaz9h+9R /dyFr8eJesTxwOrNYexd4wTfpk4zwemGMkU/mLGS/dWaw5Tz5IIy9QDGBFhZpTl+lVuI wIQyTS1RVD5QW7zFvppL7ivMSr2XEtqRFKYxb5v2fsFlchmr/3TDF+2E6f994ZIGB4kU 8AtvXRleXSrJrF6OjPSd6OMWXuFlzReSuDfGxkxsvNjhjApECD3KJOedEVXY+NnxcVgA pDYF8qzBmGz9GxcyexgYwSXRmZMXyE6uHMhOJWcPe+YNLbi35k2fmvaM3QidkqdJIHo7 L4fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=q96JdHd2+337Gqa0MlwklQMDQGubVtjjUSlxUx6pbOY=; b=bylltWVrvUwpNVSmwvzGZWvtpNy/1MbMHKN/RpYkkoXTJqEJbxuOC0zwRp10KHFABN +oprcKbpyIu4JL9y3PST0OL2lN6iTWTT+YxrwHvLAvtxBktXf2P3YySfC9LR0T6/5n8d 60EcFo1sC3VC9XnqrBUxctJnQNh9FU3O5NuIwrUVodqKhCqiqwLe5A9UvE0a+C3vQKeY B9KGJiIr93yyVD3qR5nZGCW0KvKpNok7gRj3u1/jKrybVQt0GUfNRFtn0GkVKiX4pBXm PhfDNs7BlwZOeoIKaW0DDzB3nJLrQhvNNOAOW5Ur74hvtfywIPsdbBttG72myyn3PcTu Wjnw== X-Gm-Message-State: AOAM532zwtIKtoGxtT10YaUqSjijpnso+JYIg9GPPIyRRbENVKwMxddu Sp4df3V1xNdrvuA9U7VSUzK1e8HfoME= X-Google-Smtp-Source: ABdhPJyrN2D4hTwEfxXbepkXzAE4ctW87sqFllCjS2cMXbaE5GHC7JREUDrdXrZ5fGHqsKWQin+E/g== X-Received: by 2002:a37:dc02:: with SMTP id v2mr1158395qki.181.1606162051444; Mon, 23 Nov 2020 12:07:31 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id l88sm5987106qtd.59.2020.11.23.12.07.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:07:30 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK7TeJ010388 for ; Mon, 23 Nov 2020 20:07:29 GMT Subject: [PATCH v3 40/85] NFSD: Replace READ* macros in nfsd4_decode_putfh() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:07:29 -0500 Message-ID: <160616204978.51996.5677066489149283026.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 54bde3ac92f1..876334eb4d72 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1190,16 +1190,21 @@ nfsd4_decode_open_downgrade(struct nfsd4_compoundargs *argp, struct nfsd4_open_d static __be32 nfsd4_decode_putfh(struct nfsd4_compoundargs *argp, struct nfsd4_putfh *putfh) { - DECODE_HEAD; + __be32 *p; - READ_BUF(4); - putfh->pf_fhlen = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &putfh->pf_fhlen) < 0) + return nfserr_bad_xdr; if (putfh->pf_fhlen > NFS4_FHSIZE) - goto xdr_error; - READ_BUF(putfh->pf_fhlen); - SAVEMEM(putfh->pf_fhval, putfh->pf_fhlen); + return nfserr_bad_xdr; + p = xdr_inline_decode(argp->xdr, putfh->pf_fhlen); + if (!p) + return nfserr_bad_xdr; + putfh->pf_fhval = svcxdr_tmpalloc(argp, putfh->pf_fhlen); + if (!putfh->pf_fhval) + return nfserr_jukebox; + memcpy(putfh->pf_fhval, p, putfh->pf_fhlen); - DECODE_TAIL; + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:07:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30F3FC63697 for ; Mon, 23 Nov 2020 20:07:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C839420717 for ; Mon, 23 Nov 2020 20:07:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b5HgUDep" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727983AbgKWUHi (ORCPT ); Mon, 23 Nov 2020 15:07:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727725AbgKWUHh (ORCPT ); Mon, 23 Nov 2020 15:07:37 -0500 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE791C0613CF for ; Mon, 23 Nov 2020 12:07:37 -0800 (PST) Received: by mail-qt1-x843.google.com with SMTP id g17so14371154qts.5 for ; Mon, 23 Nov 2020 12:07:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=OdlCDg1wYos791JCDgyhUGhBlCvZo0/tQZxahymaM3E=; b=b5HgUDepj4iCcuiJlgGnYLraoqAXS819MNSZx6fLmXujOUCbIm/4VMZNAyK4UTnrRB ot8UUbXTwz1hKA9gc3CyJReQNoE+GvrfCtf8k/YPJF0aXn5pVMHGu+K/5QDW7eyieJiZ k7dff48k0f7vf4kjoENCSIfLRQ2a4/L+SwxxzZXkeAcbm6jFsY1vM/nWMo0AFzaaZSyA VNg0UCoShCgKMu832GphOGADo9Ukk9I7zx8GZknv5jOvZQ3gqU0bKSxwXVQCa51LZ762 WMszfWUZKu21o0k5UFYbnwNMYvz2YI2Io+5LEnovCiC+8n943pX54W7h5b203fwixOdy nG4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=OdlCDg1wYos791JCDgyhUGhBlCvZo0/tQZxahymaM3E=; b=WG1gG7tm66g59bO2P/a9Xf77XkVr0tzKDdR50QRkccCZYrvRND20hm54yPt/W/V4XN Lai/PSRma/oJ0Ft+QqZeIfhgNk5ZuB8M6oSMiIAxN0+JsOukPc78mms3S9fgpDv0ak34 uZbPc8cNJUdaT2yahnejnyLhn9/pRIgsK1z7GujuFtp/Dp7YLXZDlTszWmRg+/WUpPV/ V20bEg+q5DlE/DpnfWJnmjiMV168B5IvImu5vtQ07O7HNpoDqa2H63gG7bmIftD4rS8T Smy5NSWnZjY12MyQFsBCuKbHg357Tw03p6kwLhS8HpPVQOPIEOKx/1hoK9B4w62kBazC Jc1w== X-Gm-Message-State: AOAM533IIgfBdLF55wfQvf9qohEQZ5H6tZ0hxhPYQ9VF0pNW17ie/GYX R6ziz12ylSoeKnoaCHhWE9o1v9zVRng= X-Google-Smtp-Source: ABdhPJxhsIDVuwNlGUBAWZby7odm8SZye7VIAIOjZcDSW//uOwF5BkMk2dkujirUhobGDAPQIvP+SA== X-Received: by 2002:ac8:724d:: with SMTP id l13mr836651qtp.373.1606162056744; Mon, 23 Nov 2020 12:07:36 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id o125sm10137793qke.56.2020.11.23.12.07.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:07:36 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK7Zm3010391 for ; Mon, 23 Nov 2020 20:07:35 GMT Subject: [PATCH v3 41/85] NFSD: Replace READ* macros in nfsd4_decode_read() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:07:35 -0500 Message-ID: <160616205507.51996.6277809172160199601.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 876334eb4d72..804c0ee4c308 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1218,16 +1218,17 @@ nfsd4_decode_putpubfh(struct nfsd4_compoundargs *argp, void *p) static __be32 nfsd4_decode_read(struct nfsd4_compoundargs *argp, struct nfsd4_read *read) { - DECODE_HEAD; + __be32 status; - status = nfsd4_decode_stateid(argp, &read->rd_stateid); + status = nfsd4_decode_stateid4(argp, &read->rd_stateid); if (status) return status; - READ_BUF(12); - p = xdr_decode_hyper(p, &read->rd_offset); - read->rd_length = be32_to_cpup(p++); + if (xdr_stream_decode_u64(argp->xdr, &read->rd_offset) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &read->rd_length) < 0) + return nfserr_bad_xdr; - DECODE_TAIL; + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:07:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BA8BC63697 for ; Mon, 23 Nov 2020 20:07:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0133620717 for ; Mon, 23 Nov 2020 20:07:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FiiAjPHp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728107AbgKWUHp (ORCPT ); Mon, 23 Nov 2020 15:07:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728018AbgKWUHo (ORCPT ); Mon, 23 Nov 2020 15:07:44 -0500 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27D99C0613CF for ; Mon, 23 Nov 2020 12:07:43 -0800 (PST) Received: by mail-qt1-x844.google.com with SMTP id m65so14312225qte.11 for ; Mon, 23 Nov 2020 12:07:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=Sr3uwFR9iosTze7hdR8yTyexnyjD0P0CfGcmiL2mevw=; b=FiiAjPHpFKR1/suomOof9Y3xD2477AOxOQJ4OwZ3F8NF1QLXYwOxL1061PD8cuExK4 NMAHIx+S4wps7EHD8O/pdi/wQZmyBJQpiPGhHBh/LhoD3OsHR/vW/C8uFTdXQ5bBPycn Qd/Q/7TkyNwZMQ9U1s/PbRV5pSmzEfwr7NRE+XZGtrIsH1tog/Npvgi6sxZsFs+IFWEH 2epCKvK8HzaJZF8IA/5LdgorRqSb/7JMuvpBRE/i5FcwAp+ZoT2p5fTY21PZfyU6rA9U CVqpGuY4r+7KnFmHOtHc1dIw5tG28dhxCJmb+zK2b7kKWQnSvffExh0lenMsNBTNLRJE uxCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=Sr3uwFR9iosTze7hdR8yTyexnyjD0P0CfGcmiL2mevw=; b=DUIRbNYdY3GULIMeT46yAGx1B7nfg2ljOQSu1FuV/mzTXNi4ie7ui0DLSgR88VaH+y Fq5SbAB9wwKdNeS899FFEnuzwVGapFtcj39PvzjYLYnlgaWtGsE5GKmo0Nq/MVnWyS9q 9w7q2BuVOnbvHqXWZpgchsRBz6zODarqjXg+u2QLj5R/nj3Cz3h9A/IOBQWpLhmFI8vS Z2sfWNBdwvBhVW/TX2Qdj8g/Sno5jxD6uBoPeEsSb0dJQ5CDIpS8WNPA2JF8GivbcYDs AU4anVTLLogo3AQ8WDHIB7IU9PV/OzQaczAybPfRjNQaM2GvAEvndCjAP+qjppf5L1V9 vlIw== X-Gm-Message-State: AOAM5304nKUTHq1M9AcAAwB7/vWj0Kr0IDk24ReYGlGrJhefNBX6v5nD lNz6vzHjxcUKnw6qxzT6FkqY4Oqpm+k= X-Google-Smtp-Source: ABdhPJzb5UmgkL6W3Hlh45ZB9DWNwbN5qNrTUM0ko+qYiklBXO66tgx02t8lHPxbdkw0unf0mgpSZg== X-Received: by 2002:a05:622a:294:: with SMTP id z20mr814041qtw.321.1606162062029; Mon, 23 Nov 2020 12:07:42 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id 97sm2773835qte.34.2020.11.23.12.07.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:07:41 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK7eLY010394 for ; Mon, 23 Nov 2020 20:07:40 GMT Subject: [PATCH v3 42/85] NFSD: Replace READ* macros in nfsd4_decode_readdir() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:07:40 -0500 Message-ID: <160616206035.51996.3142711628398562358.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 804c0ee4c308..6f10692452cf 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1234,17 +1234,22 @@ nfsd4_decode_read(struct nfsd4_compoundargs *argp, struct nfsd4_read *read) static __be32 nfsd4_decode_readdir(struct nfsd4_compoundargs *argp, struct nfsd4_readdir *readdir) { - DECODE_HEAD; + __be32 status; - READ_BUF(24); - p = xdr_decode_hyper(p, &readdir->rd_cookie); - COPYMEM(readdir->rd_verf.data, sizeof(readdir->rd_verf.data)); - readdir->rd_dircount = be32_to_cpup(p++); - readdir->rd_maxcount = be32_to_cpup(p++); - if ((status = nfsd4_decode_bitmap(argp, readdir->rd_bmval))) - goto out; + if (xdr_stream_decode_u64(argp->xdr, &readdir->rd_cookie) < 0) + return nfserr_bad_xdr; + status = nfsd4_decode_verifier4(argp, &readdir->rd_verf); + if (status) + return status; + if (xdr_stream_decode_u32(argp->xdr, &readdir->rd_dircount) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &readdir->rd_maxcount) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_uint32_array(argp->xdr, readdir->rd_bmval, + ARRAY_SIZE(readdir->rd_bmval)) < 0) + return nfserr_bad_xdr; - DECODE_TAIL; + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:07:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A8952C2D0E4 for ; Mon, 23 Nov 2020 20:07:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4FB0320717 for ; Mon, 23 Nov 2020 20:07:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WLjwlzlb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728198AbgKWUHs (ORCPT ); Mon, 23 Nov 2020 15:07:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728018AbgKWUHs (ORCPT ); Mon, 23 Nov 2020 15:07:48 -0500 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D93BC0613CF for ; Mon, 23 Nov 2020 12:07:48 -0800 (PST) Received: by mail-qt1-x841.google.com with SMTP id 7so14381064qtp.1 for ; Mon, 23 Nov 2020 12:07:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=2ytE20CH0KubMBhhh6jnCi52bsotB+3AGzaIYGMI3TU=; b=WLjwlzlb0nFQ28UB26B53BMJsXa2zm4kjQ+gEQCvgmlKXi5tYuT96X6pD7Dpg8s/GF s93mCh+ZmUcfzCMRcNuWXqLRCHVSVd6c4e9gyayAv7WA6Dy1OwDPik9GtI1ml5H0cw6+ HBOQxiC9B6KnUkFpUHYZ/I8Sx4WTrjo/1gGaH28wk6m7ztnmk4eLHKrz3mSrKibnlYt7 AHraT7fXwpFl4by81p4OcBbs1JwM8Cl7mAC2yfEOwwNx3PzG29fNGQq1aOeaPFlgJHPW kGJAjsyhyb7TKYEnu7ieSb7um685kv5leHzEi3d/naMgoIJl1t/BLZDqb9LnSUzxRLeN AAtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=2ytE20CH0KubMBhhh6jnCi52bsotB+3AGzaIYGMI3TU=; b=DdTWM9OS3QzIWsVB8BbAM88RXJO3qerQe/ozrDVRbHH8vdf5w94vmjrsPomby5N57g nVI/O5oGp5/dmXsTmbKbVT+4nWsTmXN3Z8LMOWY0GCO1XhqLBz4MVG4P0+YE3o367Gmw 3Eo7/8Zo4JrfresCnF2pV8PZLZ6avevzOMOl4cu+VPLGFLKpj7ckA/K75R1hkzwX257D 8hFFV4ncKe4fY885RsUDcN//IIhkYKBxtkZMXy+mCvo36SghZ5/82NulHl4vYqErrzsb V57TvvtQZtxgTpD+IhF43iop3zslBS8w6fjmmi4fwynYKIi+NXvxwcbnssHuH3TSneZ8 bsAA== X-Gm-Message-State: AOAM531uYl4a8afrBfMv4u7GYamRwmybJ4WJOL4vckhbSwqLybznL+8b xqAO1nUlk75/LpNx8fhSHDPmDOs19ko= X-Google-Smtp-Source: ABdhPJzQVF5k4A/CCqVrta19+bhDJ89avu3ujZ8lyrJa+CpwuCSIzXNQFwAzUk7qs1tnmyC7KZTFXg== X-Received: by 2002:ac8:4612:: with SMTP id p18mr869648qtn.31.1606162067275; Mon, 23 Nov 2020 12:07:47 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id n21sm10739326qke.21.2020.11.23.12.07.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:07:46 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK7jh0010397 for ; Mon, 23 Nov 2020 20:07:45 GMT Subject: [PATCH v3 43/85] NFSD: Replace READ* macros in nfsd4_decode_remove() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:07:45 -0500 Message-ID: <160616206564.51996.379395383887167228.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 6f10692452cf..cdec94ae81fc 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1255,16 +1255,7 @@ nfsd4_decode_readdir(struct nfsd4_compoundargs *argp, struct nfsd4_readdir *read static __be32 nfsd4_decode_remove(struct nfsd4_compoundargs *argp, struct nfsd4_remove *remove) { - DECODE_HEAD; - - READ_BUF(4); - remove->rm_namelen = be32_to_cpup(p++); - READ_BUF(remove->rm_namelen); - SAVEMEM(remove->rm_name, remove->rm_namelen); - if ((status = check_filename(remove->rm_name, remove->rm_namelen))) - return status; - - DECODE_TAIL; + return nfsd4_decode_component4(argp, &remove->rm_name, &remove->rm_namelen); } static __be32 From patchwork Mon Nov 23 20:07:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1106C2D0E4 for ; Mon, 23 Nov 2020 20:07:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 97B4420717 for ; Mon, 23 Nov 2020 20:07:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CR9sGLiF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728238AbgKWUHy (ORCPT ); Mon, 23 Nov 2020 15:07:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728236AbgKWUHx (ORCPT ); Mon, 23 Nov 2020 15:07:53 -0500 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B054C061A4D for ; Mon, 23 Nov 2020 12:07:53 -0800 (PST) Received: by mail-qk1-x742.google.com with SMTP id d9so18228135qke.8 for ; Mon, 23 Nov 2020 12:07:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=LyJTjgmV9SIQVKG5T1vVOXWk0Lgaki3Q255iyHvcfMY=; b=CR9sGLiFINtOc2QGUXUWLXn5/446sYhHih0KYqUBMq69qEPY7lSZuBHDoeYQPJzJ94 xN7P4y6aYqz7X6eHbDgDhP41jCqgjZNr2rhOGMwsN5S+Mjbleo7MNpGvnPamg+Uea4Cm UmCS+LpfA1QWCV+J2bgKAlktmuKt4M56BnxjGUd1EmLBhjTBHjULqThDVuHrfyMdL/r6 6v01aFm9tGEhencpdd/etLw0/wDv8rL+AHZCqONYEPESSooM5jRMgM/wGnRWEim43DZt zu2A+6blr6q+WZdHeGzwobOlmbzrJBUb5328uFFtDr7GzeRiWlLY7e1ir1EAP6uql3yF bgZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=LyJTjgmV9SIQVKG5T1vVOXWk0Lgaki3Q255iyHvcfMY=; b=Wh/Jksh4SHKp1pCV+Bl3zPf6R1ZdL1/ON9wjATQ4FgJN8elCVr7pyvTUwTScdL80ys B6WP6KA4dFVXZJcOEKnF58sRpDFMlOikjrGaLcfjP13KL2TlYoY5mRv24g1NVcBGs5kN hXTlcqp5PiAsDFZJZTk/vccvBPxHZQ6J8V/pWXKlMRCiwEmvMg8mEjvZ4wz0QN+d3CAE i5We1OndWbAKl/bv78N2CVP6uDYLEkLha8Y28Ro+6NXUQCitYO5Gs8TUgMSNAmjnR630 JWAbHJxNj7UjZhCqdwMVHV/verAn6VUMP8NYShccWN6fplGqE/CM7VNVJMUXrEgJj1Jc tlpA== X-Gm-Message-State: AOAM530B54+uHEaF8PxEfw6AYcsIE+SD9cjf6nnXHj3mJ1FBXJEp0HFD hws+NuAP5fNOFODEPP+iOSewkIYfhng= X-Google-Smtp-Source: ABdhPJy0MnwS+rf8tM1246FL7cslr5G2wlKvO9ET5XXKLXvdRbwba4m+TJrpStPxXCSxYDSd/LFihQ== X-Received: by 2002:a37:610:: with SMTP id 16mr1248916qkg.214.1606162072579; Mon, 23 Nov 2020 12:07:52 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id t15sm8779739qkm.114.2020.11.23.12.07.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:07:51 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK7opI010400 for ; Mon, 23 Nov 2020 20:07:50 GMT Subject: [PATCH v3 44/85] NFSD: Replace READ* macros in nfsd4_decode_rename() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:07:50 -0500 Message-ID: <160616207092.51996.17310784381514228708.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index cdec94ae81fc..ea687ea78c18 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1261,22 +1261,12 @@ nfsd4_decode_remove(struct nfsd4_compoundargs *argp, struct nfsd4_remove *remove static __be32 nfsd4_decode_rename(struct nfsd4_compoundargs *argp, struct nfsd4_rename *rename) { - DECODE_HEAD; + __be32 status; - READ_BUF(4); - rename->rn_snamelen = be32_to_cpup(p++); - READ_BUF(rename->rn_snamelen); - SAVEMEM(rename->rn_sname, rename->rn_snamelen); - READ_BUF(4); - rename->rn_tnamelen = be32_to_cpup(p++); - READ_BUF(rename->rn_tnamelen); - SAVEMEM(rename->rn_tname, rename->rn_tnamelen); - if ((status = check_filename(rename->rn_sname, rename->rn_snamelen))) - return status; - if ((status = check_filename(rename->rn_tname, rename->rn_tnamelen))) + status = nfsd4_decode_component4(argp, &rename->rn_sname, &rename->rn_snamelen); + if (status) return status; - - DECODE_TAIL; + return nfsd4_decode_component4(argp, &rename->rn_tname, &rename->rn_tnamelen); } static __be32 From patchwork Mon Nov 23 20:07:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926303 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FF77C2D0E4 for ; Mon, 23 Nov 2020 20:08:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 034F120715 for ; Mon, 23 Nov 2020 20:07:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="d4hI4Uj7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728301AbgKWUH7 (ORCPT ); Mon, 23 Nov 2020 15:07:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727846AbgKWUH6 (ORCPT ); Mon, 23 Nov 2020 15:07:58 -0500 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CC21C0613CF for ; Mon, 23 Nov 2020 12:07:58 -0800 (PST) Received: by mail-qv1-xf44.google.com with SMTP id q7so9418120qvt.12 for ; Mon, 23 Nov 2020 12:07:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=NfzVNkUokah+aFmU14vL8CdLYkXIt1+1eozBSxVmhyU=; b=d4hI4Uj7MkL1uY1n8HvvalWJfA51NQrbaBuuVzFDUr1wyaOMMkkt66uNOEwgcIYv+h 5XprjCV/H9OMn+YbrQoz3Hc368evdoVmWXGzs4H3U/tRRnzRk8xzuLtHQxxeFMWjaqh3 ThFa3lM2t3TzJMXqIXcnWbwtUtUsrEbQ21GQgGL+JfWRG/J5iBzAP7YVci81rVHJARec RU1l8KG8/8jg6SAQ7eiZ1JOZtSXDb65k0ohitvCjaS0gYA8BAodGdx8M/OPznJ0TJaqL LzDESSuI/sIW+uiMggtN0dm6voLn1BcOem5oaBguPd0dd8vSwkTJgsy4s+8krjT5cLci aKxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=NfzVNkUokah+aFmU14vL8CdLYkXIt1+1eozBSxVmhyU=; b=M6DN+MHKGMkPBJuRLDF1fwQ7WvJiJpsjexe39GVpD5mh2GriTp9WBOBTrH1cOTkhGE ZbfMaw29ETvjCSuk+NXcQDQpqF9KQdslMXytr7RW8P0Ik0piKJzbn49vQk1vYJkuUbso fALrIzxLg+ZNJHrdiPr9CFtlrISyhbwB92smj+ptNg5S/l6sgDzhCprIXk0VR4Vsxlgn O56VaOsZ3184n81O3CJbEw8OEcfyzotk1CA4goiWdxmJa50bo9cxEHPnbV0eLWtzbmW3 R/nJowSkeOxHldPVPWVljpVRN+FtDP2ccygAcSt7Gh2PzEzxRYSaGNTEFzz0hlFww7rr jsNg== X-Gm-Message-State: AOAM532ITXZYiHysTqgyaZbGimlF+VAAxgO45gu2+Iu5VgGmrUKBQ1eD 5tu5AZ+MjLARaHVB24kibNwVEOULxpU= X-Google-Smtp-Source: ABdhPJw3PTWCSP9sqe1W789d2lMqCfPDFfZB9Oruht6PqwW0yzm+a5kOrKddx5pvd0Yr7MwGR8GTYw== X-Received: by 2002:a0c:e911:: with SMTP id a17mr1310339qvo.18.1606162077613; Mon, 23 Nov 2020 12:07:57 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id k4sm10315239qtp.5.2020.11.23.12.07.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:07:57 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK7u8a010403 for ; Mon, 23 Nov 2020 20:07:56 GMT Subject: [PATCH v3 45/85] NFSD: Replace READ* macros in nfsd4_decode_renew() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:07:56 -0500 Message-ID: <160616207621.51996.8189584044738083845.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index ea687ea78c18..064020c187dd 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1272,15 +1272,7 @@ nfsd4_decode_rename(struct nfsd4_compoundargs *argp, struct nfsd4_rename *rename static __be32 nfsd4_decode_renew(struct nfsd4_compoundargs *argp, clientid_t *clientid) { - DECODE_HEAD; - - if (argp->minorversion >= 1) - return nfserr_notsupp; - - READ_BUF(sizeof(clientid_t)); - COPYMEM(clientid, sizeof(clientid_t)); - - DECODE_TAIL; + return nfsd4_decode_clientid4(argp, clientid); } static __be32 From patchwork Mon Nov 23 20:08:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926305 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2CD4C2D0E4 for ; Mon, 23 Nov 2020 20:08:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A626820715 for ; Mon, 23 Nov 2020 20:08:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="n97CW+ke" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728463AbgKWUIE (ORCPT ); Mon, 23 Nov 2020 15:08:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728458AbgKWUID (ORCPT ); Mon, 23 Nov 2020 15:08:03 -0500 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3F68C0613CF for ; Mon, 23 Nov 2020 12:08:03 -0800 (PST) Received: by mail-qk1-x744.google.com with SMTP id i199so4785214qke.5 for ; Mon, 23 Nov 2020 12:08:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=6wrDpVEo+RmhagD+Nx8qoQHWzG42nsQ1CvZhrT4NK6E=; b=n97CW+ke/kCNpGZ4KGcbL5CBPi33jE0mQEb8Iz2eoOt/5sDgH0n6IQorXc4AMKTWsl UxQBH39TLCzYA1KbpejXMho/ujdOHB/YF+z27+qtadpp6kvmcOx/umILLvn3euxdP7c7 8pxNP9uaculDGRTLXwFO/NIMCdhD/5R2K63f1nRYyqxcJObRa/tIXaf/t+aZOOu2WCYO e3SvzlXbwjBwYW6LhDEfwPeAO2k6xwiHperkg/EvamiXN5pXkemth1iQyudGFgjSs1xi LgiYgnqAggcyySkwSLzPRKBGppclaId5+jtUBBo1plPAO2MIAAdnTrYU7ND6MU5S7GqE t+UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=6wrDpVEo+RmhagD+Nx8qoQHWzG42nsQ1CvZhrT4NK6E=; b=UypbtBknz47VOtr+A8RgXktCwsiF7FzohIlBfj+ciuzbLTfYjTGcWLxKZdy7T/OFoK DB3q55gfHMumVyFjBWlFG3H7zqBzAKxcAKNN7OkVskknDLHGB6+SV7wdSTjuSEFoBbpz XC+AOXPv8b+fiI38GW+oY1LP1S27wW7/UIatNR3pnZuwirVBj3Abk5eCbJwToVyT5Onb Y0Fg+poRJXtkN/BwC4sS+3MagInr4RjwawcFUm3owpSrFvEH+vIu24smbN73xDyOHpbD z1Yc/S07EUunhUCT/O5BTvubMPiDT5AVJFvuNOUbibjd0yADm/8bhCUT2cvhzBHRw9K/ wsqQ== X-Gm-Message-State: AOAM532Gld1El49+UW7YfAnki3IJ12Au8S4nV6W158YUvJQnjzoezg2w d6lC6xcovezEHywM568624olBUMIej0= X-Google-Smtp-Source: ABdhPJxfnhyO7afz+0YHeOJXdq7kp5zXcMWTslSNSYNSd4hpLUKPle4ORA1gjGc5agaqkQJJxB32Rg== X-Received: by 2002:a37:6296:: with SMTP id w144mr1253224qkb.312.1606162082685; Mon, 23 Nov 2020 12:08:02 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id l8sm10065197qtj.93.2020.11.23.12.08.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:08:02 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK81fD010408 for ; Mon, 23 Nov 2020 20:08:01 GMT Subject: [PATCH v3 46/85] NFSD: Replace READ* macros in nfsd4_decode_secinfo() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:08:01 -0500 Message-ID: <160616208128.51996.15161555644579025881.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 064020c187dd..21b3b4e5a525 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1279,16 +1279,7 @@ static __be32 nfsd4_decode_secinfo(struct nfsd4_compoundargs *argp, struct nfsd4_secinfo *secinfo) { - DECODE_HEAD; - - READ_BUF(4); - secinfo->si_namelen = be32_to_cpup(p++); - READ_BUF(secinfo->si_namelen); - SAVEMEM(secinfo->si_name, secinfo->si_namelen); - status = check_filename(secinfo->si_name, secinfo->si_namelen); - if (status) - return status; - DECODE_TAIL; + return nfsd4_decode_component4(argp, &secinfo->si_name, &secinfo->si_namelen); } static __be32 From patchwork Mon Nov 23 20:08:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926307 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 877DBC2D0E4 for ; Mon, 23 Nov 2020 20:08:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 31A9420715 for ; Mon, 23 Nov 2020 20:08:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Rq8cYY4N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728477AbgKWUIJ (ORCPT ); Mon, 23 Nov 2020 15:08:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728458AbgKWUIJ (ORCPT ); Mon, 23 Nov 2020 15:08:09 -0500 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1691BC0613CF for ; Mon, 23 Nov 2020 12:08:09 -0800 (PST) Received: by mail-qk1-x742.google.com with SMTP id h11so6664147qkl.4 for ; Mon, 23 Nov 2020 12:08:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=aUWMFAxlrbl8tjXS0MpVEBHiARiBpd4h9u2zvX6IfSQ=; b=Rq8cYY4NZszBvQ4vCNVgCUr+Lu77KFtEW+ay76NeDITsuMzKl+BmWOUFsGYh7Ti2ng Y+Azgeaom/BHeEG4IzlNu0idSJvzGqeCjNQ2YNvTYczQ7JVOwOv0+v7FoPpOA+CCdDYb JB+Bm+b4VJ9QeiQXXmlVUiubTUxdxKGnoYIQlLMMrXctavH78X9j/Cw57jUb6KZp3xzZ wwn0gn+9GbAiiex3BqgAPFZk7bLPicSfIOJ7I/ty0reYiATe+mCFQJ8zXz4JGKbU+WKr k9KmyVUSfOzRAmU168FA834yqSSdyBSEDlwgw8/8lo62ud6WfLIfLnDjNO+FxNAu5MnQ +Ifw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=aUWMFAxlrbl8tjXS0MpVEBHiARiBpd4h9u2zvX6IfSQ=; b=gHrwLe9S+NNUtD9UwCF+lgJrhipyIP3hw7HJlRVJREU5aTik7el65wBSOkXbHYSz5r tqgKMH3Mpjuck4FWV1SCnZqkzpOVYdzbKzw50Ksm0qNzC6mIVQuRSngv1V9frHNEJS1w TdehXJMh6kaokC65uZ7LWcQZA+vJg5Ph4usBsZ+Tl2iJraJ/QBp0l7dNZgImKGC4dYQp 7XUmqD2swlZbv87OLY4KCi82ueby+fqi/bqxIHJ0RhrFJxbbrq5WSy3X0B4a2oGYDpkQ xBZHmEb6tXzmDmV7PwdvxadOb1lxAo3aRsBf6W81e0P68fVAKQRyHGJhE9IzFHQbSSUE jGnw== X-Gm-Message-State: AOAM530H61ofSjX9AKgB9/7LyKsaK/v6J1v5OXam1ma6KAN2OOADq5Cn yyFTO7cOayY8kP77l4bk0XalHeLm0AA= X-Google-Smtp-Source: ABdhPJwobseNL8Pr84rr3J34uF6UFQn6VwvON6jrqysx/Kkas3dC8cZMiQZMMjMJhZzKUGnwqLgLPA== X-Received: by 2002:a37:6892:: with SMTP id d140mr1198540qkc.200.1606162088060; Mon, 23 Nov 2020 12:08:08 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id k128sm8645640qkd.48.2020.11.23.12.08.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:08:07 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK86bR010417 for ; Mon, 23 Nov 2020 20:08:06 GMT Subject: [PATCH v3 47/85] NFSD: Replace READ* macros in nfsd4_decode_setattr() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:08:06 -0500 Message-ID: <160616208635.51996.5358162552258329645.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 21b3b4e5a525..5a1d92290e6f 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1298,7 +1298,7 @@ nfsd4_decode_setattr(struct nfsd4_compoundargs *argp, struct nfsd4_setattr *seta { __be32 status; - status = nfsd4_decode_stateid(argp, &setattr->sa_stateid); + status = nfsd4_decode_stateid4(argp, &setattr->sa_stateid); if (status) return status; return nfsd4_decode_fattr4(argp, setattr->sa_bmval, From patchwork Mon Nov 23 20:08:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926309 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 065B9C63697 for ; Mon, 23 Nov 2020 20:08:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A50202071E for ; Mon, 23 Nov 2020 20:08:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IOOxs9pg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728521AbgKWUIP (ORCPT ); Mon, 23 Nov 2020 15:08:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728503AbgKWUIO (ORCPT ); Mon, 23 Nov 2020 15:08:14 -0500 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55E42C061A4D for ; Mon, 23 Nov 2020 12:08:14 -0800 (PST) Received: by mail-qv1-xf42.google.com with SMTP id es6so691366qvb.7 for ; Mon, 23 Nov 2020 12:08:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=/9+6pTI7jWoQ5xYJuv0PkuSmbXpI9rSJ2d5sfikdqwI=; b=IOOxs9pglGd6f9wYAU+BuI2rq+msoSVQxsMFOKWX6XbKXXdVal3kQvBq+mMIUqhrii U09WwYJgQADzy9QVvJFDe+qL4BIWWg815om3Ym8620qQOD2rdiU6bujRFtZ4fcxFS9sj GazZxnfHywI8SHy8xPowB+RiR2K/EI0k3crd8BHbLvyP0EPyuYr1w6oYz4nPSA4Hf4mX qWButXFindanNXtuHj4CPzYWPzm43eEjNNOYS32Kq2Z42Q45GdfJvbMPsC4ft8IxwVC6 oer5FkeII7TqroX9Sejj9yN2BsvDeZTaW8S3OxGkBO9zOPg2vJoNr4vYhqTlZ5hFii9U 8RRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=/9+6pTI7jWoQ5xYJuv0PkuSmbXpI9rSJ2d5sfikdqwI=; b=W0Ic9vYIat3pjeIMZlaZ6eCCauqWggM2L3SfRweMpLmH8cowjq3/W02Gu0xHKc3MPD FRarw7pc1A+TqmA0Fb9fZ8KSYNPIMh0iMnvrAMRSdnmBi3JwoZMMK6uG+HANPTG048MI lbySlwtqaoUGWZyxcRVx9JTJbhHObRhIR1Xt2XmZYSPS37q10S0S9xC1J3cgWXFwxZLb tPSveP7WIZiPrCS8M0+OAf3eVC1KgcN56o4Te/YC1WebiKgW5bcfvtJIZLbmTtENOtpW crSPKmTx36yf3+SpQin7zE1TV77fWssFhyH7I0xHwrV19M5trb121jERICP+Tt6bOjOB xWWQ== X-Gm-Message-State: AOAM530RmoXrPg6AU1ixbRZ/LYjMyZL5duxO9k0Lnt6vB3OaceKrHxpA HT05BtzWrV8UMPOTma2cgi4tDJZmFyE= X-Google-Smtp-Source: ABdhPJzN3pKIbd0ll8iGU3BXf+xlqsBKkwH8F+181iUSoF4Zcu5yDF3g+2EJyGDeU5+a9NEJoB4H+Q== X-Received: by 2002:a0c:b181:: with SMTP id v1mr1123992qvd.36.1606162093256; Mon, 23 Nov 2020 12:08:13 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id q62sm527806qkf.86.2020.11.23.12.08.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:08:12 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK8BUB010420 for ; Mon, 23 Nov 2020 20:08:11 GMT Subject: [PATCH v3 48/85] NFSD: Replace READ* macros in nfsd4_decode_setclientid() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:08:11 -0500 Message-ID: <160616209164.51996.2207710435528521213.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 5a1d92290e6f..550d38ee926d 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1310,31 +1310,46 @@ nfsd4_decode_setattr(struct nfsd4_compoundargs *argp, struct nfsd4_setattr *seta static __be32 nfsd4_decode_setclientid(struct nfsd4_compoundargs *argp, struct nfsd4_setclientid *setclientid) { - DECODE_HEAD; + __be32 *p, status; if (argp->minorversion >= 1) return nfserr_notsupp; - READ_BUF(NFS4_VERIFIER_SIZE); - COPYMEM(setclientid->se_verf.data, NFS4_VERIFIER_SIZE); - + status = nfsd4_decode_verifier4(argp, &setclientid->se_verf); + if (status) + return status; status = nfsd4_decode_opaque(argp, &setclientid->se_name); if (status) + return status; + if (xdr_stream_decode_u32(argp->xdr, &setclientid->se_callback_prog) < 0) return nfserr_bad_xdr; - READ_BUF(8); - setclientid->se_callback_prog = be32_to_cpup(p++); - setclientid->se_callback_netid_len = be32_to_cpup(p++); - READ_BUF(setclientid->se_callback_netid_len); - SAVEMEM(setclientid->se_callback_netid_val, setclientid->se_callback_netid_len); - READ_BUF(4); - setclientid->se_callback_addr_len = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &setclientid->se_callback_netid_len) < 0) + return nfserr_bad_xdr; + p = xdr_inline_decode(argp->xdr, setclientid->se_callback_netid_len); + if (!p) + return nfserr_bad_xdr; + setclientid->se_callback_netid_val = svcxdr_tmpalloc(argp, + setclientid->se_callback_netid_len); + if (!setclientid->se_callback_netid_val) + return nfserr_jukebox; + memcpy(setclientid->se_callback_netid_val, p, + setclientid->se_callback_netid_len); - READ_BUF(setclientid->se_callback_addr_len); - SAVEMEM(setclientid->se_callback_addr_val, setclientid->se_callback_addr_len); - READ_BUF(4); - setclientid->se_callback_ident = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &setclientid->se_callback_addr_len) < 0) + return nfserr_bad_xdr; + p = xdr_inline_decode(argp->xdr, setclientid->se_callback_addr_len); + if (!p) + return nfserr_bad_xdr; + setclientid->se_callback_addr_val = svcxdr_tmpalloc(argp, + setclientid->se_callback_addr_len); + if (!setclientid->se_callback_addr_val) + return nfserr_jukebox; + memcpy(setclientid->se_callback_addr_val, p, + setclientid->se_callback_addr_len); + if (xdr_stream_decode_u32(argp->xdr, &setclientid->se_callback_ident) < 0) + return nfserr_bad_xdr; - DECODE_TAIL; + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:08:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926311 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B579CC63697 for ; Mon, 23 Nov 2020 20:09:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6B4D220724 for ; Mon, 23 Nov 2020 20:09:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e55K4dDd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729103AbgKWUIU (ORCPT ); Mon, 23 Nov 2020 15:08:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728458AbgKWUIT (ORCPT ); Mon, 23 Nov 2020 15:08:19 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF1AAC0613CF for ; Mon, 23 Nov 2020 12:08:19 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id i199so4786325qke.5 for ; Mon, 23 Nov 2020 12:08:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=uSaKTNGyVvz9qB9EnCPC7QEhGTyah1g1SJV8G5WXcWA=; b=e55K4dDdIPd8FXzGlQnaMKgAhXeSs9zRPRNNVSbmVA4VkxR6uqSzMDQcg66BFqrEpP w5PsZ1nGzi+RnccHfKacKAsXQ5bdN+hOHU1XUTcvY7X4+sDQVwt51Ix7hE/cAVXo3M5J x6fzJr5gbpRPUhxhLycCA+A544QeIZ3jMf9W/ECNs8tRMTl7rCYeKoar9Ex8tXrgqdVk uRBtbfETsLTjYz1/bmqCVCf0UO7FpLBO/a4Exklqj2wRKSbGIs8ADfvTPRGLFbJu93FK d3ur6EBRK+NCgZj6bml3Y9lCnkzVx4CHpu3MPsHNiBYe6X4WYeimz05Om7mZJYF73NaG mcYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=uSaKTNGyVvz9qB9EnCPC7QEhGTyah1g1SJV8G5WXcWA=; b=fb3OQWb/TMg3h6zoVytdMRPFnISZw7Qdz6ZLCrDklxjKYcXShScSp4mvxwJIWuSHlK i+3wMcUamOh5Xxi4EJUzNkmdz4imjUf2ZQPxa91laEJb5pWawBOg1C1ee7teCGog2GKW y/l5A8OmZ7NH+O8EuTQ3rjWyPs0B69YK5UInaKxJwLi+JEFV9rI3+I6ms/8auDY1ZzRx Soin6WRBX97pHt3TQmwo2Zyv6klJpNBYpBbaDmhVa8PlLueOg38zQG5Q2Gz8Myq8SGC+ pzSA6ofCLHB56phpUnf6pmjtj7FgymWikpSWoeDPwlnavLHbSGrJKOc4cGMuhTmp64F3 9yIg== X-Gm-Message-State: AOAM531YKCnjRAikfL5iE3Ves0ZlzCdcgIz+Tnz3xao9mw5UOuMG6Zb5 iPrOsPpAbc+pEKS+Vf/3ZAPj59qOrCU= X-Google-Smtp-Source: ABdhPJxOMmdkK4aKblvhVlY9uEwLMe1zAQ9vd1nP3OzZg/fLxr/ayTTiqHeo4SwSHmUQiatZ5WTXeQ== X-Received: by 2002:a05:620a:790:: with SMTP id 16mr1249832qka.169.1606162098675; Mon, 23 Nov 2020 12:08:18 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id k4sm10316105qtp.5.2020.11.23.12.08.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:08:18 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK8GWC010423 for ; Mon, 23 Nov 2020 20:08:16 GMT Subject: [PATCH v3 49/85] NFSD: Replace READ* macros in nfsd4_decode_setclientid_confirm() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:08:16 -0500 Message-ID: <160616209692.51996.9637955274935350198.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 550d38ee926d..6a6659e07eec 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1355,16 +1355,15 @@ nfsd4_decode_setclientid(struct nfsd4_compoundargs *argp, struct nfsd4_setclient static __be32 nfsd4_decode_setclientid_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_setclientid_confirm *scd_c) { - DECODE_HEAD; + __be32 status; if (argp->minorversion >= 1) return nfserr_notsupp; - READ_BUF(8 + NFS4_VERIFIER_SIZE); - COPYMEM(&scd_c->sc_clientid, 8); - COPYMEM(&scd_c->sc_confirm, NFS4_VERIFIER_SIZE); - - DECODE_TAIL; + status = nfsd4_decode_clientid4(argp, &scd_c->sc_clientid); + if (status) + return status; + return nfsd4_decode_verifier4(argp, &scd_c->sc_confirm); } /* Also used for NVERIFY */ From patchwork Mon Nov 23 20:08:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926313 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 14A48C6379D for ; Mon, 23 Nov 2020 20:09:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D056520717 for ; Mon, 23 Nov 2020 20:09:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KB39cgYP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729240AbgKWUI0 (ORCPT ); Mon, 23 Nov 2020 15:08:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728458AbgKWUI0 (ORCPT ); Mon, 23 Nov 2020 15:08:26 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17D9CC0613CF for ; Mon, 23 Nov 2020 12:08:25 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id u184so3661208qkf.3 for ; Mon, 23 Nov 2020 12:08:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=j++YOtt+ltlu5ltIe0epQUe2T7kaYbhq1qBu1VqKhDU=; b=KB39cgYPI1Ub4uP30Wubw22yqY7k9pCDuTD1tY3eTri80wi/TOfCiXOSpf02uRA3fu iJiKxTZt8QzDSU9PEQXyttrUzrHyoDGTMY2zDfLPSwFm/aMgFBTwy2L8scsyhsIWIcqJ mwEW2L9b2MLdHKQidJ1mORcpFaQA6VKzShjqXo2kc38zM/bxukomTVNW8BImggufF5xU FiyIwiyHytxb9zGrUtZ4NxGA4quHnpoYbVKSRjHP9XiG6o2wd1kd2vx1G6KeCC9Ccona oq4MEEB3qJz9sd0u4zKpIaa4mkp4v02l57gDGE3t4jlldyaJ7HIxbSxfAetJ3fQkNnGP oVQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=j++YOtt+ltlu5ltIe0epQUe2T7kaYbhq1qBu1VqKhDU=; b=txNgdIhvJeiaUWClT5xPKREecLX6vJZIpnooq75YCQGYMBSfQvw+RHwoMe4Vwe+7d5 +MWBhhTWjq2vW8RLqgcFzTa2LHCQVkMhUC8MXFGEwWLc1Fr0S/4ypbJSR0clQ2K9allr tblsmK+TiK8NSmYDkzop+WdcJGpkBOikO3GAiKmJQMiWsjDpsZpz6V/A5EMhjlo5QVg6 9P0EXK1Dxg7ZQgtDrXGzfFBWWjfSwOEMU2ez2xTCmJr29F87QEAZ11VHMyqyKeg47bgl zu3WoQmPxU9rH2h6QiMhK8tVqLhR9YeTFHIcsGqruthfxJu6EO/yiCpX+4+VktTi17uS eO8g== X-Gm-Message-State: AOAM533S0r5/jn8jnkGM0MPCsDaDf7L+sJUpzYn8K2Ukf9cuiVtPxAaG 8A7QhaUfQw+bIfiL74KKqr9zXggVV+c= X-Google-Smtp-Source: ABdhPJy+TgaLCRkuEU3PyEjNb2wqC1mr5UAzlk6xAMf+lU/c1UR8GYPtsd5LIOxL1vZxjRRxARaDfg== X-Received: by 2002:a05:620a:16ae:: with SMTP id s14mr1158251qkj.461.1606162104023; Mon, 23 Nov 2020 12:08:24 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id g70sm10595706qke.8.2020.11.23.12.08.22 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:08:23 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK8Mqe010426 for ; Mon, 23 Nov 2020 20:08:22 GMT Subject: [PATCH v3 50/85] NFSD: Replace READ* macros in nfsd4_decode_verify() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:08:22 -0500 Message-ID: <160616210221.51996.4096838677421642494.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 6a6659e07eec..d4497be2c583 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1370,20 +1370,27 @@ nfsd4_decode_setclientid_confirm(struct nfsd4_compoundargs *argp, struct nfsd4_s static __be32 nfsd4_decode_verify(struct nfsd4_compoundargs *argp, struct nfsd4_verify *verify) { - DECODE_HEAD; + __be32 *p, status; - if ((status = nfsd4_decode_bitmap(argp, verify->ve_bmval))) - goto out; + status = nfsd4_decode_bitmap4(argp, verify->ve_bmval, + ARRAY_SIZE(verify->ve_bmval)); + if (status) + return status; /* For convenience's sake, we compare raw xdr'd attributes in * nfsd4_proc_verify */ - READ_BUF(4); - verify->ve_attrlen = be32_to_cpup(p++); - READ_BUF(verify->ve_attrlen); - SAVEMEM(verify->ve_attrval, verify->ve_attrlen); + if (xdr_stream_decode_u32(argp->xdr, &verify->ve_attrlen) < 0) + return nfserr_bad_xdr; + p = xdr_inline_decode(argp->xdr, verify->ve_attrlen); + if (!p) + return nfserr_bad_xdr; + verify->ve_attrval = svcxdr_tmpalloc(argp, verify->ve_attrlen); + if (!verify->ve_attrval) + return nfserr_jukebox; + memcpy(verify->ve_attrval, p, verify->ve_attrlen); - DECODE_TAIL; + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:08:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926493 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B750C2D0E4 for ; Mon, 23 Nov 2020 20:13:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B93120657 for ; Mon, 23 Nov 2020 20:13:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vGvNmUoz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729448AbgKWUIa (ORCPT ); Mon, 23 Nov 2020 15:08:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729401AbgKWUIa (ORCPT ); Mon, 23 Nov 2020 15:08:30 -0500 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60F5FC061A4D for ; Mon, 23 Nov 2020 12:08:30 -0800 (PST) Received: by mail-qk1-x742.google.com with SMTP id z188so6818051qke.9 for ; Mon, 23 Nov 2020 12:08:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=2hPYTwNS/Ywav1XEbM2c8+2miBjaZyYzbSMSWwDdPBc=; b=vGvNmUozL0DIfhC6dzpYbT0o9Lu3LzIPs2jKUaK/GM5thn9F/iHJUonZUQqj/lH3Bg tKBVCobgVmAgCZglhRGz+lkuJ3Hg7GIJY7NJRTpiSKuFW3bBOBjSlbEjmH0iyfYdVa6T L5C59cZ9MdMeav9Fn4L3N1OAhrCD93s2zPjpw2IVTKzllseIwT5p8Km4ktjsRgVrxd2u mY6NUv1xNBNAHYTnmOYMNE7ebalhcSVZ5u5ZDKUDaNIWAmMewm5Rae66tKzN47JbI+G2 ngxI4+q6UguX/06PyXus5FS7Gqkfb7PQtkOTQwO2hmFHkO//05Vqxr8kxXbLB7jo23PK CgBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=2hPYTwNS/Ywav1XEbM2c8+2miBjaZyYzbSMSWwDdPBc=; b=A/I71ha+Km2XMEQccwETEVnsKN8CeqZo+7GoxPIaujL7BYerXspUNEpoRDWRDc9Bm+ 933NZ/4MDqp/fM0Av21gDjKqMKVLq8AITl8h9vLiCU9loA8rZsstQWjffHc7P8cmaoDm rHDYUSyvQt+aUCvRep01O/ud16rz1f950WSZNW4ESMAD6FhoKAYTl75IveF3FiVJvTrW x3m04u8FM1q8DeP8yFqSoskFF5WlDhIJ8GL8imODgfL78NqMP+A6tnahsTtzNxVvYcAs 18++eZLYNz26n/pL9W3a451iksLrnMQ9WXYUO9rEpYC5jaoxXR66ec2UMsefIknzYVv6 1Rgg== X-Gm-Message-State: AOAM5333FyiRLj/qLxJb3w5ag30srZ4x1XOOCr9N/5TXzYgOWgRCUph4 WTYELk359BmUrqzg5+xMHtuBfgqgJ6k= X-Google-Smtp-Source: ABdhPJzDbejww2PTxsxkIJl0DxjGKRomA+RYZ7uRv6NacB6yFoxLoFMKPXcyfnyIaHOH36/o4XgdIw== X-Received: by 2002:ae9:ea14:: with SMTP id f20mr1185331qkg.239.1606162109169; Mon, 23 Nov 2020 12:08:29 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id l28sm9782986qkl.7.2020.11.23.12.08.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:08:28 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK8RER010429 for ; Mon, 23 Nov 2020 20:08:27 GMT Subject: [PATCH v3 51/85] NFSD: Replace READ* macros in nfsd4_decode_write() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:08:27 -0500 Message-ID: <160616210749.51996.12880752418411320389.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index d4497be2c583..226c37957556 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1396,22 +1396,23 @@ nfsd4_decode_verify(struct nfsd4_compoundargs *argp, struct nfsd4_verify *verify static __be32 nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write) { - DECODE_HEAD; + __be32 status; - status = nfsd4_decode_stateid(argp, &write->wr_stateid); + status = nfsd4_decode_stateid4(argp, &write->wr_stateid); if (status) return status; - READ_BUF(16); - p = xdr_decode_hyper(p, &write->wr_offset); - write->wr_stable_how = be32_to_cpup(p++); + if (xdr_stream_decode_u64(argp->xdr, &write->wr_offset) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &write->wr_stable_how) < 0) + return nfserr_bad_xdr; if (write->wr_stable_how > NFS_FILE_SYNC) - goto xdr_error; - write->wr_buflen = be32_to_cpup(p++); - + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &write->wr_buflen) < 0) + return nfserr_bad_xdr; if (!xdr_stream_subsegment(argp->xdr, &write->wr_payload, write->wr_buflen)) - goto xdr_error; + return nfserr_bad_xdr; - DECODE_TAIL; + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:08:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926315 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D845C64E8A for ; Mon, 23 Nov 2020 20:09:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD9D620717 for ; Mon, 23 Nov 2020 20:09:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qoqZZN/x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729786AbgKWUIh (ORCPT ); Mon, 23 Nov 2020 15:08:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729760AbgKWUIf (ORCPT ); Mon, 23 Nov 2020 15:08:35 -0500 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B10DFC0613CF for ; Mon, 23 Nov 2020 12:08:35 -0800 (PST) Received: by mail-qv1-xf44.google.com with SMTP id u23so9455396qvf.1 for ; Mon, 23 Nov 2020 12:08:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=nAoxune6BpDAHqUZufK7mLh7Nw52CQ4hI3jblqiJH+w=; b=qoqZZN/xkcs0z+JRnAMTNFWqJjcK3YX9tbdHrQZwp3CrVk2SUWpLfI+Yw/Kj+Cy1Hk r/0Qk286YKXo90JYQNm7kFTONFq8n36fji9AFSwEmdQP8Il1UboRNCFF5Ue6Yeb1MZS8 pQgiG2ESXNLI5k8dydt7Fi0WtkOpGDLfVXRa3PbFqMqLAxZvR3FPbLaRQYcXT4R4e9CV 2Hm+Jvri6rg74LgcdqJ4bq+91OA+s6VflmoKEgShi+24KJTXgWZwkg8qgm+7NOX6BaRt 0AkUnaMdL9/dOshxCVS+duEbw7JQrXDTt4RFU4+kS70L8tIntC5jx3jc6Z+3K4VuoUnH wpEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=nAoxune6BpDAHqUZufK7mLh7Nw52CQ4hI3jblqiJH+w=; b=jkO3PLBimUe2QAqORvjZXkpjAKzaLtpP1gxW/opudCc4buRcMGpkFamR4v8sD6i6uh womnQrdzHaIdAkhv5HiIP/x6SSUnJdvyKA0/qkG4Z/KUEktS33jZ6VlH3htbqqnHgzCk cQIWPj7/jva/wFa78tX2ZKPhmj5FHfiF8w8QStCxFwIxQEJb3eUWqD51a0d0IKIonFvV Q7tyHKl+SqqF5b2gB15kSqzVY3g5xJigLViA/pvkpTTCCKaoftRmBL3KaKgN3riYtxBA bujJ1+VNYnxrtJFuU/dYhn6RrfZlUVcA4xafbeEx6R12fjLQu56qMxQZ1Irc0VUBtpKu QzNw== X-Gm-Message-State: AOAM533J5vHyQSH4TKnFXUNoDwU8WZ3vmqGtpR3TKS4CDPnOyLC078yQ lsoqnvOS6Ls84MMhzm/CgohTTB/7PXU= X-Google-Smtp-Source: ABdhPJyIA9CsU2Ji9yf7Tu05Il62ASIjkuXbxEKtG1Q5tOT1go5IYDRGiFwzUABlS+CCMd1hN4tZtQ== X-Received: by 2002:a05:6214:a69:: with SMTP id ef9mr1170672qvb.50.1606162114458; Mon, 23 Nov 2020 12:08:34 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id q20sm10082788qtn.80.2020.11.23.12.08.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:08:33 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK8Wqs010432 for ; Mon, 23 Nov 2020 20:08:32 GMT Subject: [PATCH v3 52/85] NFSD: Replace READ* macros in nfsd4_decode_release_lockowner() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:08:32 -0500 Message-ID: <160616211278.51996.10005952551727082844.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 226c37957556..0a2474542309 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1418,20 +1418,20 @@ nfsd4_decode_write(struct nfsd4_compoundargs *argp, struct nfsd4_write *write) static __be32 nfsd4_decode_release_lockowner(struct nfsd4_compoundargs *argp, struct nfsd4_release_lockowner *rlockowner) { - DECODE_HEAD; + __be32 status; if (argp->minorversion >= 1) return nfserr_notsupp; - READ_BUF(12); - COPYMEM(&rlockowner->rl_clientid, sizeof(clientid_t)); - rlockowner->rl_owner.len = be32_to_cpup(p++); - READ_BUF(rlockowner->rl_owner.len); - READMEM(rlockowner->rl_owner.data, rlockowner->rl_owner.len); + status = nfsd4_decode_state_owner4(argp, &rlockowner->rl_clientid, + &rlockowner->rl_owner); + if (status) + return status; if (argp->minorversion && !zero_clientid(&rlockowner->rl_clientid)) return nfserr_inval; - DECODE_TAIL; + + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:08:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926317 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D477BC64EBC for ; Mon, 23 Nov 2020 20:09:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C5DC20715 for ; Mon, 23 Nov 2020 20:09:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YtPthJMG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728608AbgKWUIl (ORCPT ); Mon, 23 Nov 2020 15:08:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729999AbgKWUIk (ORCPT ); Mon, 23 Nov 2020 15:08:40 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1C7CC0613CF for ; Mon, 23 Nov 2020 12:08:40 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id u4so18225979qkk.10 for ; Mon, 23 Nov 2020 12:08:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=VVVrypne4AeSywEEvRqVh0zfmtCtzGNwJ8y/AUKcfes=; b=YtPthJMG1OU0/8Zq7TrDFdM0lpBiDFyaK+oPIVup/gI8YdBCgm9niOzM2hWTwQfqYV XhEf9fBTcoihcDckwZjtJZvNWqDvIueJJvSsX3alu/aVdwELlnkDjFnY3PJsoP5kZUF3 DMiWWIq93jPhLLN5MCVpEaBtAoj+KrYOKhtHCVFpNoGVLquZlAGDILZBGR4NtZ2AWq4T uBINDydUbRJuY33Q30ulVcdQDAkh/07N2Y0inMNk2VdG6NnmS9tJhSGl7dHeh4wvIvJ/ q26pOs4Tt2/RmSKL6FdiaLVo2TrS/sZ4cSLsHHXi3k5+bSX+hOa8dKKP7HCkvjWMd/Wh vZYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=VVVrypne4AeSywEEvRqVh0zfmtCtzGNwJ8y/AUKcfes=; b=GmW43pI9ypWZjh+RufmDQ/OSeLeqGbXsxysuUQ6vlkzudfBZs3wI3wvNhHpFpgin6s b3/nTrqRDknrfZFoGQm4syMv/+DJWue1XFeHHlGJlxT71ppK5s/lTpQZJmlY5/UZAxJg 2g37ROi8LQOwJB8weCCGXstwCso1tbw5VnnEsMNDG51iIPVUFWhi7sKEcek0HUGleVcl zgQ3sEk60uPekTbgMmJF8wiloNRQHAbRmEY+Xjzvs85aRYbcbSzkQd2qSSC3kaX6xwJq xAddniK4kqBTyBYIBPcBOB8V73z7Z8cF3XsCj0L0VcYFOOr4d+XeReEjjwAl004c6UCG dDoQ== X-Gm-Message-State: AOAM531tntdPqIu7eLZtXq9rhaspvh1zltwLRZLjSkbzBqYj9rEZlsJj 4wh+m7W2F+fUX5CpdtkCXEao/+z9x88= X-Google-Smtp-Source: ABdhPJzKTZ2bo/B3A1giXbXEeEQzEwTtTLc/sW3K8wA4L8VizyQx8UUwyR2p7QS1oBJpFErCLnNAbQ== X-Received: by 2002:a37:9dd1:: with SMTP id g200mr1249493qke.376.1606162119682; Mon, 23 Nov 2020 12:08:39 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id e9sm7966969qtr.95.2020.11.23.12.08.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:08:39 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK8ceH010435 for ; Mon, 23 Nov 2020 20:08:38 GMT Subject: [PATCH v3 53/85] NFSD: Replace READ* macros in nfsd4_decode_cb_sec() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:08:38 -0500 Message-ID: <160616211806.51996.1070194178927932232.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 165 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 107 insertions(+), 58 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 0a2474542309..acbe461e03ae 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -212,6 +212,25 @@ static char *savemem(struct nfsd4_compoundargs *argp, __be32 *p, int nbytes) * NFSv4 basic data type decoders */ +/* + * This helper handles variable-length opaques which belong to protocol + * elements that this implementation does not support. + */ +static __be32 +nfsd4_decode_ignored_string(struct nfsd4_compoundargs *argp, u32 maxlen) +{ + u32 len; + + if (xdr_stream_decode_u32(argp->xdr, &len) < 0) + return nfserr_bad_xdr; + if (maxlen && len > maxlen) + return nfserr_bad_xdr; + if (!xdr_inline_decode(argp->xdr, len)) + return nfserr_bad_xdr; + + return nfs_ok; +} + static __be32 nfsd4_decode_opaque(struct nfsd4_compoundargs *argp, struct xdr_netobj *o) { @@ -645,87 +664,117 @@ nfsd4_decode_state_owner4(struct nfsd4_compoundargs *argp, return nfsd4_decode_opaque(argp, owner); } -static __be32 nfsd4_decode_cb_sec(struct nfsd4_compoundargs *argp, struct nfsd4_cb_sec *cbs) +/* Defined in Appendix A of RFC 5531 */ +static __be32 +nfsd4_decode_authsys_parms(struct nfsd4_compoundargs *argp, + struct nfsd4_cb_sec *cbs) { - DECODE_HEAD; - struct user_namespace *userns = nfsd_user_namespace(argp->rqstp); - u32 dummy, uid, gid; - char *machine_name; - int i; - int nr_secflavs; + u32 stamp, gidcount, uid, gid; + __be32 *p, status; + + if (xdr_stream_decode_u32(argp->xdr, &stamp) < 0) + return nfserr_bad_xdr; + /* machine name */ + status = nfsd4_decode_ignored_string(argp, 255); + if (status) + return status; + if (xdr_stream_decode_u32(argp->xdr, &uid) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &gid) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &gidcount) < 0) + return nfserr_bad_xdr; + if (gidcount > 16) + return nfserr_bad_xdr; + p = xdr_inline_decode(argp->xdr, gidcount << 2); + if (!p) + return nfserr_bad_xdr; + if (cbs->flavor == (u32)(-1)) { + struct user_namespace *userns = nfsd_user_namespace(argp->rqstp); + + kuid_t kuid = make_kuid(userns, uid); + kgid_t kgid = make_kgid(userns, gid); + if (uid_valid(kuid) && gid_valid(kgid)) { + cbs->uid = kuid; + cbs->gid = kgid; + cbs->flavor = RPC_AUTH_UNIX; + } else { + dprintk("RPC_AUTH_UNIX with invalid uid or gid, ignoring!\n"); + } + } + + return nfs_ok; +} + +static __be32 +nfsd4_decode_gss_cb_handles4(struct nfsd4_compoundargs *argp, + struct nfsd4_cb_sec *cbs) +{ + __be32 status; + u32 service; + + dprintk("RPC_AUTH_GSS callback secflavor not supported!\n"); + + if (xdr_stream_decode_u32(argp->xdr, &service) < 0) + return nfserr_bad_xdr; + if (service < RPC_GSS_SVC_NONE || service > RPC_GSS_SVC_PRIVACY) + return nfserr_bad_xdr; + /* gcbp_handle_from_server */ + status = nfsd4_decode_ignored_string(argp, 0); + if (status) + return status; + /* gcbp_handle_from_client */ + status = nfsd4_decode_ignored_string(argp, 0); + if (status) + return status; + + return nfs_ok; +} + +/* a counted array of callback_sec_parms4 items */ +static __be32 +nfsd4_decode_cb_sec(struct nfsd4_compoundargs *argp, struct nfsd4_cb_sec *cbs) +{ + u32 i, secflavor, nr_secflavs; + __be32 status; /* callback_sec_params4 */ - READ_BUF(4); - nr_secflavs = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &nr_secflavs) < 0) + return nfserr_bad_xdr; if (nr_secflavs) cbs->flavor = (u32)(-1); else /* Is this legal? Be generous, take it to mean AUTH_NONE: */ cbs->flavor = 0; + for (i = 0; i < nr_secflavs; ++i) { - READ_BUF(4); - dummy = be32_to_cpup(p++); - switch (dummy) { + if (xdr_stream_decode_u32(argp->xdr, &secflavor) < 0) + return nfserr_bad_xdr; + switch (secflavor) { case RPC_AUTH_NULL: - /* Nothing to read */ + /* void */ if (cbs->flavor == (u32)(-1)) cbs->flavor = RPC_AUTH_NULL; break; case RPC_AUTH_UNIX: - READ_BUF(8); - /* stamp */ - dummy = be32_to_cpup(p++); - - /* machine name */ - dummy = be32_to_cpup(p++); - READ_BUF(dummy); - SAVEMEM(machine_name, dummy); - - /* uid, gid */ - READ_BUF(8); - uid = be32_to_cpup(p++); - gid = be32_to_cpup(p++); - - /* more gids */ - READ_BUF(4); - dummy = be32_to_cpup(p++); - READ_BUF(dummy * 4); - if (cbs->flavor == (u32)(-1)) { - kuid_t kuid = make_kuid(userns, uid); - kgid_t kgid = make_kgid(userns, gid); - if (uid_valid(kuid) && gid_valid(kgid)) { - cbs->uid = kuid; - cbs->gid = kgid; - cbs->flavor = RPC_AUTH_UNIX; - } else { - dprintk("RPC_AUTH_UNIX with invalid" - "uid or gid ignoring!\n"); - } - } + status = nfsd4_decode_authsys_parms(argp, cbs); + if (status) + return status; break; case RPC_AUTH_GSS: - dprintk("RPC_AUTH_GSS callback secflavor " - "not supported!\n"); - READ_BUF(8); - /* gcbp_service */ - dummy = be32_to_cpup(p++); - /* gcbp_handle_from_server */ - dummy = be32_to_cpup(p++); - READ_BUF(dummy); - p += XDR_QUADLEN(dummy); - /* gcbp_handle_from_client */ - READ_BUF(4); - dummy = be32_to_cpup(p++); - READ_BUF(dummy); + status = nfsd4_decode_gss_cb_handles4(argp, cbs); + if (status) + return status; break; default: - dprintk("Illegal callback secflavor\n"); return nfserr_inval; } } - DECODE_TAIL; + + return nfs_ok; } + /* * NFSv4 operation argument decoders */ From patchwork Mon Nov 23 20:08:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E9BCC71156 for ; Mon, 23 Nov 2020 20:09:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3AFED20717 for ; Mon, 23 Nov 2020 20:09:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E4EJHGgz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730001AbgKWUIq (ORCPT ); Mon, 23 Nov 2020 15:08:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729708AbgKWUIq (ORCPT ); Mon, 23 Nov 2020 15:08:46 -0500 Received: from mail-qv1-xf44.google.com (mail-qv1-xf44.google.com [IPv6:2607:f8b0:4864:20::f44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C4CC061A4D for ; Mon, 23 Nov 2020 12:08:46 -0800 (PST) Received: by mail-qv1-xf44.google.com with SMTP id ek7so9450492qvb.6 for ; Mon, 23 Nov 2020 12:08:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=1B8RcYTvrIidCvhnrNz+kUHJjx/EBQgtYfA3y5nP/Lk=; b=E4EJHGgzI23UCgpU4UmfBwjFo9Gj9MNwlF5qsmLBsvAAD1coHEWldVpBDb74ICE71Q cnz4iFQ0pwEMDKo53a7KOOxi5X10PffROfxd1XNoF7nfFEMAwC2cW8JO7/Eh+ENggB9H nbVzvfsgfI+8m7i2b46kisRsxyX6/XuKhm9GcJCRhw0M8FCN/qTbOyes7Vwp8Gv21ANh +XGn8+qGOFjT7P3UftiQx59VXT5B/4F2k2Z5UlPTgX8fCA8mmVsq6jV2p77Ny/BOVDgE m0hQxNSj/zkc2Y070qUF6JOVKoyr3hR19G/WTANzv96O52U/mlH7ez5kZJz+FD9zNvTH 9aTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=1B8RcYTvrIidCvhnrNz+kUHJjx/EBQgtYfA3y5nP/Lk=; b=tpCeAd6TXPlaP7XFcBU/Um0fSCgAVAK8mKhacbW14XgFpbHHia+LnKHuoalEgJ8hsV aHTVJ1ip719QAK3rfan++XVNlxnsy+CMZEj26VC7eUFOlpJUB+7EiqqjlaXnVmccLOl7 SmBu2cb8BG9PPInaErHmvBmI9GsdeLp6I+qE6tAYNwLQ1Tqr0nDjgaTV1EXjpnJf+vnt ofTw6nRb3lRvilDDFykzdY2Q9DHJaODA1loLYGmm4GnjtXj/K0hCiESyumgvkCs1s/Zz kePqxgCD5XrGzdNYgpaVj7IcqVvaZ+DWkxXeSQ3K3krV52DvSdA6j3JCIZ9GPhRuoPux gb7Q== X-Gm-Message-State: AOAM530NGOF4bJBN5IBB6BuNMFU2QfSoACICGggDKifipkR3iN6OLVNy aLaNrfuA5nNnC+W8tuLMNMZaWoluMk0= X-Google-Smtp-Source: ABdhPJzTPOJsQyPvQ+u60R9FQb2jdrvpJwzAaMo/zCU0poxf3wAinV0rAtCadkIIY57xxBN6n55hoQ== X-Received: by 2002:ad4:4cd0:: with SMTP id i16mr1115936qvz.13.1606162124992; Mon, 23 Nov 2020 12:08:44 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id d66sm11345046qke.132.2020.11.23.12.08.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:08:44 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK8hlF010438 for ; Mon, 23 Nov 2020 20:08:43 GMT Subject: [PATCH v3 54/85] NFSD: Replace READ* macros in nfsd4_decode_backchannel_ctl() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:08:43 -0500 Message-ID: <160616212335.51996.575379692286109461.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index acbe461e03ae..87a3c0c53945 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -788,17 +788,6 @@ nfsd4_decode_access(struct nfsd4_compoundargs *argp, return nfs_ok; } -static __be32 nfsd4_decode_backchannel_ctl(struct nfsd4_compoundargs *argp, struct nfsd4_backchannel_ctl *bc) -{ - DECODE_HEAD; - - READ_BUF(4); - bc->bc_cb_program = be32_to_cpup(p++); - nfsd4_decode_cb_sec(argp, &bc->bc_cb_sec); - - DECODE_TAIL; -} - static __be32 nfsd4_decode_bind_conn_to_session(struct nfsd4_compoundargs *argp, struct nfsd4_bind_conn_to_session *bcts) { DECODE_HEAD; @@ -1483,6 +1472,13 @@ nfsd4_decode_release_lockowner(struct nfsd4_compoundargs *argp, struct nfsd4_rel return nfs_ok; } +static __be32 nfsd4_decode_backchannel_ctl(struct nfsd4_compoundargs *argp, struct nfsd4_backchannel_ctl *bc) +{ + if (xdr_stream_decode_u32(argp->xdr, &bc->bc_cb_program) < 0) + return nfserr_bad_xdr; + return nfsd4_decode_cb_sec(argp, &bc->bc_cb_sec); +} + static __be32 nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, struct nfsd4_exchange_id *exid) From patchwork Mon Nov 23 20:08:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926321 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9BB7C8300C for ; Mon, 23 Nov 2020 20:09:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ABA7420717 for ; Mon, 23 Nov 2020 20:09:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Pjw/XWZZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730431AbgKWUIx (ORCPT ); Mon, 23 Nov 2020 15:08:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730363AbgKWUIw (ORCPT ); Mon, 23 Nov 2020 15:08:52 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 525A4C061A4D for ; Mon, 23 Nov 2020 12:08:51 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id u4so18226555qkk.10 for ; Mon, 23 Nov 2020 12:08:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=NQSk4okHm8AyzilFeA+KiYrv/j2cBUHm8a6jv1JtyyQ=; b=Pjw/XWZZ67zX54LmIlYIVGWSEU1GjIrbHhMhXW98+sDaUnKnMnr0z676eLWPiyqV2v +FsvaQV1oytzh0RD2H5xQK/dt0dbK3Qe2FoRwliA/XJrtFTv2TxlZjHm+mn+3pYjIlVF Y3JvyOnJ1hy869qSQGU3Tfcf7asuHukuibhrupYXv69wgaZYLNCQtBPL5hzUPRCQqt3A XRvrXXj3MR4qga9ABgPg8yTFT1sGXsUN0LgzjunW+wcA1ucdSxLUglx+3P1ejshp0pZ/ jCjZdsr+Cv7eQgP6HmFijUNHEgxWxHpw12EX6QtSKqFcvZuZMTActg+1dCUiS0ZNuK7Y mNlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=NQSk4okHm8AyzilFeA+KiYrv/j2cBUHm8a6jv1JtyyQ=; b=DQ2UbShw7Dxn7lDBSYVWjwYYq/9Pn5qKFGZZSb7WM1175nPthlDB9IdLTTPRDlWoy8 Jh4M2Bu4WjWUuDOV0/sMR+f/5hm6yAvYwgRJ3kouWTS1D4r3ikKVfy1ct64bZSy0Qx4i tw6Jg2MjGFXnFJYWKI+0KkU/WmPoa5VWyHgQ6hLQ9OFyOqzWAN8J4d4czjFK0vaVRcIh J8CmeEEd1WtBW3ThgCseMVwk9igHAIPvLUGmM5DBmRNB43oH7bzt+u2ZcFZ368E15aDW VE0nta4ZX0lQD9S5TvouAD/ccLXaszScmwYaS82tpUeXpLxWoLWyfvoiGeOtV98u1P9L wx2g== X-Gm-Message-State: AOAM533i1Np8qC70MIXwmSoCBxXX4MPmW1Dwdht6hmZ4invAmTdnhnQh HpixYMQTE0DQcf09BdvLmyjz+/KUFDc= X-Google-Smtp-Source: ABdhPJwjtemikrX55gfUQFzSqXoYMiIQhvPO6cYaCXxLDzGmWzHTytQCeowuTH/vnUs45Mit1IsISg== X-Received: by 2002:a37:a8c8:: with SMTP id r191mr1233460qke.58.1606162130264; Mon, 23 Nov 2020 12:08:50 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id g8sm10766095qkk.131.2020.11.23.12.08.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:08:49 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK8mXc010441 for ; Mon, 23 Nov 2020 20:08:48 GMT Subject: [PATCH v3 55/85] NFSD: Replace READ* macros in nfsd4_decode_bind_conn_to_session() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:08:48 -0500 Message-ID: <160616212863.51996.8575531760483185115.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org A dedicated sessionid4 decoder is introduced that will be used by other operation decoders in subsequent patches. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 87a3c0c53945..9989a6dfb2d4 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -664,6 +664,19 @@ nfsd4_decode_state_owner4(struct nfsd4_compoundargs *argp, return nfsd4_decode_opaque(argp, owner); } +static __be32 +nfsd4_decode_sessionid4(struct nfsd4_compoundargs *argp, + struct nfs4_sessionid *sessionid) +{ + __be32 *p; + + p = xdr_inline_decode(argp->xdr, NFS4_MAX_SESSIONID_LEN); + if (!p) + return nfserr_bad_xdr; + memcpy(sessionid->data, p, sizeof(sessionid->data)); + return nfs_ok; +} + /* Defined in Appendix A of RFC 5531 */ static __be32 nfsd4_decode_authsys_parms(struct nfsd4_compoundargs *argp, @@ -788,18 +801,6 @@ nfsd4_decode_access(struct nfsd4_compoundargs *argp, return nfs_ok; } -static __be32 nfsd4_decode_bind_conn_to_session(struct nfsd4_compoundargs *argp, struct nfsd4_bind_conn_to_session *bcts) -{ - DECODE_HEAD; - - READ_BUF(NFS4_MAX_SESSIONID_LEN + 8); - COPYMEM(bcts->sessionid.data, NFS4_MAX_SESSIONID_LEN); - bcts->dir = be32_to_cpup(p++); - /* XXX: skipping ctsa_use_conn_in_rdma_mode. Perhaps Tom Tucker - * could help us figure out we should be using it. */ - DECODE_TAIL; -} - static __be32 nfsd4_decode_close(struct nfsd4_compoundargs *argp, struct nfsd4_close *close) { @@ -1479,6 +1480,22 @@ static __be32 nfsd4_decode_backchannel_ctl(struct nfsd4_compoundargs *argp, stru return nfsd4_decode_cb_sec(argp, &bc->bc_cb_sec); } +static __be32 nfsd4_decode_bind_conn_to_session(struct nfsd4_compoundargs *argp, struct nfsd4_bind_conn_to_session *bcts) +{ + u32 use_conn_in_rdma_mode; + __be32 status; + + status = nfsd4_decode_sessionid4(argp, &bcts->sessionid); + if (status) + return status; + if (xdr_stream_decode_u32(argp->xdr, &bcts->dir) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &use_conn_in_rdma_mode) < 0) + return nfserr_bad_xdr; + + return nfs_ok; +} + static __be32 nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, struct nfsd4_exchange_id *exid) From patchwork Mon Nov 23 20:08:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31263C63798 for ; Mon, 23 Nov 2020 20:09:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E1D5420715 for ; Mon, 23 Nov 2020 20:09:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="qOF9/Wef" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730615AbgKWUI7 (ORCPT ); Mon, 23 Nov 2020 15:08:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728596AbgKWUI5 (ORCPT ); Mon, 23 Nov 2020 15:08:57 -0500 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9730DC0613CF for ; Mon, 23 Nov 2020 12:08:56 -0800 (PST) Received: by mail-qv1-xf43.google.com with SMTP id ek7so9450835qvb.6 for ; Mon, 23 Nov 2020 12:08:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=avIS2zgACPqncgzUYiQJ+I+WSzAGG86j1QUPQ+4zttg=; b=qOF9/Wefpgd5Rr6l5VIzb6GWQwkFPpkXncnPgmjZtlnMTX9A0+F2nC69jgUYSHD1kw 3ChTU0Q+RWJ57QpPE4bk+MhWdTjCPRgNp5Ma9Tj+wxZt75aAhCZyo/vqKbbg4PIXQGj1 SYyDOXVbfAmsaloB3DDhNOKC9aIwdT4sFBWRNksgctQDL3L4N7J18m834AagThT8rCdh HuI3E2EbMOmFXLA0ZP+rYo9JhcaIMAjQ6WTY3uMz2Nm1PDHwTaNxsi2SIYNIIItBW3sY AhyuwesmcpGIrDLAzG4QejrzF2lfHUbfM2Fm/TJfVIlQzzigijHGDNcfo9Lbu0W88nPK Unww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=avIS2zgACPqncgzUYiQJ+I+WSzAGG86j1QUPQ+4zttg=; b=H77ZpBTMJ9caKeOdOIQCuoNpe5IlDkeaSoaLq2Ua1QlStWwYCEfB4ubzmUpf2I5VdR wORGAHzX0LLsSLL09uG5eyrGSrSNi1SIlSPtKVVAz3+3EdkqUvB7RwstLtTAOYuPu7kn LeFgYLedCbwFMRyUOpYjytflVzMo/8P1r5L+5EsN5PUN3Rtk+woksVGx5Vu+OrpFWlI6 EvZW3X8DXHCpVj2Zc/Z5alXxR1F7khyMcmOLKk+f1fbkbs/xfYoQEYf+HwblTxBzw91b gig2SVuGX0eVY2ZsAd6nLHxZoXJR5Ljuob4bcjA/PoqH7unUotjthW2MvhbaXKoTBF1b pqPg== X-Gm-Message-State: AOAM530IGYwIVM1tP1mUHQoQO8ztyQtCo40mQLeixruJKsKV0gaxnJjW jzMuqyn6R/5UGQqYojbe2tzCpWxabF4= X-Google-Smtp-Source: ABdhPJwc0qPiVz3AqZPVFNw9GFEe1VUyWtyO2aoktQYD1CyYpI4UpWf2H43/GjneYChX0qJD4fyf2w== X-Received: by 2002:a0c:e443:: with SMTP id d3mr1150494qvm.18.1606162135536; Mon, 23 Nov 2020 12:08:55 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id t15sm8782588qkm.114.2020.11.23.12.08.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:08:54 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK8rJC010444 for ; Mon, 23 Nov 2020 20:08:53 GMT Subject: [PATCH v3 56/85] NFSD: Add a separate decoder to handle state_protect_ops From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:08:53 -0500 Message-ID: <160616213392.51996.13089999437533932245.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Refactor for clarity and de-duplication of code. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 66 ++++++++++++++++++----------------------------------- 1 file changed, 23 insertions(+), 43 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 9989a6dfb2d4..165591c435bc 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -315,32 +315,6 @@ nfsd4_decode_verifier4(struct nfsd4_compoundargs *argp, nfs4_verifier *verf) return nfs_ok; } -static __be32 -nfsd4_decode_bitmap(struct nfsd4_compoundargs *argp, u32 *bmval) -{ - u32 bmlen; - DECODE_HEAD; - - bmval[0] = 0; - bmval[1] = 0; - bmval[2] = 0; - - READ_BUF(4); - bmlen = be32_to_cpup(p++); - if (bmlen > 1000) - goto xdr_error; - - READ_BUF(bmlen << 2); - if (bmlen > 0) - bmval[0] = be32_to_cpup(p++); - if (bmlen > 1) - bmval[1] = be32_to_cpup(p++); - if (bmlen > 2) - bmval[2] = be32_to_cpup(p++); - - DECODE_TAIL; -} - /** * nfsd4_decode_bitmap4 - Decode an NFSv4 bitmap4 * @argp: NFSv4 compound argument structure @@ -1496,6 +1470,24 @@ static __be32 nfsd4_decode_bind_conn_to_session(struct nfsd4_compoundargs *argp, return nfs_ok; } +static __be32 +nfsd4_decode_state_protect_ops(struct nfsd4_compoundargs *argp, + struct nfsd4_exchange_id *exid) +{ + __be32 status; + + status = nfsd4_decode_bitmap4(argp, exid->spo_must_enforce, + ARRAY_SIZE(exid->spo_must_enforce)); + if (status) + return nfserr_bad_xdr; + status = nfsd4_decode_bitmap4(argp, exid->spo_must_allow, + ARRAY_SIZE(exid->spo_must_allow)); + if (status) + return nfserr_bad_xdr; + + return nfs_ok; +} + static __be32 nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, struct nfsd4_exchange_id *exid) @@ -1520,27 +1512,15 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, case SP4_NONE: break; case SP4_MACH_CRED: - /* spo_must_enforce */ - status = nfsd4_decode_bitmap(argp, - exid->spo_must_enforce); - if (status) - goto out; - /* spo_must_allow */ - status = nfsd4_decode_bitmap(argp, exid->spo_must_allow); + status = nfsd4_decode_state_protect_ops(argp, exid); if (status) - goto out; + return status; break; case SP4_SSV: /* ssp_ops */ - READ_BUF(4); - dummy = be32_to_cpup(p++); - READ_BUF(dummy * 4); - p += dummy; - - READ_BUF(4); - dummy = be32_to_cpup(p++); - READ_BUF(dummy * 4); - p += dummy; + status = nfsd4_decode_state_protect_ops(argp, exid); + if (status) + return status; /* ssp_hash_algs<> */ READ_BUF(4); From patchwork Mon Nov 23 20:08:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926325 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8274C83013 for ; Mon, 23 Nov 2020 20:09:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 63D8820715 for ; Mon, 23 Nov 2020 20:09:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rbN7Vgus" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727483AbgKWUJE (ORCPT ); Mon, 23 Nov 2020 15:09:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730575AbgKWUJB (ORCPT ); Mon, 23 Nov 2020 15:09:01 -0500 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA1FBC0613CF for ; Mon, 23 Nov 2020 12:09:01 -0800 (PST) Received: by mail-qk1-x741.google.com with SMTP id n132so18286836qke.1 for ; Mon, 23 Nov 2020 12:09:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=8Hq2wwl8KrlV94eaiQ+/wCr3qLRV8KmQzSAeoZGdKCg=; b=rbN7VgusDY6AoUr6SNXKp7NMiSDBWJpihMuUrUUqD8rn/l3spS8TTI4s3e0fSvnhn7 xvjqPTsZ0m2LLLogBPR4n51nP8LYPYDakDwFXcDsH9PtB43WomwRa3FPfy9By0lsmWqI iAaNUnqbjv/iL+y4yvTl9m7D/wuoy/lHokKWULAOQfqtKkO2VmqpQxJL14WMQcwHcJ+W Vg4EuXuck03Eqj+6c9yxq7Hv8OEaQQgCWZvgUMqXicUr7oVEUtzPnmxJMHSfj65J02nI axQpcqjtMUNPBcpx8HYJTf9YSkm+ugXqY65nr/Faxj5usTA73rYA2nKCcooGgzItv/eg kmiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=8Hq2wwl8KrlV94eaiQ+/wCr3qLRV8KmQzSAeoZGdKCg=; b=kp19CwpNurlLzMnCWAmceHIeG9WbotOft+q1zaKM50IKocf5jce69D6yzr2GCrwpAO lFCQho8sPFlDFbpMCxfCR5i/rdaCPpvKw5MfnT60FX3huEc9Epqr7+/PljAJon030NTg SGuU4fz48sQiNkBc+vyi76Vn9Xb294hVwBK0n0h+J9deRtyxoEIN/OPey7I6gX8xSftT REEOwm/mlKThY6HTtOrcPvkEtYkc2a2/2FzcGxC8q+0mzt3gGRfrD2FRHlCWrItRxKgC zMzNZks6hT/Sg+j1MXU7lISRA1XdI3BJ/qEcBAQ0grfiK/kUHcpCdOnR8+IVSkM/Uzli 6JrQ== X-Gm-Message-State: AOAM532mMYZ1JI85it8jxZHy0pyNHsm5idHXJhLST5luVW7QcctI9xU/ MaP3/Z877Hx4Gb8od4ttfvzWRxhhj7s= X-Google-Smtp-Source: ABdhPJyFeM8R8CUvOgn4Q+cwBjJyHzH69ztw6Tm5g8T3r/BMsbrwkXtgaUE64lkerycTknVn5bI0Xg== X-Received: by 2002:a37:358:: with SMTP id 85mr1176297qkd.303.1606162140717; Mon, 23 Nov 2020 12:09:00 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id e4sm7956328qtc.54.2020.11.23.12.08.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:09:00 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK8x1Y010447 for ; Mon, 23 Nov 2020 20:08:59 GMT Subject: [PATCH v3 57/85] NFSD: Add a separate decoder for ssv_sp_parms From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:08:59 -0500 Message-ID: <160616213922.51996.16126304189462578034.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Refactor for clarity. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 70 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 26 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 165591c435bc..86147f53f5e7 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1488,12 +1488,54 @@ nfsd4_decode_state_protect_ops(struct nfsd4_compoundargs *argp, return nfs_ok; } +/* + * This implementation currently does not support SP4_SSV. + * This decoder simply skips over these arguments. + */ +static noinline __be32 +nfsd4_decode_ssv_sp_parms(struct nfsd4_compoundargs *argp, + struct nfsd4_exchange_id *exid) +{ + u32 count, window, num_gss_handles; + __be32 status; + + /* ssp_ops */ + status = nfsd4_decode_state_protect_ops(argp, exid); + if (status) + return status; + + /* ssp_hash_algs<> */ + if (xdr_stream_decode_u32(argp->xdr, &count) < 0) + return nfserr_bad_xdr; + while (count--) { + status = nfsd4_decode_ignored_string(argp, 0); + if (status) + return status; + } + + /* ssp_encr_algs<> */ + if (xdr_stream_decode_u32(argp->xdr, &count) < 0) + return nfserr_bad_xdr; + while (count--) { + status = nfsd4_decode_ignored_string(argp, 0); + if (status) + return status; + } + + if (xdr_stream_decode_u32(argp->xdr, &window) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &num_gss_handles) < 0) + return nfserr_bad_xdr; + + return nfs_ok; +} + static __be32 nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, struct nfsd4_exchange_id *exid) { - int dummy, tmp; DECODE_HEAD; + int dummy; READ_BUF(NFS4_VERIFIER_SIZE); COPYMEM(exid->verifier.data, NFS4_VERIFIER_SIZE); @@ -1517,33 +1559,9 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, return status; break; case SP4_SSV: - /* ssp_ops */ - status = nfsd4_decode_state_protect_ops(argp, exid); + status = nfsd4_decode_ssv_sp_parms(argp, exid); if (status) return status; - - /* ssp_hash_algs<> */ - READ_BUF(4); - tmp = be32_to_cpup(p++); - while (tmp--) { - READ_BUF(4); - dummy = be32_to_cpup(p++); - READ_BUF(dummy); - p += XDR_QUADLEN(dummy); - } - - /* ssp_encr_algs<> */ - READ_BUF(4); - tmp = be32_to_cpup(p++); - while (tmp--) { - READ_BUF(4); - dummy = be32_to_cpup(p++); - READ_BUF(dummy); - p += XDR_QUADLEN(dummy); - } - - /* ignore ssp_window and ssp_num_gss_handles: */ - READ_BUF(8); break; default: goto xdr_error; From patchwork Mon Nov 23 20:09:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926327 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FC3AC63777 for ; Mon, 23 Nov 2020 20:10:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D207F21D81 for ; Mon, 23 Nov 2020 20:10:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="I4V3aSFc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730917AbgKWUJI (ORCPT ); Mon, 23 Nov 2020 15:09:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728449AbgKWUJI (ORCPT ); Mon, 23 Nov 2020 15:09:08 -0500 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07F7CC0613CF for ; Mon, 23 Nov 2020 12:09:07 -0800 (PST) Received: by mail-qt1-x841.google.com with SMTP id f93so14320808qtb.10 for ; Mon, 23 Nov 2020 12:09:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=GpTokXGaANHYCBj89Ram3lgk4u3OFzBS+0QdJdDIbvc=; b=I4V3aSFcTIfOYL2QoXnpKoHs8JOr37Fzo1h6T3/s4Bk12p7QGe89F81SLl79qVohzx WYGI/eTkulIaB59Swhkd/CzTRicuJ2yDhbsohg1NPDCPUmRYODtIZckorQazSYv42ITj K4HYEahDMOkaIVAM9iwpvxrzpW/vHdWfgwxLyZQV5TsyGOrZmMRCGEhM5wF5Js9R7eVa AWJChh00B1PHRCa1Qgaa1pMRzEyv/UwtL1GOesWhThh8b+iCqevAzdBX0y14lKuWs2VR sB6Pp2T3WMk4Sng9N10s+xdKyNiVwEYOxjGW7liZlE5q41TH8kcB+AAas0GduT+NkozP jPpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=GpTokXGaANHYCBj89Ram3lgk4u3OFzBS+0QdJdDIbvc=; b=klS827eeF80bJkAL+A/b7XX/8RfLWenKmrq1bRHLaAiZip6XvYlz1hsN6IsRKt5cnU EmywuEYCy62t6UQmXKb2zCQirE5pzl51WAm3eGvr3qcC9dwqAHk8pT2phwn105+Df22h ql5v2pslLzkNIhiBA9dr294Ge1fKcqhn7CxbFchX9LM6F9Vbk8gUl1oOsQVdL+Hi4+Sc HWjqSH695A3No1IteQHlNWvS8Wj8UZ8H/3IjHW9KrRHV0EJmO3hnsXBd8+bx1oTkQVp0 92iuUKLRlhfjDQ4AyMHwUXBCF4klzytlsgexK1Y2TC0k20p+buqvrMnzD9KMyeIDN5u/ aTMQ== X-Gm-Message-State: AOAM530agxAfAbXo7n0Oh0R551JZLb/Rgtnk001NnEg0uwOI466Z8/F2 +CXR0/4Ma5LhDTnoAu2Jhh3mI+NXTc8= X-Google-Smtp-Source: ABdhPJyRHSxNgzMfwCtXYLZKF/4Ee8MKbmK2ufb4s0flLB0OiF1llmiJ9peH/QKEB+KAdc6AYwC+fA== X-Received: by 2002:ac8:5304:: with SMTP id t4mr891674qtn.77.1606162145906; Mon, 23 Nov 2020 12:09:05 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id p65sm10083280qkb.92.2020.11.23.12.09.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:09:05 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK94MS010450 for ; Mon, 23 Nov 2020 20:09:04 GMT Subject: [PATCH v3 58/85] NFSD: Add a helper to decode state_protect4_a From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:09:04 -0500 Message-ID: <160616214430.51996.12356284605153624353.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Refactor for clarity. Also, remove a stale comment. Commit ed94164398c9 ("nfsd: implement machine credential support for some operations") added support for SP4_MACH_CRED, so state_protect_a is no longer completely ignored. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4state.c | 2 +- fs/nfsd/nfs4xdr.c | 44 +++++++++++++++++++++++++++----------------- fs/nfsd/xdr4.h | 2 +- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index d7f27ed6b794..be6dcc4c2ab0 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3066,7 +3066,7 @@ nfsd4_exchange_id(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, rpc_ntop(sa, addr_str, sizeof(addr_str)); dprintk("%s rqstp=%p exid=%p clname.len=%u clname.data=%p " - "ip_addr=%s flags %x, spa_how %d\n", + "ip_addr=%s flags %x, spa_how %u\n", __func__, rqstp, exid, exid->clname.len, exid->clname.data, addr_str, exid->flags, exid->spa_how); diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 86147f53f5e7..ecae29ba9bb7 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1531,25 +1531,13 @@ nfsd4_decode_ssv_sp_parms(struct nfsd4_compoundargs *argp, } static __be32 -nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, - struct nfsd4_exchange_id *exid) +nfsd4_decode_state_protect4_a(struct nfsd4_compoundargs *argp, + struct nfsd4_exchange_id *exid) { - DECODE_HEAD; - int dummy; - - READ_BUF(NFS4_VERIFIER_SIZE); - COPYMEM(exid->verifier.data, NFS4_VERIFIER_SIZE); + __be32 status; - status = nfsd4_decode_opaque(argp, &exid->clname); - if (status) + if (xdr_stream_decode_u32(argp->xdr, &exid->spa_how) < 0) return nfserr_bad_xdr; - - READ_BUF(4); - exid->flags = be32_to_cpup(p++); - - /* Ignore state_protect4_a */ - READ_BUF(4); - exid->spa_how = be32_to_cpup(p++); switch (exid->spa_how) { case SP4_NONE: break; @@ -1564,9 +1552,31 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, return status; break; default: - goto xdr_error; + return nfserr_bad_xdr; } + return nfs_ok; +} + +static __be32 +nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, + struct nfsd4_exchange_id *exid) +{ + DECODE_HEAD; + int dummy; + + status = nfsd4_decode_verifier4(argp, &exid->verifier); + if (status) + return status; + status = nfsd4_decode_opaque(argp, &exid->clname); + if (status) + return status; + if (xdr_stream_decode_u32(argp->xdr, &exid->flags) < 0) + return nfserr_bad_xdr; + status = nfsd4_decode_state_protect4_a(argp, exid); + if (status) + return status; + READ_BUF(4); /* nfs_impl_id4 array length */ dummy = be32_to_cpup(p++); diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 6245004a9993..232529bc1b79 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -433,7 +433,7 @@ struct nfsd4_exchange_id { u32 flags; clientid_t clientid; u32 seqid; - int spa_how; + u32 spa_how; u32 spo_must_enforce[3]; u32 spo_must_allow[3]; struct xdr_netobj nii_domain; From patchwork Mon Nov 23 20:09:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926329 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDD5DC63798 for ; Mon, 23 Nov 2020 20:10:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 919FE20731 for ; Mon, 23 Nov 2020 20:10:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V5heRJj2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728623AbgKWUJO (ORCPT ); Mon, 23 Nov 2020 15:09:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731053AbgKWUJM (ORCPT ); Mon, 23 Nov 2020 15:09:12 -0500 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 584B9C0613CF for ; Mon, 23 Nov 2020 12:09:12 -0800 (PST) Received: by mail-qv1-xf41.google.com with SMTP id ek7so9451237qvb.6 for ; Mon, 23 Nov 2020 12:09:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=KtglniT35niCajf4434oeyizSzqWor46WMmpz88zeFo=; b=V5heRJj28IG8Oh3AmogSIl5yWmHnoUxtr2wuLe96IK3ZLtOsdcIKss62NbhsIKYmZN 3SWBogLyMtLPYfR5a8isOsUPlnwAYEeVWY35dlyyorvwPhdyNuM5+Qhvz/uom+Ahzw7H Mz7AArWeHvOvJ9IJjzuCKnaLXvyy55qZyjl19dYpOiENTerkqzAzE2scoClpqo0kRa8A T9N6GU7COLkYQNcSzTyI2HwW2HmRRLlvYtkU+tKcxLRc4bh0EfcICKCIYCswph5+sCnT bpGpi4Fisef6jJ8HO3aEgTJ9yGjH1ytKJe8hE72yquZlKlPJb4dTTNAgl4Kwit58hoiM FrMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=KtglniT35niCajf4434oeyizSzqWor46WMmpz88zeFo=; b=homT9rCbjqQ0Wbai5dRSHPQAXiLgX15lc6ky5lvUk33dkntHF5GeMqbXx8okQaY2lT LoZcyYP5spGr9+Pz9OmGeyFKe0HdytkogPZRUdPwEM0cpZTmNlJakZROdpnviGYbunYy KnI9qPGIaPFKa/Kbxz44jinkqUYQEeQrWwQvzHpFkz8AMCJ2ZZEgOR4+TD7ukVpvgw+9 9mmxscZPsshvIT3syna9rfLqs9InvX4ddrTfzpW6W/OhvwuLS+53L+XOx46fFgpE3q2a Y8awNbn4cOU5WOKfbAEc3IMyivYzqZPNdvOJ36R7hxFWUtKfLzcOlctDOBLFB2UHlRq2 MNog== X-Gm-Message-State: AOAM530F3BwevL+1Ii9Ofk045uqhrN/AVBNGzprOn5Ps/dEMErsTiCcV L25pxYiwsbm7dgxbRsMWVSVSJLGs3eY= X-Google-Smtp-Source: ABdhPJxW0ajluUazkGWdlvCgtdww0tu8kZuqqlwskeO9fVucXVkFneUSUsMsiYUtX0JkU5q2zXNZ5A== X-Received: by 2002:a05:6214:504:: with SMTP id v4mr1132259qvw.38.1606162151315; Mon, 23 Nov 2020 12:09:11 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id x124sm6514096qkc.25.2020.11.23.12.09.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:09:10 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK99Rd010453 for ; Mon, 23 Nov 2020 20:09:09 GMT Subject: [PATCH v3 59/85] NFSD: Add a helper to decode nfs_impl_id4 From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:09:09 -0500 Message-ID: <160616214959.51996.11303465966055146170.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Refactor for clarity. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 63 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index ecae29ba9bb7..c74aa6203989 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1558,12 +1558,47 @@ nfsd4_decode_state_protect4_a(struct nfsd4_compoundargs *argp, return nfs_ok; } +static __be32 +nfsd4_decode_nfs_impl_id4(struct nfsd4_compoundargs *argp, + struct nfsd4_exchange_id *exid) +{ + __be32 status; + u32 count; + + if (xdr_stream_decode_u32(argp->xdr, &count) < 0) + return nfserr_bad_xdr; + switch (count) { + case 0: + break; + case 1: + /* Note that RFC 8881 places no length limit on + * nii_domain, but this implementation permits no + * more than NFS4_OPAQUE_LIMIT bytes */ + status = nfsd4_decode_opaque(argp, &exid->nii_domain); + if (status) + return status; + /* Note that RFC 8881 places no length limit on + * nii_name, but this implementation permits no + * more than NFS4_OPAQUE_LIMIT bytes */ + status = nfsd4_decode_opaque(argp, &exid->nii_name); + if (status) + return status; + status = nfsd4_decode_nfstime4(argp, &exid->nii_time); + if (status) + return status; + break; + default: + return nfserr_bad_xdr; + } + + return nfs_ok; +} + static __be32 nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, struct nfsd4_exchange_id *exid) { - DECODE_HEAD; - int dummy; + __be32 status; status = nfsd4_decode_verifier4(argp, &exid->verifier); if (status) @@ -1576,29 +1611,7 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, status = nfsd4_decode_state_protect4_a(argp, exid); if (status) return status; - - READ_BUF(4); /* nfs_impl_id4 array length */ - dummy = be32_to_cpup(p++); - - if (dummy > 1) - goto xdr_error; - - if (dummy == 1) { - status = nfsd4_decode_opaque(argp, &exid->nii_domain); - if (status) - goto xdr_error; - - /* nii_name */ - status = nfsd4_decode_opaque(argp, &exid->nii_name); - if (status) - goto xdr_error; - - /* nii_date */ - status = nfsd4_decode_time(argp, &exid->nii_time); - if (status) - goto xdr_error; - } - DECODE_TAIL; + return nfsd4_decode_nfs_impl_id4(argp, exid); } static __be32 From patchwork Mon Nov 23 20:09:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7CE13C64E75 for ; Mon, 23 Nov 2020 20:10:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 253ED20717 for ; Mon, 23 Nov 2020 20:10:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rqCghze4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728635AbgKWUJT (ORCPT ); Mon, 23 Nov 2020 15:09:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731157AbgKWUJR (ORCPT ); Mon, 23 Nov 2020 15:09:17 -0500 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DA7FC0613CF for ; Mon, 23 Nov 2020 12:09:17 -0800 (PST) Received: by mail-qt1-x841.google.com with SMTP id z3so14343334qtw.9 for ; Mon, 23 Nov 2020 12:09:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=bgtRqKg843ZWylFn2dEPW9Le7aPHCKY8iBa7h0ejojQ=; b=rqCghze4+2/SAvx5qO1WvqnS006dhmgXmrxxuOypKlwe68jAB0RZ2pIQLaUWRxyxkT LN9hwe0eu+ZtwI98K4hp0vvLH5UYTgI48G0lEhpQwZNRPi8BG3gAZ4WRlI5TP8JEp35z T8wqIm+WxVphhL7v1iqpM8/752TW3LZBx/YKirNRnLdrwUry3trQSVXxEtmKWRz6foln KYGIu6ZyjB6CqYTxxqVBWbrL7JjwQk2h/H6mTjsPwmnKjmVJs4sJ3cV2vPdvwHKS1K7h nc5mv/FYh4JYdmBbLlR1ZpSb8NjDBTnlowallJB2ZwyNWLy9FajPJdnQ3hXGRW6hekxk L46A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=bgtRqKg843ZWylFn2dEPW9Le7aPHCKY8iBa7h0ejojQ=; b=JK++ZMszMVRZxHPpWsn8uJK9yPQKfPUOnueBf6nMywPOtSzw0J3ASzqkvZ8XHYVwg9 rh8NmOfe5muFA8BUqfYV1f0wjYU6+IqinLAotyjx6TPm3nQCh3JqzSmFXlKtk8NxfW9s pQHFnEHA6zharuHFrLwrExF+Y1Gg9H8j47/hWtlzaZi263nzVUGoupZT09WU/3JFzaup ghrOv0+ban6SG0zfkM96plYXhMjVQL5P5lv1zBYyjBmMhq/J9B5IPxBGoUnLH4MhZKIv RS0N5HtG0KL4zgiW430cJPg6ySyIdskzDO7eqiMpOU/t4EnWanAav8fOYXePjRJVJMwq O8TA== X-Gm-Message-State: AOAM530xFr7yVl87BwQ1RSnPTG9dOsYi4tudKJGW/Arf0gTnTig/Qd1Z okhhqkhfTCTXebWN3DL4yAhBHqoWtUc= X-Google-Smtp-Source: ABdhPJyO4Sfbh22TkIhaLZazHeeOZWPf8CmYFQjpwnq+Xz02OG0lrHFzQyZ2FMGSWohUjFw99lKU5Q== X-Received: by 2002:ac8:7551:: with SMTP id b17mr923388qtr.35.1606162156465; Mon, 23 Nov 2020 12:09:16 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id n9sm5512484qti.75.2020.11.23.12.09.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:09:15 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK9Ew3010456 for ; Mon, 23 Nov 2020 20:09:14 GMT Subject: [PATCH v3 60/85] NFSD: Add a helper to decode channel_attrs4 From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:09:14 -0500 Message-ID: <160616215488.51996.10296408285780429558.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org De-duplicate some code. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 71 ++++++++++++++++++++++++++++------------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index c74aa6203989..06de62f8185c 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1614,6 +1614,38 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp, return nfsd4_decode_nfs_impl_id4(argp, exid); } +static __be32 +nfsd4_decode_channel_attrs4(struct nfsd4_compoundargs *argp, + struct nfsd4_channel_attrs *ca) +{ + __be32 *p; + + p = xdr_inline_decode(argp->xdr, XDR_UNIT * 7); + if (!p) + return nfserr_bad_xdr; + + /* headerpadsz is ignored */ + p++; + ca->maxreq_sz = be32_to_cpup(p++); + ca->maxresp_sz = be32_to_cpup(p++); + ca->maxresp_cached = be32_to_cpup(p++); + ca->maxops = be32_to_cpup(p++); + ca->maxreqs = be32_to_cpup(p++); + ca->nr_rdma_attrs = be32_to_cpup(p); + switch (ca->nr_rdma_attrs) { + case 0: + break; + case 1: + if (xdr_stream_decode_u32(argp->xdr, &ca->rdma_attrs) < 0) + return nfserr_bad_xdr; + break; + default: + return nfserr_bad_xdr; + } + + return nfs_ok; +} + static __be32 nfsd4_decode_create_session(struct nfsd4_compoundargs *argp, struct nfsd4_create_session *sess) @@ -1625,39 +1657,12 @@ nfsd4_decode_create_session(struct nfsd4_compoundargs *argp, sess->seqid = be32_to_cpup(p++); sess->flags = be32_to_cpup(p++); - /* Fore channel attrs */ - READ_BUF(28); - p++; /* headerpadsz is always 0 */ - sess->fore_channel.maxreq_sz = be32_to_cpup(p++); - sess->fore_channel.maxresp_sz = be32_to_cpup(p++); - sess->fore_channel.maxresp_cached = be32_to_cpup(p++); - sess->fore_channel.maxops = be32_to_cpup(p++); - sess->fore_channel.maxreqs = be32_to_cpup(p++); - sess->fore_channel.nr_rdma_attrs = be32_to_cpup(p++); - if (sess->fore_channel.nr_rdma_attrs == 1) { - READ_BUF(4); - sess->fore_channel.rdma_attrs = be32_to_cpup(p++); - } else if (sess->fore_channel.nr_rdma_attrs > 1) { - dprintk("Too many fore channel attr bitmaps!\n"); - goto xdr_error; - } - - /* Back channel attrs */ - READ_BUF(28); - p++; /* headerpadsz is always 0 */ - sess->back_channel.maxreq_sz = be32_to_cpup(p++); - sess->back_channel.maxresp_sz = be32_to_cpup(p++); - sess->back_channel.maxresp_cached = be32_to_cpup(p++); - sess->back_channel.maxops = be32_to_cpup(p++); - sess->back_channel.maxreqs = be32_to_cpup(p++); - sess->back_channel.nr_rdma_attrs = be32_to_cpup(p++); - if (sess->back_channel.nr_rdma_attrs == 1) { - READ_BUF(4); - sess->back_channel.rdma_attrs = be32_to_cpup(p++); - } else if (sess->back_channel.nr_rdma_attrs > 1) { - dprintk("Too many back channel attr bitmaps!\n"); - goto xdr_error; - } + status = nfsd4_decode_channel_attrs4(argp, &sess->fore_channel); + if (status) + return status; + status = nfsd4_decode_channel_attrs4(argp, &sess->back_channel); + if (status) + return status; READ_BUF(4); sess->callback_prog = be32_to_cpup(p++); From patchwork Mon Nov 23 20:09:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30EFEC64E7D for ; Mon, 23 Nov 2020 20:10:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C39BD20731 for ; Mon, 23 Nov 2020 20:10:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="t5Tu8XMC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731261AbgKWUJY (ORCPT ); Mon, 23 Nov 2020 15:09:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731218AbgKWUJX (ORCPT ); Mon, 23 Nov 2020 15:09:23 -0500 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F196C0613CF for ; Mon, 23 Nov 2020 12:09:23 -0800 (PST) Received: by mail-qt1-x841.google.com with SMTP id f27so4800151qtv.6 for ; Mon, 23 Nov 2020 12:09:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=vY14K9HjPNANhQMuRDefDP0SeKwcKICSeZuiBq4P6rM=; b=t5Tu8XMClEmuSgDpcYZo3QoWWBrohUx4lmXVdyEAPMI237ZOwXG/EYTpBqpFbQICPa ATaIT/lQAOTh/ogfg5br80e62J6ABvwJEbZjxXLGQQFQKxlV8TVGr5fh3i5z3URVBto4 P1/cj+3EFpSTxaHu6NE0ELKNGmmRTkb0k7E6ZU9pXXY1q/uhSL7oMAJux6B2hacsaqZZ 0yet93TqiS4Cgr/YlJQeY0lLiQhhQVpe1hdlWffQfoUgJWfQwlNGDVDVS+qNZicPS2sS X9jaaMc5V7V+2qFtVvMEBf4LbXq4Gx8YtLznz1DYqzK1een6ol7CbGlLYoa+0P2ZbUto vnAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=vY14K9HjPNANhQMuRDefDP0SeKwcKICSeZuiBq4P6rM=; b=GwAZJMoc5HSuZwsQyn8B1d+3pISO2+3EwwbbeEuguNajRy67FjdtfWUukmfmQ32jX1 0zh7i4MEorbcNSAjGOIcaVZREZpL5rMzEMxMN/BBP2ukVQfFJ1vCFmuCdrd+4XtL1+hv OtjLs23/4gNxr2/fB9qkE4ZTPB2OfeEnyjlLMsuFAZHvUjrRnfiV4c9nebipdAo5orY8 jRwrSM6ckjB5bq7TS7fatFhxR4bFaeKg8aU+rVkZhP7xCy8zwMnmvGFd+VVFlnpLqXSg JpCjOjurb5ZZ2WmodgWyWNi4R5/Wpe9oZokJOt+f4ON4Fat2a3rWJDJDA9AU/zoB1+ja HYfQ== X-Gm-Message-State: AOAM533uKVjPskfcAOFlwopA9+ih1ghH0E0NvNZUMGmv8qGcWKVBfWmi Xr0YQM2/eV3qryymYyln5gNQjW9fUD4= X-Google-Smtp-Source: ABdhPJyoctxYieTeMYAOq+rYeFEgjYLduGocIwNmEhOLPyC2EqnA1wicMkxUFWM5IlXDT5N/hHrHYA== X-Received: by 2002:ac8:59c3:: with SMTP id f3mr876389qtf.214.1606162162139; Mon, 23 Nov 2020 12:09:22 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id t63sm9764470qka.128.2020.11.23.12.09.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:09:21 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK9KDD010459 for ; Mon, 23 Nov 2020 20:09:20 GMT Subject: [PATCH v3 61/85] NFSD: Replace READ* macros in nfsd4_decode_create_session() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:09:20 -0500 Message-ID: <160616216016.51996.46404110576435704.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 06de62f8185c..3904ebe8077a 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1650,24 +1650,28 @@ static __be32 nfsd4_decode_create_session(struct nfsd4_compoundargs *argp, struct nfsd4_create_session *sess) { - DECODE_HEAD; - - READ_BUF(16); - COPYMEM(&sess->clientid, 8); - sess->seqid = be32_to_cpup(p++); - sess->flags = be32_to_cpup(p++); + __be32 status; + status = nfsd4_decode_clientid4(argp, &sess->clientid); + if (status) + return status; + if (xdr_stream_decode_u32(argp->xdr, &sess->seqid) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &sess->flags) < 0) + return nfserr_bad_xdr; status = nfsd4_decode_channel_attrs4(argp, &sess->fore_channel); if (status) return status; status = nfsd4_decode_channel_attrs4(argp, &sess->back_channel); + if (status) + return status; + if (xdr_stream_decode_u32(argp->xdr, &sess->callback_prog) < 0) + return nfserr_bad_xdr; + status = nfsd4_decode_cb_sec(argp, &sess->cb_sec); if (status) return status; - READ_BUF(4); - sess->callback_prog = be32_to_cpup(p++); - nfsd4_decode_cb_sec(argp, &sess->cb_sec); - DECODE_TAIL; + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:09:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62F76C63697 for ; Mon, 23 Nov 2020 20:10:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05A1A20717 for ; Mon, 23 Nov 2020 20:10:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YQoyacK8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731345AbgKWUJ2 (ORCPT ); Mon, 23 Nov 2020 15:09:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731324AbgKWUJ2 (ORCPT ); Mon, 23 Nov 2020 15:09:28 -0500 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24348C0613CF for ; Mon, 23 Nov 2020 12:09:28 -0800 (PST) Received: by mail-qt1-x844.google.com with SMTP id v11so14309501qtq.12 for ; Mon, 23 Nov 2020 12:09:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=yFFiqdVem/MPdj2HWBmk9d9Vu0BBzkHLvrLzApWI0ZY=; b=YQoyacK8pGNqRImQpFL+oN4cWVzGqm7A8KzaMn/Yl5PfIRYZIAcgeo55Kxs1QMWGHK g5m9GICwnU+GPZCd47JTfvYx/tuftffEyaHopi1yOvvO+k9cVqAlIRCdMy8KMaF2uozp WP1cMcti0it3RoVdCmiYKMT2qLqYY1zp6sJ1w5Vwj8g0IQlpExITfdB3ErmHu5u4EOHV LUtd3SnKf7mZcxB3fvTfN20tAPvvU6ecCBok1ZCNeHqmdIYZiShHFXRBhFnq1h2ZctKX 0tWXNzwax2iOYx8MNH4sUxtEue0xrBf5gecNslcDadV9VcAnbqG+If3HDGSDzLnu/FsF AzDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=yFFiqdVem/MPdj2HWBmk9d9Vu0BBzkHLvrLzApWI0ZY=; b=q8rAke7GkWym6gkxOncwJvBPrONr6Jaa4ENDytz6wtyFiPR+bxaSrYNewYUAqX3Z7W mKiOl8vW564ud6SB803Xk5AmJ609gw55onKy0DLHzmRQYV1+7/CHYFuvgqAYKltMxZjd h/te47VZG7UgZxpnQxjOYBFzcibNGHbyhADPp1ndub3vmqxHGPdps+Z5CDmaAjComuqj TMgvLTddY3U1VWnqZYFk9X3hMNp3Kx+kWqIX3ke/EcrbV4PMW9PGCIfCltwnpbfeXXOI VYv6bJX79jC1zAE+CTtyU3cFXVwbt76tst0MP/98QI6gMXNrq1zSBPYLAL2jYfnGjwDB Hhcw== X-Gm-Message-State: AOAM532hR+zTyXwO3n0NwkZ+LS8twR4/2kqxm1ycuDcg+MkXcgG4h/LH Z5DsYNj+W4DCExpj8JKmO3HEe3f9FWI= X-Google-Smtp-Source: ABdhPJxn3Q+hybhcmV1OLmFqQ+iZcBmJtDY0q6QAmtxzDtGgrslN4Ek/F6W5CEoGafxI6CE8cuhv2Q== X-Received: by 2002:ac8:5b82:: with SMTP id a2mr917849qta.178.1606162167116; Mon, 23 Nov 2020 12:09:27 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id b25sm10244632qto.17.2020.11.23.12.09.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:09:26 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK9PHg010462 for ; Mon, 23 Nov 2020 20:09:25 GMT Subject: [PATCH v3 62/85] NFSD: Replace READ* macros in nfsd4_decode_destroy_session() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:09:25 -0500 Message-ID: <160616216545.51996.14350695803519628936.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 3904ebe8077a..bde832994be4 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1678,11 +1678,7 @@ static __be32 nfsd4_decode_destroy_session(struct nfsd4_compoundargs *argp, struct nfsd4_destroy_session *destroy_session) { - DECODE_HEAD; - READ_BUF(NFS4_MAX_SESSIONID_LEN); - COPYMEM(destroy_session->sessionid.data, NFS4_MAX_SESSIONID_LEN); - - DECODE_TAIL; + return nfsd4_decode_sessionid4(argp, &destroy_session->sessionid); } static __be32 From patchwork Mon Nov 23 20:09:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926495 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EF5CAC63777 for ; Mon, 23 Nov 2020 20:13:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B0F2020657 for ; Mon, 23 Nov 2020 20:13:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gOZbPCiC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731353AbgKWUJe (ORCPT ); Mon, 23 Nov 2020 15:09:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731389AbgKWUJd (ORCPT ); Mon, 23 Nov 2020 15:09:33 -0500 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AAA7C0613CF for ; Mon, 23 Nov 2020 12:09:33 -0800 (PST) Received: by mail-qt1-x843.google.com with SMTP id e10so6898245qte.4 for ; Mon, 23 Nov 2020 12:09:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=U87VMX6PWpNDIh5Rr5x8DdmKsUeOe3Wv2RQH43fVpmo=; b=gOZbPCiCb81ZJF6O5YbmLbgTaiHpQkzeFnLxZklG/bDbaVcuWbfaFn089LW7iRyyhh EHhzEHl5h2QOTIw41LeH8azqvBliVizaCmzQJCW3b/VnHn3xJmzNfKuK6sfR7Xba2plq VfghwhpMAOQHTyanFgLm+FsXSrOTmqjsZCc8DoNEXM7dT2jGI43nPD57s6fwyPuJirDX ymB3NyWdWCqCupZ+OzDqI1RAkXYehSshBhITiP/JXTOgUEdeIxQqyhC4MNh2kAc6iZ8s lksCkkEy+Kgo3Nl5e5r5V8Q/gfuc1XxkX26GpQ9n9WaSPI0s1oLrpPDiZ0H8JTtlKV8m 9MkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=U87VMX6PWpNDIh5Rr5x8DdmKsUeOe3Wv2RQH43fVpmo=; b=Tu9RmNUl/VgtoXkHt3bm9OrKGMpr6oNinHm4YgRZqZe7gJQB5fXD5dVcstqc2VJ+uq bFNWlW6oMzrKN0N31+4tIJEHOLZVQrl3IhZ1jNs9bG+p8OyQKrK3uEhA76t21MDGLvWw 8xhqhw6wWfnI3ZKckEcKRne/+JW6PN1+WSeRilTqXBxqMDVktSHyeJQY+G75O0puHpfz MrSHL4yIyCobVKvrVEEvmbKn2aZYEDTUdVHxllhEYN2hB7nD9fd/nDRNyE+Y6xBPg6Zg /tCVd2z2RePlfnRAleJ91pBYA7V0Pts2ekh9+Hlegc+odj7o3gR010dh1BhLyljvR42k Id4g== X-Gm-Message-State: AOAM5324RQOvqBP3HxzfJv8LZGZGDJlR1qX0oRufIq5rdURFbfP+PPY5 0PMtgdUVbQ0VZerT7nlHsivrTXO5+Lg= X-Google-Smtp-Source: ABdhPJzm9dTE6qQYFmOfhmt/WWREMPGZ2Szd/cpz51xYs2xG/nkw5GVoxndN+F2dvhHN2IvnGIZTSQ== X-Received: by 2002:ac8:6ec5:: with SMTP id f5mr939434qtv.56.1606162172383; Mon, 23 Nov 2020 12:09:32 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id r14sm10494889qtu.25.2020.11.23.12.09.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:09:31 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK9UA3010465 for ; Mon, 23 Nov 2020 20:09:30 GMT Subject: [PATCH v3 63/85] NFSD: Replace READ* macros in nfsd4_decode_free_stateid() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:09:30 -0500 Message-ID: <160616217073.51996.17726050216615997950.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index bde832994be4..b326d5b4e7f8 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1685,13 +1685,7 @@ static __be32 nfsd4_decode_free_stateid(struct nfsd4_compoundargs *argp, struct nfsd4_free_stateid *free_stateid) { - DECODE_HEAD; - - READ_BUF(sizeof(stateid_t)); - free_stateid->fr_stateid.si_generation = be32_to_cpup(p++); - COPYMEM(&free_stateid->fr_stateid.si_opaque, sizeof(stateid_opaque_t)); - - DECODE_TAIL; + return nfsd4_decode_stateid4(argp, &free_stateid->fr_stateid); } static __be32 From patchwork Mon Nov 23 20:09:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926491 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27E0CC8300B for ; Mon, 23 Nov 2020 20:12:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD1B820717 for ; Mon, 23 Nov 2020 20:12:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ECy+KWe+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731533AbgKWUJm (ORCPT ); Mon, 23 Nov 2020 15:09:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731503AbgKWUJk (ORCPT ); Mon, 23 Nov 2020 15:09:40 -0500 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA5ADC061A4D for ; Mon, 23 Nov 2020 12:09:38 -0800 (PST) Received: by mail-qt1-x842.google.com with SMTP id 7so14386133qtp.1 for ; Mon, 23 Nov 2020 12:09:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=WmiWZz556S6KIjcRVh9fmQMJChbZre2LBivK0xf7HW4=; b=ECy+KWe+N5CN8ZqEJFRt2No5XPG0mubGO/wLuq8eq/KuLBZRSSlZIm9zzzskkUsie1 KcFfVQRyqXKABb/hwYyDYPT2UTRFtXbTyxq2bivGqpgcQEg5HRlVqTUqU0k1lGlQk9a5 EFcbonn2UYoNdqb7EVY8Qh8mX33ERyDBVuz4J2yBaLZWHuEhyyiurQ9rRN5qUbRCEovm U2Jk3JFte1kKmlwUvRM9pWyCzVdndGtS49G5GqpZevOiBRNbU1C/aQp8voIfEFOQ9TvD FYmMLKVWKIA1+K8lbsiYYOo1sr/jK8P6wuK8pfMRrE2XplaW73vXSJfPMlcXybz2OMCh ndLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=WmiWZz556S6KIjcRVh9fmQMJChbZre2LBivK0xf7HW4=; b=N0ZWexR1rIMIPnqIMz51Mhq+BGYUQbQNqqWyRlczICiPHPiQKImiJBseROtX7AiNAX WB4MJ3EvItDHMx7egb85PuLKx4BYdfcg7pZdVUykTFBVHzVO9HhuOgDnBCe9VNEyvpVH CKHE2rAjFWrjS1EE4r/DhrxVjZqYHs6yRYbSsundmzvpln9ulrRl5ryhEum8cZmSjREI /moxAAr8BfmJtzokJ2PXH3mMyNwEkIXvxW/bfoMvEQo1EgZbzedXQzO218lCRWhC+MKr ei4jtoFP/16PtrAMlhuIhvgidZSEZbbfex+aXb6Q7JbWwqmBcugzFZxIFsbaodH0mcYf MZhA== X-Gm-Message-State: AOAM530vLYsBe1scoSokxCvRCdIhydXWBy1wFDdpdM9MdzqJ6C0Vr/fh qtMmOhstxSbp7ho5UnsevAAIOTTMzls= X-Google-Smtp-Source: ABdhPJwlcnldg488MxeKbjaSSM5rM2mbemkjFQBhjcUW+CM0OmgNGenFb1FHsQPS2Y9DqiiIHJ5Fqw== X-Received: by 2002:aed:22c5:: with SMTP id q5mr873500qtc.247.1606162177625; Mon, 23 Nov 2020 12:09:37 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id t2sm5475234qtr.24.2020.11.23.12.09.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:09:37 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK9aIM010468 for ; Mon, 23 Nov 2020 20:09:36 GMT Subject: [PATCH v3 64/85] NFSD: Replace READ* macros in nfsd4_decode_getdeviceinfo() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:09:36 -0500 Message-ID: <160616217602.51996.12946553675831247424.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index b326d5b4e7f8..4be809f00eb1 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -638,6 +638,21 @@ nfsd4_decode_state_owner4(struct nfsd4_compoundargs *argp, return nfsd4_decode_opaque(argp, owner); } +#ifdef CONFIG_NFSD_PNFS +static __be32 +nfsd4_decode_deviceid4(struct nfsd4_compoundargs *argp, + struct nfsd4_deviceid *devid) +{ + __be32 *p; + + p = xdr_inline_decode(argp->xdr, NFS4_DEVICEID4_SIZE); + if (!p) + return nfserr_bad_xdr; + memcpy(devid, p, sizeof(*devid)); + return nfs_ok; +} +#endif /* CONFIG_NFSD_PNFS */ + static __be32 nfsd4_decode_sessionid4(struct nfsd4_compoundargs *argp, struct nfs4_sessionid *sessionid) @@ -1765,27 +1780,20 @@ static __be32 nfsd4_decode_getdeviceinfo(struct nfsd4_compoundargs *argp, struct nfsd4_getdeviceinfo *gdev) { - DECODE_HEAD; - u32 num, i; - - READ_BUF(sizeof(struct nfsd4_deviceid) + 3 * 4); - COPYMEM(&gdev->gd_devid, sizeof(struct nfsd4_deviceid)); - gdev->gd_layout_type = be32_to_cpup(p++); - gdev->gd_maxcount = be32_to_cpup(p++); - num = be32_to_cpup(p++); - if (num) { - if (num > 1000) - goto xdr_error; - READ_BUF(4 * num); - gdev->gd_notify_types = be32_to_cpup(p++); - for (i = 1; i < num; i++) { - if (be32_to_cpup(p++)) { - status = nfserr_inval; - goto out; - } - } - } - DECODE_TAIL; + __be32 status; + + status = nfsd4_decode_deviceid4(argp, &gdev->gd_devid); + if (status) + return status; + if (xdr_stream_decode_u32(argp->xdr, &gdev->gd_layout_type) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &gdev->gd_maxcount) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_uint32_array(argp->xdr, + &gdev->gd_notify_types, 1) < 0) + return nfserr_bad_xdr; + + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:09:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926339 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43EE5C8300B for ; Mon, 23 Nov 2020 20:10:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E294620717 for ; Mon, 23 Nov 2020 20:10:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PviXerCm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731563AbgKWUJq (ORCPT ); Mon, 23 Nov 2020 15:09:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731541AbgKWUJp (ORCPT ); Mon, 23 Nov 2020 15:09:45 -0500 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13AC7C0613CF for ; Mon, 23 Nov 2020 12:09:44 -0800 (PST) Received: by mail-qk1-x742.google.com with SMTP id l2so18310099qkf.0 for ; Mon, 23 Nov 2020 12:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=dl0ilOvpHBVP4pwo3/beWKpAeJ7AQDc9hRiT/6vt6rQ=; b=PviXerCmGJk3YwbIBWLtUa7e98oQIcyXHR7GFr+GQhrak02oTFohDzdeEffza4p4DM yf73AGHv0qFJ+yJbdgkErI9YcVxTA08jDOxfZChJ0i2ElM5TfvwnzRR69o144UG5Hqwo Xg8A9AHvZi7qxv06bSMzMHYd7Uf14OE4VvcnRtRLctDxXK249ORJJOzk/qIA1tAtV7gs Nzcjk77spgeBffSnp5A1mqc/1FWKCjSS+gI/0b0kpaUah3rJQPNjm7mECSWtwHcshl0A bkSXRc+qtzX4khT2a3kcl+jSoE2ATXFyVgLIC/s3uKeZO4Nn+yXvdgkmQWvsh4Dmhjio VC8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=dl0ilOvpHBVP4pwo3/beWKpAeJ7AQDc9hRiT/6vt6rQ=; b=su93JHDTcyYrb1xIH7ipaqrO02b4bkNVOpirnvrFySsvLjPK+BRE0CrTk3z/29hzak fFqJzqZNdQvQcu/j+ilKK6y6nMOu+dJCB2d8kuA/kyKx8UQtspNojBFYpYoQciI7oozp F+VD9Lw6J7NAU+YladzYSAlBLlP9LULe3nuCBtOp9rqq1qkW9wHuJVJ/ZYJPqLaw2MhK 86ecFyc7ByBoA6Qmr14jULxGGBuc+gtUIjO1Jv7uh+ACBkWL6WtIDodx3AFoNIOfydvc 4MVMWglV2jF3a365HgV2HoiMSPZ6ykYoaOl3hnEq0In2LIO2wjCG1WzOJS44O1uQNTUP 8yHw== X-Gm-Message-State: AOAM532vDqbvf5eHfMik6W63rHSGT8mGPfZme/HrlEOlaL3MmlbC9eO6 WgeBr2e7/Dg56whbGkbOWzqUMqkFtDE= X-Google-Smtp-Source: ABdhPJxoJR3qeaAu6TDvSHQXZUan78W+T8NlccPNGIHBc1Ye873kiRlYPKzWleVY49r4U9+eIePMUQ== X-Received: by 2002:ae9:eb10:: with SMTP id b16mr1279531qkg.494.1606162182976; Mon, 23 Nov 2020 12:09:42 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id t51sm9715698qtb.11.2020.11.23.12.09.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:09:42 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK9fm3010471 for ; Mon, 23 Nov 2020 20:09:41 GMT Subject: [PATCH v3 65/85] NFSD: Replace READ* macros in nfsd4_decode_layoutcommit() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:09:41 -0500 Message-ID: <160616218130.51996.15666019727368165292.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 120 ++++++++++++++++++++++++++--------------------------- 1 file changed, 58 insertions(+), 62 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 4be809f00eb1..febdc4b10e13 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -274,20 +274,6 @@ nfsd4_decode_component4(struct nfsd4_compoundargs *argp, char **namp, u32 *lenp) return nfs_ok; } -static __be32 -nfsd4_decode_time(struct nfsd4_compoundargs *argp, struct timespec64 *tv) -{ - DECODE_HEAD; - - READ_BUF(12); - p = xdr_decode_hyper(p, &tv->tv_sec); - tv->tv_nsec = be32_to_cpup(p++); - if (tv->tv_nsec >= (u32)1000000000) - return nfserr_inval; - - DECODE_TAIL; -} - static __be32 nfsd4_decode_nfstime4(struct nfsd4_compoundargs *argp, struct timespec64 *tv) { @@ -651,6 +637,29 @@ nfsd4_decode_deviceid4(struct nfsd4_compoundargs *argp, memcpy(devid, p, sizeof(*devid)); return nfs_ok; } + +static __be32 +nfsd4_decode_layoutupdate4(struct nfsd4_compoundargs *argp, + struct nfsd4_layoutcommit *lcp) +{ + if (xdr_stream_decode_u32(argp->xdr, &lcp->lc_layout_type) < 0) + return nfserr_bad_xdr; + if (lcp->lc_layout_type < LAYOUT_NFSV4_1_FILES) + return nfserr_bad_xdr; + if (lcp->lc_layout_type >= LAYOUT_TYPE_MAX) + return nfserr_bad_xdr; + + if (xdr_stream_decode_u32(argp->xdr, &lcp->lc_up_len) < 0) + return nfserr_bad_xdr; + if (lcp->lc_up_len > 0) { + lcp->lc_up_layout = xdr_inline_decode(argp->xdr, lcp->lc_up_len); + if (!lcp->lc_up_layout) + return nfserr_bad_xdr; + } + + return nfs_ok; +} + #endif /* CONFIG_NFSD_PNFS */ static __be32 @@ -1796,6 +1805,41 @@ nfsd4_decode_getdeviceinfo(struct nfsd4_compoundargs *argp, return nfs_ok; } +static __be32 +nfsd4_decode_layoutcommit(struct nfsd4_compoundargs *argp, + struct nfsd4_layoutcommit *lcp) +{ + __be32 *p, status; + + if (xdr_stream_decode_u64(argp->xdr, &lcp->lc_seg.offset) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, &lcp->lc_seg.length) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_bool(argp->xdr, &lcp->lc_reclaim) < 0) + return nfserr_bad_xdr; + status = nfsd4_decode_stateid4(argp, &lcp->lc_sid); + if (status) + return status; + if (xdr_stream_decode_u32(argp->xdr, &lcp->lc_newoffset) < 0) + return nfserr_bad_xdr; + if (lcp->lc_newoffset) { + if (xdr_stream_decode_u64(argp->xdr, &lcp->lc_last_wr) < 0) + return nfserr_bad_xdr; + } else + lcp->lc_last_wr = 0; + p = xdr_inline_decode(argp->xdr, XDR_UNIT); + if (!p) + return nfserr_bad_xdr; + if (xdr_item_is_present(p)) { + status = nfsd4_decode_nfstime4(argp, &lcp->lc_mtime); + if (status) + return status; + } else { + lcp->lc_mtime.tv_nsec = UTIME_NOW; + } + return nfsd4_decode_layoutupdate4(argp, lcp); +} + static __be32 nfsd4_decode_layoutget(struct nfsd4_compoundargs *argp, struct nfsd4_layoutget *lgp) @@ -1820,54 +1864,6 @@ nfsd4_decode_layoutget(struct nfsd4_compoundargs *argp, DECODE_TAIL; } -static __be32 -nfsd4_decode_layoutcommit(struct nfsd4_compoundargs *argp, - struct nfsd4_layoutcommit *lcp) -{ - DECODE_HEAD; - u32 timechange; - - READ_BUF(20); - p = xdr_decode_hyper(p, &lcp->lc_seg.offset); - p = xdr_decode_hyper(p, &lcp->lc_seg.length); - lcp->lc_reclaim = be32_to_cpup(p++); - - status = nfsd4_decode_stateid(argp, &lcp->lc_sid); - if (status) - return status; - - READ_BUF(4); - lcp->lc_newoffset = be32_to_cpup(p++); - if (lcp->lc_newoffset) { - READ_BUF(8); - p = xdr_decode_hyper(p, &lcp->lc_last_wr); - } else - lcp->lc_last_wr = 0; - READ_BUF(4); - timechange = be32_to_cpup(p++); - if (timechange) { - status = nfsd4_decode_time(argp, &lcp->lc_mtime); - if (status) - return status; - } else { - lcp->lc_mtime.tv_nsec = UTIME_NOW; - } - READ_BUF(8); - lcp->lc_layout_type = be32_to_cpup(p++); - - /* - * Save the layout update in XDR format and let the layout driver deal - * with it later. - */ - lcp->lc_up_len = be32_to_cpup(p++); - if (lcp->lc_up_len > 0) { - READ_BUF(lcp->lc_up_len); - READMEM(lcp->lc_up_layout, lcp->lc_up_len); - } - - DECODE_TAIL; -} - static __be32 nfsd4_decode_layoutreturn(struct nfsd4_compoundargs *argp, struct nfsd4_layoutreturn *lrp) From patchwork Mon Nov 23 20:09:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926337 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72C5CC6379D for ; Mon, 23 Nov 2020 20:10:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2651E20721 for ; Mon, 23 Nov 2020 20:10:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Wvr6uL29" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731416AbgKWUJu (ORCPT ); Mon, 23 Nov 2020 15:09:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728652AbgKWUJt (ORCPT ); Mon, 23 Nov 2020 15:09:49 -0500 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4117AC061A4D for ; Mon, 23 Nov 2020 12:09:49 -0800 (PST) Received: by mail-qk1-x744.google.com with SMTP id q5so18216782qkc.12 for ; Mon, 23 Nov 2020 12:09:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=P+qpi3cGFXou6Kf66J1L1VKL4vJuQ963lSpVMW2TZ+A=; b=Wvr6uL29sb2fceIDT4XXJ8WCHIg5NmxcbvDM4pb96Y0ifhAyFVoDo+qzRdh3NXX/I0 IyUaS8hYgDDMg9K6s+IzZneFiDpvtfLaY5gdEnfPkMCvALhMUNQ1RaQhTD3kGuAxUPj7 FfqvXgIOvQtaSagE6ECPNWL7fBmRjBc7N0adaUFXYzwgq4GszJwvLu5BD45+iMeRTYHs GOEGyClGBgnF3se3D08xEBC1dT4giaLxD+rNSuBPX5m8qQ7YznIPq9QKW3Sb/oxK4gni 8XN4jdo6oBUUp3/fJtqwGaeBLcgFAg26xsqMyJIGUucT2rEPkMSrDcqStMXs601CbUad oy1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=P+qpi3cGFXou6Kf66J1L1VKL4vJuQ963lSpVMW2TZ+A=; b=Uurp1+osSqbsm9BIbop6/0PieToXXHap/tl25uN5UO+Rvm8Z+5VPecJyC4QRSKi6rn 8QhS8XO12SEmcitvjG20OiSq93bECL0lGGh7mDXj1DLgRcrJx78y5I5t6QATi7hcWJE1 yHVgvnASR0eIDk/18JXpK9tl+dgzJ/UBV7FfoQP7KIiYB5X7Js8dULlO8a2PHgsH7WIB BT+QVGBb+qjMcZLdpbBZ08myWNTF3q4cV/Hl062+f3U6SGONBlFrtWXZ5gkPq1v9pts7 EXjgALgcNXxhqmELQm1VpGLu9i75i3nFL2qxOA68LDjzNBQrcIdPYMknF88nbQc1mKvy zmRw== X-Gm-Message-State: AOAM530NfZzXBMUqoEvP2WgMnXtDvm8T2MuPhsEicHM5NEteXx/NhRTu 4eWy9dTVUMXrJ4XDiUWKm6ScAgB6Jvc= X-Google-Smtp-Source: ABdhPJwnhlCAEi7hcIuT8RXc2JtAf9E8ZrtaYVFHpbUofCqek0X/xdPTnfJSZkG9E43I5n6STUgrbA== X-Received: by 2002:a37:2790:: with SMTP id n138mr1165583qkn.324.1606162188210; Mon, 23 Nov 2020 12:09:48 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id n9sm5513807qti.75.2020.11.23.12.09.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:09:47 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK9kZY010474 for ; Mon, 23 Nov 2020 20:09:46 GMT Subject: [PATCH v3 66/85] NFSD: Replace READ* macros in nfsd4_decode_layoutget() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:09:46 -0500 Message-ID: <160616218659.51996.9574327474130071630.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index febdc4b10e13..89b5b919beab 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1844,24 +1844,27 @@ static __be32 nfsd4_decode_layoutget(struct nfsd4_compoundargs *argp, struct nfsd4_layoutget *lgp) { - DECODE_HEAD; - - READ_BUF(36); - lgp->lg_signal = be32_to_cpup(p++); - lgp->lg_layout_type = be32_to_cpup(p++); - lgp->lg_seg.iomode = be32_to_cpup(p++); - p = xdr_decode_hyper(p, &lgp->lg_seg.offset); - p = xdr_decode_hyper(p, &lgp->lg_seg.length); - p = xdr_decode_hyper(p, &lgp->lg_minlength); + __be32 status; - status = nfsd4_decode_stateid(argp, &lgp->lg_sid); + if (xdr_stream_decode_u32(argp->xdr, &lgp->lg_signal) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &lgp->lg_layout_type) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &lgp->lg_seg.iomode) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, &lgp->lg_seg.offset) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, &lgp->lg_seg.length) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, &lgp->lg_minlength) < 0) + return nfserr_bad_xdr; + status = nfsd4_decode_stateid4(argp, &lgp->lg_sid); if (status) return status; + if (xdr_stream_decode_u32(argp->xdr, &lgp->lg_maxcount) < 0) + return nfserr_bad_xdr; - READ_BUF(4); - lgp->lg_maxcount = be32_to_cpup(p++); - - DECODE_TAIL; + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:09:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926341 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30AA1C83011 for ; Mon, 23 Nov 2020 20:10:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CF5EF20721 for ; Mon, 23 Nov 2020 20:10:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="p90yBdFq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731678AbgKWUJ4 (ORCPT ); Mon, 23 Nov 2020 15:09:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731661AbgKWUJy (ORCPT ); Mon, 23 Nov 2020 15:09:54 -0500 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AD6AC0613CF for ; Mon, 23 Nov 2020 12:09:54 -0800 (PST) Received: by mail-qt1-x841.google.com with SMTP id z3so14345244qtw.9 for ; Mon, 23 Nov 2020 12:09:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=0/vbsUMIt9/2qb+yufmXMQ9nPbCmEuG07gvMLR2Mjjo=; b=p90yBdFqNT7XNXILC51hHLIjcc7TD+afvdyFc3Awa2UYa1ShLHi5ehMIbbtcNknwnj Pnm6VTR6YSdrOuYIKWDlOhwL2/GqHmp2xOlxyaPQXCTNPB5U0be9Z23fpuRyMsQxYzSS vfgytTJcBmwYzGzf508sWgJVi5+eXlJOrcLQasrkqA5SwcdXp72vI8RSvbhQHUm1nvqP krB9ild0cBLyudpiSYTh45yq0/p0VEMddQh41ZtZsw0T/rRxg9CCXpObw4qhiCJKmK7y Cj44vARnid95Eiwl1EJpM3Al/gd/uoDxYFsMYnpESTzHPGfr+UbDN3vs4ygLWoEebxiz nEDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=0/vbsUMIt9/2qb+yufmXMQ9nPbCmEuG07gvMLR2Mjjo=; b=QhH98OJ/WXzHJRc0tE52YCQqAa0NLq1JIASeaFZP01Ww39lbu65yOTkBVpEP0YpPuW 86i+20uTi2NVSLFzMXS+c06rlCZ32AITwikxin5HLskAi6bMRnREvX9CDSTVX+LWeilY Q/PiQBTDCMgyB46QLWS2RgO+DA/4qWvmg4bBpd7EINXjLXT2lbXmBQWak5ygV0DbiKb0 0GKuXLZzpDvO2ZbP4NbZOeGDHQR29LhSkVsxTXECbpK6B5yXbKhQxD8cgFu1Be3ueezD VyQC2zgZSaU0ZUjRG8IKBYwmZUtD7UV0CB42N6hX/RYsBeByJN97UzD7TGFWoziFiZj4 RTxQ== X-Gm-Message-State: AOAM530K1bgatAABNMiE14Y6Mgy0fqm8LrYW2fBLmlIO6xz64pP3NLSU XKOURVKDtC380jsa69G5dSChjqj+T0E= X-Google-Smtp-Source: ABdhPJwsVNnmFUK3a4f8Vb85118mhi5A6+9RqLaxeBK5aHvpSxOsC/fzsMR2pMS47YAp3DuTh7qr8w== X-Received: by 2002:ac8:3707:: with SMTP id o7mr898240qtb.344.1606162193518; Mon, 23 Nov 2020 12:09:53 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id n21sm5260850qke.32.2020.11.23.12.09.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:09:52 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK9psl010477 for ; Mon, 23 Nov 2020 20:09:51 GMT Subject: [PATCH v3 67/85] NFSD: Replace READ* macros in nfsd4_decode_layoutreturn() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:09:51 -0500 Message-ID: <160616219187.51996.1087900867142675882.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 72 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 28 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 89b5b919beab..f93a0b9f202f 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -660,6 +660,43 @@ nfsd4_decode_layoutupdate4(struct nfsd4_compoundargs *argp, return nfs_ok; } +static __be32 +nfsd4_decode_layoutreturn4(struct nfsd4_compoundargs *argp, + struct nfsd4_layoutreturn *lrp) +{ + __be32 status; + + if (xdr_stream_decode_u32(argp->xdr, &lrp->lr_return_type) < 0) + return nfserr_bad_xdr; + switch (lrp->lr_return_type) { + case RETURN_FILE: + if (xdr_stream_decode_u64(argp->xdr, &lrp->lr_seg.offset) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, &lrp->lr_seg.length) < 0) + return nfserr_bad_xdr; + status = nfsd4_decode_stateid4(argp, &lrp->lr_sid); + if (status) + return status; + if (xdr_stream_decode_u32(argp->xdr, &lrp->lrf_body_len) < 0) + return nfserr_bad_xdr; + if (lrp->lrf_body_len > 0) { + lrp->lrf_body = xdr_inline_decode(argp->xdr, lrp->lrf_body_len); + if (!lrp->lrf_body) + return nfserr_bad_xdr; + } + break; + case RETURN_FSID: + case RETURN_ALL: + lrp->lr_seg.offset = 0; + lrp->lr_seg.length = NFS4_MAX_UINT64; + break; + default: + return nfserr_bad_xdr; + } + + return nfs_ok; +} + #endif /* CONFIG_NFSD_PNFS */ static __be32 @@ -1871,34 +1908,13 @@ static __be32 nfsd4_decode_layoutreturn(struct nfsd4_compoundargs *argp, struct nfsd4_layoutreturn *lrp) { - DECODE_HEAD; - - READ_BUF(16); - lrp->lr_reclaim = be32_to_cpup(p++); - lrp->lr_layout_type = be32_to_cpup(p++); - lrp->lr_seg.iomode = be32_to_cpup(p++); - lrp->lr_return_type = be32_to_cpup(p++); - if (lrp->lr_return_type == RETURN_FILE) { - READ_BUF(16); - p = xdr_decode_hyper(p, &lrp->lr_seg.offset); - p = xdr_decode_hyper(p, &lrp->lr_seg.length); - - status = nfsd4_decode_stateid(argp, &lrp->lr_sid); - if (status) - return status; - - READ_BUF(4); - lrp->lrf_body_len = be32_to_cpup(p++); - if (lrp->lrf_body_len > 0) { - READ_BUF(lrp->lrf_body_len); - READMEM(lrp->lrf_body, lrp->lrf_body_len); - } - } else { - lrp->lr_seg.offset = 0; - lrp->lr_seg.length = NFS4_MAX_UINT64; - } - - DECODE_TAIL; + if (xdr_stream_decode_bool(argp->xdr, &lrp->lr_reclaim) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &lrp->lr_layout_type) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &lrp->lr_seg.iomode) < 0) + return nfserr_bad_xdr; + return nfsd4_decode_layoutreturn4(argp, lrp); } #endif /* CONFIG_NFSD_PNFS */ From patchwork Mon Nov 23 20:09:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B64A8C71155 for ; Mon, 23 Nov 2020 20:12:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 623D020717 for ; Mon, 23 Nov 2020 20:12:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Tz+rz/b2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733140AbgKWUM1 (ORCPT ); Mon, 23 Nov 2020 15:12:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731538AbgKWUJ7 (ORCPT ); Mon, 23 Nov 2020 15:09:59 -0500 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D136CC0613CF for ; Mon, 23 Nov 2020 12:09:59 -0800 (PST) Received: by mail-qt1-x842.google.com with SMTP id e60so5144104qtd.3 for ; Mon, 23 Nov 2020 12:09:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=EG/wCVOkuiphrscXqgnH1HwcG1Je9yojXWv45ccupxA=; b=Tz+rz/b2i5KV7RS3zNmdXS5jV85rxgBCSQwemktecb+Z5Bo2TlO9QDTLvQnPokuj2T FX+LAAY2t7hBxCbxUValeCVeioR8bptoVRxZHAUryQJ9QTnbEYQSl0hrMm0pRwg7F4ZK gZf2rH/U1gu0uAgV4GSO3SIWu6g/0dkHle9ssX0DeGoZ2JBVg7o5zUlUxM8pWajM5gm0 0aOxJzdf/ONaVnN/e/5luzaVn8iF7tpfp3yBUP+T9fQr9wgFH8saLWlQJc2W3Jr9P/1Z i6w2K5xDuvsGTB2p10AoAs+fGtt4azAn5JJXaiHQY2nd+SZYutdosHk/cArkDjU61T8X ZWWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=EG/wCVOkuiphrscXqgnH1HwcG1Je9yojXWv45ccupxA=; b=uTKPwmu56ikqLSgH8Ug8s+FGeViHZyjCJUtRCzLxbqv8CWvZZvnS1ZH9FoJDs6XpGS lXKDQqdS24JjzrqMLTa3GJOucrVWjNztnPotjl2YLLPQuaIme/igOEe9SNkGZmxa/TvF n8SrISI5CC8AiwcG+oHvMJjljafA8VVtGKLI5XWE4H0NU3AoDSASd1+9Hw92WfaI0+d3 qjNOYeHRZTI1dhc5HXkz8FgHCssXdzAWXEUUf+U6+t8mUx7PyBULjy2LM6CVhcA+deBz Yv1Nazlzblif2P1Wj7n2sEOFTi0g5nNYOZ9j94Z78w43BaJ1yhAuW96StRNBjhWd1eFJ sSjQ== X-Gm-Message-State: AOAM533JtHoHOpULSvMgpBqXcc/JflQ84TKYz35Iq1JV8sdFczsTQGIt Kp2/2MqLckaQ+tnmChbodkt2ddIsgxE= X-Google-Smtp-Source: ABdhPJxSDWn8c5HWqu36u0TR7USfdkrEo+Q9qOMuaB2L/x3Ae/VaRue2LPyVl2tJI7cHhvU5lE7qLA== X-Received: by 2002:ac8:7306:: with SMTP id x6mr917087qto.272.1606162198794; Mon, 23 Nov 2020 12:09:58 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id v6sm10328697qkh.83.2020.11.23.12.09.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:09:58 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANK9v41010480 for ; Mon, 23 Nov 2020 20:09:57 GMT Subject: [PATCH v3 68/85] NFSD: Replace READ* macros in nfsd4_decode_secinfo_no_name() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:09:57 -0500 Message-ID: <160616219716.51996.10655963479904967000.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index f93a0b9f202f..903abb421e88 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1356,17 +1356,6 @@ nfsd4_decode_secinfo(struct nfsd4_compoundargs *argp, return nfsd4_decode_component4(argp, &secinfo->si_name, &secinfo->si_namelen); } -static __be32 -nfsd4_decode_secinfo_no_name(struct nfsd4_compoundargs *argp, - struct nfsd4_secinfo_no_name *sin) -{ - DECODE_HEAD; - - READ_BUF(4); - sin->sin_style = be32_to_cpup(p++); - DECODE_TAIL; -} - static __be32 nfsd4_decode_setattr(struct nfsd4_compoundargs *argp, struct nfsd4_setattr *setattr) { @@ -1918,6 +1907,14 @@ nfsd4_decode_layoutreturn(struct nfsd4_compoundargs *argp, } #endif /* CONFIG_NFSD_PNFS */ +static __be32 nfsd4_decode_secinfo_no_name(struct nfsd4_compoundargs *argp, + struct nfsd4_secinfo_no_name *sin) +{ + if (xdr_stream_decode_u32(argp->xdr, &sin->sin_style) < 0) + return nfserr_bad_xdr; + return nfs_ok; +} + static __be32 nfsd4_decode_fallocate(struct nfsd4_compoundargs *argp, struct nfsd4_fallocate *fallocate) From patchwork Mon Nov 23 20:10:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926489 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0570EC71156 for ; Mon, 23 Nov 2020 20:12:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9CF0D20715 for ; Mon, 23 Nov 2020 20:12:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aZKHGwIW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731855AbgKWUM0 (ORCPT ); Mon, 23 Nov 2020 15:12:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731794AbgKWUKF (ORCPT ); Mon, 23 Nov 2020 15:10:05 -0500 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 487E4C0613CF for ; Mon, 23 Nov 2020 12:10:05 -0800 (PST) Received: by mail-qk1-x744.google.com with SMTP id d9so18235805qke.8 for ; Mon, 23 Nov 2020 12:10:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=7SIeL2JJXEWAu2oUfB3SEbTHlCZXi/YUOEAb5EOSfkc=; b=aZKHGwIWRQ5NlKftee2YHEbLWoEI+xD4gtdlxqEOjqrFeSC+CFTaN2guptENCNB12B SR3wAjjgCStRJv4wqSqufYOEo80LHiSf3FPSa3cWf+vJ89yYUCYHDwH11gpHjfucCKSX aN32pLRLUsEZWWGSrx4+Zg8mOubFpQVHtXJ2QoJid7ZPHAiJ88Wu/VNXzVL2vNNNAZ5+ o6UKELzNT0D9vWEhJLd1qam5EPi/erboraQsf6Lab5qh6IJn9kHO8UvIOOcwUFZ7c+Wk YY+1yx4NhkA+OAIoU5l19BQE7b2AccCjnq22i+UjAMWWYay/Veulo1C5mUe1WJUt7vAY auxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=7SIeL2JJXEWAu2oUfB3SEbTHlCZXi/YUOEAb5EOSfkc=; b=VML3R6bY1O1PqyTTWimO+7Yq3HE2UHykvMuBuRVUnApgbuAc1y27bmSv1IWDd9bn+3 4/pqqoVAM3rpbykuFokzNfJxntdeN5fIObh6bTTdFIkr/wj1jrbIfwYyFITBZ5Qkmqep UNZL+TkAzGV6uZU7I/2htnzprEvP9iKqRwWcl0Sve8sOsE2WK+hjt0lerZac8hD6s63L nnvIIwdprJlxy3R0jg+A3jx8e64eAdRHvS3Iufg9sLxhSTeaYEsPwu3AYfFe/FFMzq3J rWGQPMfJGlGUexer4zUWrkAEjilfP7FUFrEjwLjAUIImeaF4nDJlInOFYYksgTDySMrX cZrw== X-Gm-Message-State: AOAM532J4hRucy8TI23cNMYh1LgOFUNB+gF6LYNCkyA/1umwvBcymaJa CDsz+/iokiSmJ/THTO89e/7PVY6BWKU= X-Google-Smtp-Source: ABdhPJwyQAoRSlw2HXQI7+jT76ojvzOlXqJR4Mxm0z3XyYiY89Sp1DhpoPOc7mRA2rRTLGQCvr2maA== X-Received: by 2002:a05:620a:12ca:: with SMTP id e10mr1226294qkl.209.1606162204221; Mon, 23 Nov 2020 12:10:04 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id c27sm10190087qkk.57.2020.11.23.12.10.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:10:03 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKA2rk010491 for ; Mon, 23 Nov 2020 20:10:02 GMT Subject: [PATCH v3 69/85] NFSD: Replace READ* macros in nfsd4_decode_sequence() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:10:02 -0500 Message-ID: <160616220244.51996.226421916291445047.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 903abb421e88..04f2a9941972 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1738,22 +1738,6 @@ nfsd4_decode_free_stateid(struct nfsd4_compoundargs *argp, return nfsd4_decode_stateid4(argp, &free_stateid->fr_stateid); } -static __be32 -nfsd4_decode_sequence(struct nfsd4_compoundargs *argp, - struct nfsd4_sequence *seq) -{ - DECODE_HEAD; - - READ_BUF(NFS4_MAX_SESSIONID_LEN + 16); - COPYMEM(seq->sessionid.data, NFS4_MAX_SESSIONID_LEN); - seq->seqid = be32_to_cpup(p++); - seq->slotid = be32_to_cpup(p++); - seq->maxslots = be32_to_cpup(p++); - seq->cachethis = be32_to_cpup(p++); - - DECODE_TAIL; -} - static __be32 nfsd4_decode_test_stateid(struct nfsd4_compoundargs *argp, struct nfsd4_test_stateid *test_stateid) { @@ -1915,6 +1899,26 @@ static __be32 nfsd4_decode_secinfo_no_name(struct nfsd4_compoundargs *argp, return nfs_ok; } +static __be32 +nfsd4_decode_sequence(struct nfsd4_compoundargs *argp, + struct nfsd4_sequence *seq) +{ + __be32 *p, status; + + status = nfsd4_decode_sessionid4(argp, &seq->sessionid); + if (status) + return status; + p = xdr_inline_decode(argp->xdr, XDR_UNIT * 4); + if (!p) + return nfserr_bad_xdr; + seq->seqid = be32_to_cpup(p++); + seq->slotid = be32_to_cpup(p++); + seq->maxslots = be32_to_cpup(p++); + seq->cachethis = be32_to_cpup(p); + + return nfs_ok; +} + static __be32 nfsd4_decode_fallocate(struct nfsd4_compoundargs *argp, struct nfsd4_fallocate *fallocate) From patchwork Mon Nov 23 20:10:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926349 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6D67C64E7A for ; Mon, 23 Nov 2020 20:10:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73CCA20715 for ; Mon, 23 Nov 2020 20:10:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Al5F7+9c" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728615AbgKWUKL (ORCPT ); Mon, 23 Nov 2020 15:10:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731892AbgKWUKK (ORCPT ); Mon, 23 Nov 2020 15:10:10 -0500 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DCDEC0613CF for ; Mon, 23 Nov 2020 12:10:10 -0800 (PST) Received: by mail-qt1-x842.google.com with SMTP id g17so14378559qts.5 for ; Mon, 23 Nov 2020 12:10:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=NVkvmfIF14WvCPapVrQjASHKw0LWR/Wj5JOWXNp8nL8=; b=Al5F7+9cY30fMqEXte1O2w2nQ/NYDHjppNgBQ5lJtEH1t8/xHQsrHbxQj4CbwKZl58 E716j3vQzOVucCZii4uxw9t8jr7MURt9ODTo9jVMx0aB2xmuvw0/o9ZA2A9QDRKkRILT vkCgc4XHuXwlffoMwhj7ZjJ/zVpf1bOVSL4K4bFzqU1fpJOerFlWm4qCShIyOPQh6V9O KMFrBXaP+ys+/vaPNki8l74OFC1PmRsVDzw7kEcuBDJM9Ecm/aW/Z5glWgmLgkNjxzk/ WGQ+w+erwyQiVq4k6VITiHKB1SxigXb4OuBgL1fXJh+7PCjM1Ur3Dxpdo5tqpHKHoUlH MMZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=NVkvmfIF14WvCPapVrQjASHKw0LWR/Wj5JOWXNp8nL8=; b=rjuNOKfgS9KVusp1Z7vmQVj2sxyYSae8XztuMDor1kc2v0WRSdu/wyaaRsoAOe4cPB Wp/F1Y44HPIb+8aFdgJeb7Bszvec+695cr4lR1KTCARTcWCcSArrkMpUWzhewk2N6S2+ EVW4B9F4kRjrKpLN3EEiU37YxIjoHEyuRzoy+XoZt4wzpgypeoiEOCPi6nIS0+t3pU2H RnRxMWyVekBNF/HEZ+Md0qqLl8os+9vbrpwGgbPOPzQsM9tvPPRj6lBOclgqlywMLo5n X7XzweJa3oyz6Tj/aWqe7800p6l+7v9+who99ggeGBsGkiEQG+6x2oMM0JOoZQbFCuLr ngEw== X-Gm-Message-State: AOAM533HkCpO70YIgo0EVUqjM4kEYokh9+624ev6l2OgtnaZqSvWz1mC YFFd6nO7IH5sO1vHRfaoi4MJM4fuUQc= X-Google-Smtp-Source: ABdhPJyfPxoSJs2PT6pAlGnJSShg+v1FErPNmt5FE8G2Rqwbj2cEPiKfFCaKyESqIWW7We+zxAT9IQ== X-Received: by 2002:aed:3768:: with SMTP id i95mr975512qtb.0.1606162209339; Mon, 23 Nov 2020 12:10:09 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id u15sm10022318qkj.122.2020.11.23.12.10.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:10:08 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKA7Nw010494 for ; Mon, 23 Nov 2020 20:10:07 GMT Subject: [PATCH v3 70/85] NFSD: Replace READ* macros in nfsd4_decode_test_stateid() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:10:07 -0500 Message-ID: <160616220773.51996.12741311743431409245.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 61 ++++++++++++++++++++++------------------------------- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 04f2a9941972..937f5262d619 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1738,42 +1738,6 @@ nfsd4_decode_free_stateid(struct nfsd4_compoundargs *argp, return nfsd4_decode_stateid4(argp, &free_stateid->fr_stateid); } -static __be32 -nfsd4_decode_test_stateid(struct nfsd4_compoundargs *argp, struct nfsd4_test_stateid *test_stateid) -{ - int i; - __be32 *p, status; - struct nfsd4_test_stateid_id *stateid; - - READ_BUF(4); - test_stateid->ts_num_ids = ntohl(*p++); - - INIT_LIST_HEAD(&test_stateid->ts_stateid_list); - - for (i = 0; i < test_stateid->ts_num_ids; i++) { - stateid = svcxdr_tmpalloc(argp, sizeof(*stateid)); - if (!stateid) { - status = nfserrno(-ENOMEM); - goto out; - } - - INIT_LIST_HEAD(&stateid->ts_id_list); - list_add_tail(&stateid->ts_id_list, &test_stateid->ts_stateid_list); - - status = nfsd4_decode_stateid(argp, &stateid->ts_id_stateid); - if (status) - goto out; - } - - status = 0; -out: - return status; -xdr_error: - dprintk("NFSD: xdr error (%s:%d)\n", __FILE__, __LINE__); - status = nfserr_bad_xdr; - goto out; -} - static __be32 nfsd4_decode_destroy_clientid(struct nfsd4_compoundargs *argp, struct nfsd4_destroy_clientid *dc) { DECODE_HEAD; @@ -1919,6 +1883,31 @@ nfsd4_decode_sequence(struct nfsd4_compoundargs *argp, return nfs_ok; } +static __be32 +nfsd4_decode_test_stateid(struct nfsd4_compoundargs *argp, struct nfsd4_test_stateid *test_stateid) +{ + struct nfsd4_test_stateid_id *stateid; + __be32 status; + u32 i; + + if (xdr_stream_decode_u32(argp->xdr, &test_stateid->ts_num_ids) < 0) + return nfserr_bad_xdr; + + INIT_LIST_HEAD(&test_stateid->ts_stateid_list); + for (i = 0; i < test_stateid->ts_num_ids; i++) { + stateid = svcxdr_tmpalloc(argp, sizeof(*stateid)); + if (!stateid) + return nfserrno(-ENOMEM); /* XXX: not jukebox? */ + INIT_LIST_HEAD(&stateid->ts_id_list); + list_add_tail(&stateid->ts_id_list, &test_stateid->ts_stateid_list); + status = nfsd4_decode_stateid4(argp, &stateid->ts_id_stateid); + if (status) + return status; + } + + return nfs_ok; +} + static __be32 nfsd4_decode_fallocate(struct nfsd4_compoundargs *argp, struct nfsd4_fallocate *fallocate) From patchwork Mon Nov 23 20:10:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926343 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 41067C63777 for ; Mon, 23 Nov 2020 20:10:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D1F8E20715 for ; Mon, 23 Nov 2020 20:10:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cHlT6QJc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728677AbgKWUKQ (ORCPT ); Mon, 23 Nov 2020 15:10:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732088AbgKWUKQ (ORCPT ); Mon, 23 Nov 2020 15:10:16 -0500 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFE52C0613CF for ; Mon, 23 Nov 2020 12:10:15 -0800 (PST) Received: by mail-qv1-xf42.google.com with SMTP id k3so2600920qvz.4 for ; Mon, 23 Nov 2020 12:10:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=EaSaDwTpOwckou5Mlr5/K/KUgYlZxkLJP1fujrokd7Q=; b=cHlT6QJctDTip6HK1D+Ih5dc0TbDZuxeRAiNUKwrcewrzJQHWpAqmV5CJSkAfkONGP r54g3RZtcMH6z6mFuptt7SBnVLSep0H2wpYSlUTKghws8l3baRqr1U6wxuFqWpDnz32J bLOUIW9kd3pkVaF1MKgxguRHxzr459feyt1M93mSEnAwgXB5JJ9jMvEZT7c7n7yqOJ++ 2lMVOh26DEhotOhHCnNf5T1fDqsw4QOMhEVJnWfOYrqlYBqgChyoVVsfTGI086QV1uAQ rkqz4nG2O1LS3URrXSgd35bNkDolEnsybsYK/fTKRL/BYNuKtQ+H8v1C+BXg2lAZ/Atp rK9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=EaSaDwTpOwckou5Mlr5/K/KUgYlZxkLJP1fujrokd7Q=; b=irOaXh/IRLnjnyaU1EN8z8pUrkmYdYKqrwogJCi179bh7CIpKmn+la0XYqsZSJRSY2 WKdr+Y6ZkkPX017cAP0L+zArZIENtdiz3BIJoLA/cgXp0k7Oqiq1ubz4HQ2FiUrEuib+ 4WsjmIgTyP6gMtEpFrTxCWbHuwze64e5m4IffEInJ/QG9V00ozOWa+5K0lqnyry6AgR9 8H1xnYHE+xrumbxwH7sfoIR4JqMeq5toYq5wSZyDtng7iAWZpvWGjdxI/IbLqTPCcSLf a76lJMo9CXQVRtch71AO4hCkLWaIv0W8xM9lDVadBfOeQPaOVV92e3+WPP0A0SMLc1j8 pEUg== X-Gm-Message-State: AOAM532cjlVw+3sqbVp/KnnThIuQZEHCnmXbVyoYlkXIqnEjrKgM29eT xgXCSF+DPLlV2mKqUOcMGQySY9kmz4g= X-Google-Smtp-Source: ABdhPJwLOvCjFpq1cz6+B2uIyw+QoPclGuqovCakNVEdiPZkwmEPpmyKrKaTCD48LQu3hfjAtmy37g== X-Received: by 2002:ad4:5483:: with SMTP id q3mr1240795qvy.24.1606162214742; Mon, 23 Nov 2020 12:10:14 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id p128sm6182304qkc.47.2020.11.23.12.10.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:10:14 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKADUC010497 for ; Mon, 23 Nov 2020 20:10:13 GMT Subject: [PATCH v3 71/85] NFSD: Replace READ* macros in nfsd4_decode_destroy_clientid() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:10:13 -0500 Message-ID: <160616221302.51996.10543965890986609670.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 937f5262d619..8225e3994204 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1738,16 +1738,6 @@ nfsd4_decode_free_stateid(struct nfsd4_compoundargs *argp, return nfsd4_decode_stateid4(argp, &free_stateid->fr_stateid); } -static __be32 nfsd4_decode_destroy_clientid(struct nfsd4_compoundargs *argp, struct nfsd4_destroy_clientid *dc) -{ - DECODE_HEAD; - - READ_BUF(8); - COPYMEM(&dc->clientid, 8); - - DECODE_TAIL; -} - static __be32 nfsd4_decode_reclaim_complete(struct nfsd4_compoundargs *argp, struct nfsd4_reclaim_complete *rc) { DECODE_HEAD; @@ -1908,6 +1898,12 @@ nfsd4_decode_test_stateid(struct nfsd4_compoundargs *argp, struct nfsd4_test_sta return nfs_ok; } +static __be32 nfsd4_decode_destroy_clientid(struct nfsd4_compoundargs *argp, + struct nfsd4_destroy_clientid *dc) +{ + return nfsd4_decode_clientid4(argp, &dc->clientid); +} + static __be32 nfsd4_decode_fallocate(struct nfsd4_compoundargs *argp, struct nfsd4_fallocate *fallocate) From patchwork Mon Nov 23 20:10:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926345 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0328FC6379F for ; Mon, 23 Nov 2020 20:10:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9197A20717 for ; Mon, 23 Nov 2020 20:10:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YD/cF8Sv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732104AbgKWUKX (ORCPT ); Mon, 23 Nov 2020 15:10:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732155AbgKWUKU (ORCPT ); Mon, 23 Nov 2020 15:10:20 -0500 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F06F8C0613CF for ; Mon, 23 Nov 2020 12:10:20 -0800 (PST) Received: by mail-qt1-x842.google.com with SMTP id t5so14390283qtp.2 for ; Mon, 23 Nov 2020 12:10:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=hltaQvsj5v3TN21OXjnwqowVnB5dD/Ti3b5+ugkTcwM=; b=YD/cF8Sv7VvdPtrnwfa6Jg34DMGY+LgOQEVm/tD3TeZTCP8Y1yeMxwv8dpY1YqPj0D z4tp+wtqCIwO8q6HfnqOx4+VqWMAguQW7JZjZDjskAoemO7YZxEswNtIqx5fG+cY6FuD fBAZFpGF39sdu+9SZLSDs/D3qps0hjar+6Mhj/UqYKHIP8qrGv1PJb7YxI+4h7hOp217 Frw87DmtbTFTfqBf72qtVKDJ5opP8RX/Nf5DQf60mClBa+r1ueT3lrmEVrMO7aseWF34 4QXr39f5BHHknv5PfjUBP2e8wbRYemRR7C6ld4gCZMa8UVhBprL94z0w5JWghM1twenQ U4FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=hltaQvsj5v3TN21OXjnwqowVnB5dD/Ti3b5+ugkTcwM=; b=i5xHz4ejCUT3G+h3Xxeg3Jc5aTOJTkSCBhfZ9Mf+vIJAWFtcOiH/qucFF/e40Z7VTc 62fHn5Rg749wtlhrT9fH/IvAPhjx9orD3lYrd3KInZT9bKwfWxU3272hO6Y8UBi5YLIC XXNbvnnLsFr1oXokDPKyUE9Uswa+CPEX7odslx+MzwjFPeqFmH8PXL/fYEvenuOUxjLq Xn9Sz1mviVTPcKih3a7wtmYuGKtPl8euk0krUeOTALcjgT5rldOyk5EgBurS12DUR5tG Dzp3KB321j5SMe5N2hh9pNBRTHeuLLEF6J6dIUepnw+trDlCKeFqE/Atj9uFJ0Frr677 /pKQ== X-Gm-Message-State: AOAM531dGh8CChT3GMMnT0YOK7239CRDObE7FquJq7wxzKpZKB2wAUig MDbdaocOAhm3lhDfpsAyyxiGCSVM7J4= X-Google-Smtp-Source: ABdhPJzA/RTmuRQTLPoLRtGXofLLFp69iQR+GanAqLxFRHg0xadgdBpIaNO9VZYGOggX0SXj7qVOsA== X-Received: by 2002:ac8:67da:: with SMTP id r26mr899394qtp.101.1606162219893; Mon, 23 Nov 2020 12:10:19 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id t2sm5477056qtr.24.2020.11.23.12.10.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:10:19 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKAIfn010500 for ; Mon, 23 Nov 2020 20:10:18 GMT Subject: [PATCH v3 72/85] NFSD: Replace READ* macros in nfsd4_decode_reclaim_complete() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:10:18 -0500 Message-ID: <160616221830.51996.17374559850572472217.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 8225e3994204..7e54cf0d4147 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1738,16 +1738,6 @@ nfsd4_decode_free_stateid(struct nfsd4_compoundargs *argp, return nfsd4_decode_stateid4(argp, &free_stateid->fr_stateid); } -static __be32 nfsd4_decode_reclaim_complete(struct nfsd4_compoundargs *argp, struct nfsd4_reclaim_complete *rc) -{ - DECODE_HEAD; - - READ_BUF(4); - rc->rca_one_fs = be32_to_cpup(p++); - - DECODE_TAIL; -} - #ifdef CONFIG_NFSD_PNFS static __be32 nfsd4_decode_getdeviceinfo(struct nfsd4_compoundargs *argp, @@ -1904,6 +1894,14 @@ static __be32 nfsd4_decode_destroy_clientid(struct nfsd4_compoundargs *argp, return nfsd4_decode_clientid4(argp, &dc->clientid); } +static __be32 nfsd4_decode_reclaim_complete(struct nfsd4_compoundargs *argp, + struct nfsd4_reclaim_complete *rc) +{ + if (xdr_stream_decode_bool(argp->xdr, &rc->rca_one_fs) < 0) + return nfserr_bad_xdr; + return nfs_ok; +} + static __be32 nfsd4_decode_fallocate(struct nfsd4_compoundargs *argp, struct nfsd4_fallocate *fallocate) From patchwork Mon Nov 23 20:10:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926347 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 86E32C64E75 for ; Mon, 23 Nov 2020 20:10:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 390FB20717 for ; Mon, 23 Nov 2020 20:10:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ab0sALcM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731974AbgKWUK0 (ORCPT ); Mon, 23 Nov 2020 15:10:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732186AbgKWUK0 (ORCPT ); Mon, 23 Nov 2020 15:10:26 -0500 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13ED7C0613CF for ; Mon, 23 Nov 2020 12:10:26 -0800 (PST) Received: by mail-qt1-x843.google.com with SMTP id e10so6900798qte.4 for ; Mon, 23 Nov 2020 12:10:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=8qm6AuA4fWlfqFP8HvQtU8t7lhensaoYUkTE+XruJT8=; b=Ab0sALcMOYiMrPLQS88MzlpW5yXvYu1SYsa9ni1wsZob98Txvv8FLk4kMdpdyZUAvK PjrJczYLeI2uHSzXbvP4X/DqVS6P8cDoyD4OuL9XMTS3dwTPOe7FSd7urJIcuA3Ra0Rl QmmPgwN6AizG2GF+/ZMsJ84BPBYb5Hm1hZbVlWUUDzdC1WTT+VmjkhXR0KFYgOb33wLz TPggsryhTybfYhzTCTzFxXwbfc7JqzNNwCYYMgBIwKiZhxjxDkBfrYXW2HIL+MUBCuEa p3clmkZEG+FquRiSZdS7Q+NTocmhzD6EadpeMbPefybQsju5/J12ZP0fUQXUA8A7ay+x AByQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=8qm6AuA4fWlfqFP8HvQtU8t7lhensaoYUkTE+XruJT8=; b=NhyCbYnMQwPFZsPbBnMh5YCiQc8F7OdSmze7trD6b2NicHK06uuxDedPE9P0KMUt5v y01LsKBhWFxZXXcQupM+GSIjIFAJM5o21MaiQHYKj2aIYNdFbphfCKrOGL86Qwg+umKJ LK5ItcaWa4TQk5R1tOPdbYcbvE/O4l1jLkUh0Tp971DTI1pM8eUnLzTpVz9nqdJclZ0O w3rNbkEsYbWeqzORMYCNXy7OzCZ7ydUxMf8nCwcnAS4VF+ug0NBaGZfQm+sAFHmMUIw4 TqFkeb18IMylYOCegyynDWl4/XUM5j3JPNnX27tDj2Inpjxcq2mJC3jFSXfDvQXjMNdn G+MA== X-Gm-Message-State: AOAM5308hLnTmehfH61K1OzYqgmyCLrQ+FsN2r+yItKXdmDN4DhZVzDp w3KNwuX7mMkWfjZGc149gXTqq7qUKEU= X-Google-Smtp-Source: ABdhPJwQJhqklXr9vjdPcm1OEMVQEQ52Byn/wr9eqb4p4gRNJS1lCIkBbEQQYeurK09bNNsVS1WtIw== X-Received: by 2002:ac8:7559:: with SMTP id b25mr894382qtr.51.1606162225002; Mon, 23 Nov 2020 12:10:25 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id o22sm2087602qto.96.2020.11.23.12.10.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:10:24 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKANVP010503 for ; Mon, 23 Nov 2020 20:10:23 GMT Subject: [PATCH v3 73/85] NFSD: Replace READ* macros in nfsd4_decode_fallocate() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:10:23 -0500 Message-ID: <160616222359.51996.5801979625846189895.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 7e54cf0d4147..cfdf41599cef 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1906,17 +1906,17 @@ static __be32 nfsd4_decode_fallocate(struct nfsd4_compoundargs *argp, struct nfsd4_fallocate *fallocate) { - DECODE_HEAD; + __be32 status; - status = nfsd4_decode_stateid(argp, &fallocate->falloc_stateid); + status = nfsd4_decode_stateid4(argp, &fallocate->falloc_stateid); if (status) return status; + if (xdr_stream_decode_u64(argp->xdr, &fallocate->falloc_offset) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, &fallocate->falloc_length) < 0) + return nfserr_bad_xdr; - READ_BUF(16); - p = xdr_decode_hyper(p, &fallocate->falloc_offset); - xdr_decode_hyper(p, &fallocate->falloc_length); - - DECODE_TAIL; + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:10:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926353 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A535C64EBC for ; Mon, 23 Nov 2020 20:10:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B4A2320717 for ; Mon, 23 Nov 2020 20:10:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dTEcNYA/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729627AbgKWUKj (ORCPT ); Mon, 23 Nov 2020 15:10:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732244AbgKWUKc (ORCPT ); Mon, 23 Nov 2020 15:10:32 -0500 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F082C0613CF for ; Mon, 23 Nov 2020 12:10:31 -0800 (PST) Received: by mail-qt1-x844.google.com with SMTP id e10so6901063qte.4 for ; Mon, 23 Nov 2020 12:10:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=Q2pp9LrvrvncE6V6e0DEkbDl/hzigtwMQF76yr2cgwU=; b=dTEcNYA/L2VD4a2708V+ORAMM7eABxINmBFUF2VhZlz+VC+7BgOUbFU5IFc+VUWHUX nNH+AjGkQRs0GO4pYjW0AnC91iftvdaMqvI6+KLzvFVdoKZqrCboX49loPuDTWewjfOx hKHGdAiUyTzGGn6UtzOwROd+H9zd30N1x8+czTMv5g74D6CvA2dLlFpjBSidYwFIiJPY +nm/Hq1LRD7aFJ/x+r5Vx/P3SGFOd3xk51QT0/W76v1p2LDe9wXZnuFJLwpnUEKZe/U5 gw9rkn+q9nP9oyGqHMLy8+J9uKCnO3B2zFlinLH76JxaX39yPkTrRsPz4ZsOin4UMXfb wZ9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=Q2pp9LrvrvncE6V6e0DEkbDl/hzigtwMQF76yr2cgwU=; b=eabZlF8EPCqQCSkRK4fMMotRKFkAOYDo/PFeATsNS0lO5W1HtNWuoyh0ODjp1NnISg 1iTna55NFW40bmwsmFdOuOUEW6Uo/zoRCdGe+3ZV7Cnjad6J1J8Syt07Rshiu/a3uPOY Rigb0f5j9Wp23I0AWlrA8vGcMUQ1L3TgphSmFYMAB6Trnl2AINhosQnQhCANCg/l3h7X Ohthv0B3yo9OqXMY+yg6ceqQ0rJT1wDY/KaVOS05+kWR0aCbWeTEL4UuvO0uT50j2ygk rW3PCC9xF1RnuPFtJwyyIA3Vwd4+h5t01OQ+0/KQs/VFBLSantwX9HXIoYhC84dBgvr7 hsgg== X-Gm-Message-State: AOAM533Tepx6BN8nptX+w4LX51Cy9E4LxK/28MrhCtAgdfIYMX0+rtir Ou2MjiCZ2Qs6zIyP2CrNwIm0KKKMdyw= X-Google-Smtp-Source: ABdhPJzVvFTvzt2AvLC29sZpj6xzaKupN+ezwE1AdAslUuscDA9wUrL5Rxa6sVvw36lTkrhCDw6hbQ== X-Received: by 2002:ac8:7642:: with SMTP id i2mr891937qtr.256.1606162230322; Mon, 23 Nov 2020 12:10:30 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id d140sm10152271qke.59.2020.11.23.12.10.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:10:29 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKASDC010506 for ; Mon, 23 Nov 2020 20:10:28 GMT Subject: [PATCH v3 74/85] NFSD: Replace READ* macros in nfsd4_decode_nl4_server() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:10:28 -0500 Message-ID: <160616222865.51996.16658480268883778047.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index cfdf41599cef..6870a2ecce3b 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1941,36 +1941,42 @@ nfsd4_decode_clone(struct nfsd4_compoundargs *argp, struct nfsd4_clone *clone) static __be32 nfsd4_decode_nl4_server(struct nfsd4_compoundargs *argp, struct nl4_server *ns) { - DECODE_HEAD; struct nfs42_netaddr *naddr; + __be32 *p; - READ_BUF(4); - ns->nl4_type = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &ns->nl4_type) < 0) + return nfserr_bad_xdr; /* currently support for 1 inter-server source server */ switch (ns->nl4_type) { case NL4_NETADDR: naddr = &ns->u.nl4_addr; - READ_BUF(4); - naddr->netid_len = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &naddr->netid_len) < 0) + return nfserr_bad_xdr; if (naddr->netid_len > RPCBIND_MAXNETIDLEN) - goto xdr_error; + return nfserr_bad_xdr; - READ_BUF(naddr->netid_len + 4); /* 4 for uaddr len */ - COPYMEM(naddr->netid, naddr->netid_len); + p = xdr_inline_decode(argp->xdr, naddr->netid_len); + if (!p) + return nfserr_bad_xdr; + memcpy(naddr->netid, p, naddr->netid_len); - naddr->addr_len = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &naddr->addr_len) < 0) + return nfserr_bad_xdr; if (naddr->addr_len > RPCBIND_MAXUADDRLEN) - goto xdr_error; + return nfserr_bad_xdr; - READ_BUF(naddr->addr_len); - COPYMEM(naddr->addr, naddr->addr_len); + p = xdr_inline_decode(argp->xdr, naddr->addr_len); + if (!p) + return nfserr_bad_xdr; + memcpy(naddr->addr, p, naddr->addr_len); break; default: - goto xdr_error; + return nfserr_bad_xdr; } - DECODE_TAIL; + + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:10:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926351 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B06DC63777 for ; Mon, 23 Nov 2020 20:10:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB74020715 for ; Mon, 23 Nov 2020 20:10:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vEkG67hs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726801AbgKWUKi (ORCPT ); Mon, 23 Nov 2020 15:10:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729627AbgKWUKg (ORCPT ); Mon, 23 Nov 2020 15:10:36 -0500 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B245C0613CF for ; Mon, 23 Nov 2020 12:10:36 -0800 (PST) Received: by mail-qt1-x841.google.com with SMTP id f27so4803650qtv.6 for ; Mon, 23 Nov 2020 12:10:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=1iuOnJBz5vXpYGYlvSLmlNOuFzGXcvE7+eiNI+Hzfw8=; b=vEkG67hsROWPEsNES9lRAz+ICKM614POO7cmUHUpnSpDBwUaNzn9Z1Utt3UbtO94V7 WcOjuuk8pwNkv6fz2EXVWCBrniQfWuFmAC0j1N1oeKF7UU1ZsRICzythqajW1+X6/nmI RnCCeUQVXk1jZrosnE6Zps8ip8lgfK2NfOw7GbheYmjGqOdniTCfEZ/dZBwkVn5OsAHV V3UPxt7NXZ36A2aD+ZQtKt1jzlOLp0BgktVwMcnGfcdfl1ctrZKrMFbPDQPVK4kXRK1s +sUzv+VqjvBU36nnqUnoRHAfLOyMJcwtWx74eDqj2qWE7uYlk3YG4mGl11eqM7vIKkLo 5Nxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=1iuOnJBz5vXpYGYlvSLmlNOuFzGXcvE7+eiNI+Hzfw8=; b=I/7o2exezzTF3CA0OQrS3yoUlSUXsqe2p0hy0Er627HfSnwzgsSd+7udehRDRBvQtR C8CtezN3ud5magqZhMjzeYzwHkWDff9miJtVytd7h/VFsvy+YpRueNbQm80R4Ev+ljlb v7VkXOpLDw+syWsOUrNLpsQORRGYOHHnyLmYXoNZZuSA2tL2IjAUt9UoVyJxT3koCqbc 7Vd2LZ0TcVwG+zQqMtN4z7/BRysssr8aG4xqF4e53RGs8i8O//bd9Aq7BiWO8Kz5Bdq4 sA3baTHXu6ATYmM1KtB37e0ncBDT+sgeI+oQrOQ8q2cEX7e3sTtnRdggJxZxLu2UwM5z gKvg== X-Gm-Message-State: AOAM5330TEob6lQDA+Ru/v5Bn5kSFIH1zDBeFlU26umxfTDrcBFs8E24 d0+a7d76PNHhaGbxalBORq1uWWNHiLI= X-Google-Smtp-Source: ABdhPJw/egDWiaNkzdF7/eaUI5wjQbN9oFg0aUJbmXnwTvNVb5Kh/2H23q+uG7/nv9IhMMoJwMAT9w== X-Received: by 2002:ac8:7749:: with SMTP id g9mr897376qtu.303.1606162235320; Mon, 23 Nov 2020 12:10:35 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id r190sm10266256qkf.101.2020.11.23.12.10.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:10:34 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKAXX7010509 for ; Mon, 23 Nov 2020 20:10:33 GMT Subject: [PATCH v3 75/85] NFSD: Replace READ* macros in nfsd4_decode_copy() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:10:33 -0500 Message-ID: <160616223394.51996.6464657919629252433.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 41 ++++++++++++++++++++++------------------- fs/nfsd/xdr4.h | 2 +- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 6870a2ecce3b..501a2c3a55e3 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -1982,40 +1982,44 @@ static __be32 nfsd4_decode_nl4_server(struct nfsd4_compoundargs *argp, static __be32 nfsd4_decode_copy(struct nfsd4_compoundargs *argp, struct nfsd4_copy *copy) { - DECODE_HEAD; struct nl4_server *ns_dummy; - int i, count; + u32 consecutive, i, count; + __be32 status; - status = nfsd4_decode_stateid(argp, ©->cp_src_stateid); + status = nfsd4_decode_stateid4(argp, ©->cp_src_stateid); if (status) return status; - status = nfsd4_decode_stateid(argp, ©->cp_dst_stateid); + status = nfsd4_decode_stateid4(argp, ©->cp_dst_stateid); if (status) return status; + if (xdr_stream_decode_u64(argp->xdr, ©->cp_src_pos) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, ©->cp_dst_pos) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, ©->cp_count) < 0) + return nfserr_bad_xdr; + /* ca_consecutive: we always do consecutive copies */ + if (xdr_stream_decode_u32(argp->xdr, &consecutive) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, ©->cp_synchronous) < 0) + return nfserr_bad_xdr; - READ_BUF(8 + 8 + 8 + 4 + 4 + 4); - p = xdr_decode_hyper(p, ©->cp_src_pos); - p = xdr_decode_hyper(p, ©->cp_dst_pos); - p = xdr_decode_hyper(p, ©->cp_count); - p++; /* ca_consecutive: we always do consecutive copies */ - copy->cp_synchronous = be32_to_cpup(p++); - - count = be32_to_cpup(p++); - + if (xdr_stream_decode_u32(argp->xdr, &count) < 0) + return nfserr_bad_xdr; copy->cp_intra = false; if (count == 0) { /* intra-server copy */ copy->cp_intra = true; - goto intra; + return nfs_ok; } - /* decode all the supplied server addresses but use first */ + /* decode all the supplied server addresses but use only the first */ status = nfsd4_decode_nl4_server(argp, ©->cp_src); if (status) return status; ns_dummy = kmalloc(sizeof(struct nl4_server), GFP_KERNEL); if (ns_dummy == NULL) - return nfserrno(-ENOMEM); + return nfserrno(-ENOMEM); /* XXX: jukebox? */ for (i = 0; i < count - 1; i++) { status = nfsd4_decode_nl4_server(argp, ns_dummy); if (status) { @@ -2024,9 +2028,8 @@ nfsd4_decode_copy(struct nfsd4_compoundargs *argp, struct nfsd4_copy *copy) } } kfree(ns_dummy); -intra: - DECODE_TAIL; + return nfs_ok; } static __be32 @@ -4781,7 +4784,7 @@ nfsd4_encode_copy(struct nfsd4_compoundres *resp, __be32 nfserr, __be32 *p; nfserr = nfsd42_encode_write_res(resp, ©->cp_res, - copy->cp_synchronous); + !!copy->cp_synchronous); if (nfserr) return nfserr; diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 232529bc1b79..facc5762bf83 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -554,7 +554,7 @@ struct nfsd4_copy { bool cp_intra; /* both */ - bool cp_synchronous; + u32 cp_synchronous; /* response */ struct nfsd42_write_res cp_res; From patchwork Mon Nov 23 20:10:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926355 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E899FC6379F for ; Mon, 23 Nov 2020 20:10:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A930520717 for ; Mon, 23 Nov 2020 20:10:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rWUpabHa" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729158AbgKWUKq (ORCPT ); Mon, 23 Nov 2020 15:10:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732324AbgKWUKn (ORCPT ); Mon, 23 Nov 2020 15:10:43 -0500 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDA70C0613CF for ; Mon, 23 Nov 2020 12:10:43 -0800 (PST) Received: by mail-qt1-x842.google.com with SMTP id e10so6901650qte.4 for ; Mon, 23 Nov 2020 12:10:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=3GpMEjrnKig0wjvJlpaKRWzsuz4tiNSE6tOiAQiPL9I=; b=rWUpabHaLh/WT+fEfzltU2D1x2gLwD3Lb21/dfVImaB+jM6lt9iHpwhKg2svhGWwwv RQHvE2spllWTn66tu7nC6bnKaT/m9hMKlhKCfGACHaLLDWH5uCl4eQdK4U8d9zCR8twl AbaUBC6g5kOUOfcl/PSSOGu975floWD+meuVMTHk3eH14zMYELHClqjkpQAVyIubzdLx 2egGSKWFrDldDnkQQNLpcXDOyPtVAxY2tk62tPUi5G1VeT+diQanQtW2k4N3x8bxTu96 mNtev1n9cKiySiMS28e3kstjs/yewMN+TAxBvORwy1mbkq6J3yT0O+iDUIjCNYCHaObe ELiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=3GpMEjrnKig0wjvJlpaKRWzsuz4tiNSE6tOiAQiPL9I=; b=cm+gojS0xgdXQRx9RnMjes7CusmVZdU63opm+OZt3alkoFhHavEN07WALNjYNeH/Nh gY87LFyOCSCj64rCxlFkfwf1vO3NgoMiFbp13h6AamM8F72v4RKU3/bnRhI7DQNUgA+p /NgU1yTiv+uoTtRZWGYv16MHhYvjhTTxmVs/ke/CNpsfKJBRCNtGaAG7jQ/MrQf+nKvL SBse25N4OYvKVUeAJXn9d2OWG7iX41FktRBPHrJojPq684W/IfxjpK/NKKDaaBxIX8eQ Gk1KWIW8zUmI+lorsG1Te+hIZciuvMtGsFkCJfHdjWkjJPQRlpynvAmKkyrSxIg2PwDj gChg== X-Gm-Message-State: AOAM533SgYe+18JvElmReLdoUD/62q41rwB9OE/JxYeBYhFy5DmyJbJB rqMGJgsuW6viLwtYaZnZ9j/V1IGRF+s= X-Google-Smtp-Source: ABdhPJxnHCLWM0yil166UUk072ScIYAIwNqWnJo3mJBntcWBupXMpcQOOhnxZycofFUaNVlpAiBrfQ== X-Received: by 2002:ac8:5304:: with SMTP id t4mr899400qtn.77.1606162242773; Mon, 23 Nov 2020 12:10:42 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id n9sm5516233qti.75.2020.11.23.12.10.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:10:42 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKAde1010512 for ; Mon, 23 Nov 2020 20:10:39 GMT Subject: [PATCH v3 76/85] NFSD: Replace READ* macros in nfsd4_decode_copy_notify() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:10:39 -0500 Message-ID: <160616223900.51996.7580313898551643348.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 501a2c3a55e3..196bb9bded3e 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2032,25 +2032,25 @@ nfsd4_decode_copy(struct nfsd4_compoundargs *argp, struct nfsd4_copy *copy) return nfs_ok; } -static __be32 -nfsd4_decode_offload_status(struct nfsd4_compoundargs *argp, - struct nfsd4_offload_status *os) -{ - return nfsd4_decode_stateid(argp, &os->stateid); -} - static __be32 nfsd4_decode_copy_notify(struct nfsd4_compoundargs *argp, struct nfsd4_copy_notify *cn) { __be32 status; - status = nfsd4_decode_stateid(argp, &cn->cpn_src_stateid); + status = nfsd4_decode_stateid4(argp, &cn->cpn_src_stateid); if (status) return status; return nfsd4_decode_nl4_server(argp, &cn->cpn_dst); } +static __be32 +nfsd4_decode_offload_status(struct nfsd4_compoundargs *argp, + struct nfsd4_offload_status *os) +{ + return nfsd4_decode_stateid(argp, &os->stateid); +} + static __be32 nfsd4_decode_seek(struct nfsd4_compoundargs *argp, struct nfsd4_seek *seek) { From patchwork Mon Nov 23 20:10:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7AEEC2D0E4 for ; Mon, 23 Nov 2020 20:11:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6BD4320724 for ; Mon, 23 Nov 2020 20:11:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hVIyC7lQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732345AbgKWUKt (ORCPT ); Mon, 23 Nov 2020 15:10:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732324AbgKWUKs (ORCPT ); Mon, 23 Nov 2020 15:10:48 -0500 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34112C0613CF for ; Mon, 23 Nov 2020 12:10:47 -0800 (PST) Received: by mail-qt1-x844.google.com with SMTP id 7so14389478qtp.1 for ; Mon, 23 Nov 2020 12:10:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=5nmiyjvYlkAqkvPs1LqcmGygRD8P6SMWptLydX8ja7M=; b=hVIyC7lQoaNShdG6SRmzodpzMZ8UU8fS+W4BaQ+mMwKbVSZZ3iu3Klh05AkZsr3VGI j9TewOs/2o41Wmnd0yCAQ/nfdCP94468FsPwSKt+ygNEPgc7VkT2vYZm3r+xfRqs5fjR P1IuESucH6+lamjfcFm3tYrpGMTh0FWX9gj/8FsphleHlr7lnmN6n7UlIjkKhkMXeV+z 75wvwh9GBrbD7I79zCuOR7M6gQ4gUJdSZTYp1Dz7RXfmzWwtgp4HkHMnuGIufP49ykuj b7iIMCY3RXgf6PnqWNlQDO+eA8LVSw/ACRmNd/45JBIekwd8ZVhy4B30LEeVx7S3zrHo 1F2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=5nmiyjvYlkAqkvPs1LqcmGygRD8P6SMWptLydX8ja7M=; b=JH9zRrSIhBejzvQkjDm6tW2CTtOkSrLsMemrq2IdaZr8lTVbzqvFBHmsyk4YZBJhVH 1PRLaE+Vu+OK9c/3NtnfgN1O6chXO6iI2fGh0SHU0CwOT+zlBWaWWM9TfzF6G1MwpMFe V4ShEmz8U5bfud2dNxJgnWMuG1S120BU1iU82ZFCUsUSx7VmF7rodeCam0pnH/ftIcbT 8puENJ4forNLRuhfwBYk1tGEoihiyLUPh+xve6WzPDfrF1ov2kIrBIz4jT8qMqhKhYWe yi7Z46QzNQU57ynUaLUPKK9ueHruBrUIzPGO6vROQoLHAEOX3PiVX6o71gExXQiM+qaU BrDQ== X-Gm-Message-State: AOAM530iloGD3PvHxFikwaeiyvDiYk3lM7b4RlPv881Wo7YFEe9QY8Ix 8fcC9cjqbuU5WfXjwMQh+tSBPCkj2Xw= X-Google-Smtp-Source: ABdhPJxgh1MVck517hvSfkOmqQ/ZZII2cSNNsARofydPCcRK47hOE7/W/7MGhfba9THJPiEe8FbPZQ== X-Received: by 2002:aed:2946:: with SMTP id s64mr876140qtd.73.1606162246131; Mon, 23 Nov 2020 12:10:46 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id g18sm10218787qtv.79.2020.11.23.12.10.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:10:45 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKAieH010515 for ; Mon, 23 Nov 2020 20:10:44 GMT Subject: [PATCH v3 77/85] NFSD: Replace READ* macros in nfsd4_decode_offload_status() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:10:44 -0500 Message-ID: <160616224429.51996.7231216723680030078.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 196bb9bded3e..0c8c2a3f389d 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2048,7 +2048,7 @@ static __be32 nfsd4_decode_offload_status(struct nfsd4_compoundargs *argp, struct nfsd4_offload_status *os) { - return nfsd4_decode_stateid(argp, &os->stateid); + return nfsd4_decode_stateid4(argp, &os->stateid); } static __be32 From patchwork Mon Nov 23 20:10:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D1F5C63777 for ; Mon, 23 Nov 2020 20:11:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D37CD20717 for ; Mon, 23 Nov 2020 20:11:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="k1Fpf3R4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726776AbgKWUKx (ORCPT ); Mon, 23 Nov 2020 15:10:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728738AbgKWUKw (ORCPT ); Mon, 23 Nov 2020 15:10:52 -0500 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2405CC0613CF for ; Mon, 23 Nov 2020 12:10:52 -0800 (PST) Received: by mail-qv1-xf43.google.com with SMTP id g19so9466916qvy.2 for ; Mon, 23 Nov 2020 12:10:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=/8/EwMyYU1c697kymcsdwy5Nls59q5He/x/uaLp6JHc=; b=k1Fpf3R4HyFU79klGVeSyIrebiBGv7VK2dIpcdSeODo9msK302YaGeNbAwN76NVfw5 BfxPE4vYCnLfyNyTPdnKfmL/tgeKSbTr2z902+Q1M6j0Tr6vaEjtM7ad2QW2hVpliNS6 13A2YbSnXT0Xg9h2cZUHlfcCmteQj4iLmMqhGJfAc2d2y6w2Yysz30pVXqKzZokENVy+ /v2zism4ayrKmTb7IA9lSlOzdTf1vWFIeXXATB9aQBbRV7Z2P4U2Ln1cKWgxL26sI9AC vnHjkBCZgNreiEUkqEJ7FKD0Jh7o+Z1piVsPEkrPD2G4TFbWeatHyBTuCQTas+br9PDk q2BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=/8/EwMyYU1c697kymcsdwy5Nls59q5He/x/uaLp6JHc=; b=XZuTwd/yJPHZ8jo+JD7kuOPwQ2UnabNJaZ+hZ2ozDR+cfJReoK87P/u3Z7eI3hNdW1 XKB/jv7KGd8yzJ8WH7P1m9oL44fhOyuwIj3CKC+TA9Mbm43aRkHEQr2sPI3i/W7r/Q31 0b+Vdg+9z3nXjpqZxHMOQaMr9y6dmsNwsmp2mz8HZ0Z8dpjDVQp6TkYONEM6LFWD5Sgd txK72WWSbp+l9y4M+L4Xgt6DQXuRWOiW+0u5G82+hTpST8VXIqWsyvrleYQ2k87D+Wur deeJzhkg9fu3usKYWFt77bTYgjil7UFUnMyH/HNfKp55pwvBxqLTtsJ+hPM6bklOKS9q Ge/Q== X-Gm-Message-State: AOAM5335W3nSKh4QQp/BwlKNgJnzdlU+CBJbiz+8KNEjGDevKenKzVKO lqan2CE1x/tvG7/yEdGaIwjOyOemaA0= X-Google-Smtp-Source: ABdhPJzWUBVU7E0aQYsdKQoqHyPC92iz3KS7wot8bg2taOyf2sDOdSbiXUKfK9hQZFtOIwrGNZlQFA== X-Received: by 2002:ad4:4b01:: with SMTP id r1mr1047186qvw.51.1606162250956; Mon, 23 Nov 2020 12:10:50 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id t51sm9719557qtb.11.2020.11.23.12.10.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:10:50 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKAnAZ010518 for ; Mon, 23 Nov 2020 20:10:49 GMT Subject: [PATCH v3 78/85] NFSD: Replace READ* macros in nfsd4_decode_seek() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:10:49 -0500 Message-ID: <160616224936.51996.10291659309003838910.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 0c8c2a3f389d..1401ca744d95 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2054,17 +2054,17 @@ nfsd4_decode_offload_status(struct nfsd4_compoundargs *argp, static __be32 nfsd4_decode_seek(struct nfsd4_compoundargs *argp, struct nfsd4_seek *seek) { - DECODE_HEAD; + __be32 status; - status = nfsd4_decode_stateid(argp, &seek->seek_stateid); + status = nfsd4_decode_stateid4(argp, &seek->seek_stateid); if (status) return status; + if (xdr_stream_decode_u64(argp->xdr, &seek->seek_offset) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u32(argp->xdr, &seek->seek_whence) < 0) + return nfserr_bad_xdr; - READ_BUF(8 + 4); - p = xdr_decode_hyper(p, &seek->seek_offset); - seek->seek_whence = be32_to_cpup(p); - - DECODE_TAIL; + return nfs_ok; } /* From patchwork Mon Nov 23 20:10:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926473 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11DEEC64E69 for ; Mon, 23 Nov 2020 20:11:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A612D20715 for ; Mon, 23 Nov 2020 20:11:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QxSXRT/k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729539AbgKWUK7 (ORCPT ); Mon, 23 Nov 2020 15:10:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728711AbgKWUK5 (ORCPT ); Mon, 23 Nov 2020 15:10:57 -0500 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E3A0C0613CF for ; Mon, 23 Nov 2020 12:10:57 -0800 (PST) Received: by mail-qt1-x843.google.com with SMTP id e60so5146806qtd.3 for ; Mon, 23 Nov 2020 12:10:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=aW7NIpPvrrUNJmbjwvgOufNyaxmC5aRPCQRaBdxds+w=; b=QxSXRT/kN/m1i4/pD4ecoDMa7Y42l9QQCwprhS+xyKqoxl5N8OYwr3N18+n4o2UcDY ju6jF2wTrP+R5k3WtjT+mApdBaizs0CR4+jTejv/nL192kd/W+bQlwUzNtRLHZ0qxGk0 MTCYSZRxQpll2b7vIvRbi2hpmxmnzCrdTZtz1MoVaB0ih+2jy3MRe5zE6sZWGX5ps8GT nRuCJaZoGI2VuBO5J7k1WPFcAlZivrJSTnmpOKvb8Toc92TZ7pTXhJ/ipKPNouna4VTx 8HE7Q0qXhbo3oRPLgF6cXrf7Qo/z0hoxDWGznOcTEAiHNrl+ITqgOLGts+Khud6opfO8 Kr6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=aW7NIpPvrrUNJmbjwvgOufNyaxmC5aRPCQRaBdxds+w=; b=rUZmGYoK4vkzO4GPUquY6PpyZZ3cxa6N0w5q2qW9au/mvwIz6VyeLoXcGPMywVbA2N zWnz51ZrIdTLmhrLX70I84sSA/CMGf4YOEd20ewf5yITPN/5mFe5xBdDKaEn+Oj/yY2I dqJAbHBcolaOIJXDh6pb64eazw7CnGg91pkCbr7JE5ZfAWCwqpTgUiUK3bt4fekcojuV NsCx1PjYtGph2IZYe7rwMCKuc7JPyd3bfRN46gOlggfgcDY7e/ypuvfmb8k2e5NHmu6+ GoCczZqOZgxDNwwldgmTXIcEG7RTRoEemSy3LVMTLapGcGIN5HFELF052zf2A55otAGf pWeg== X-Gm-Message-State: AOAM5312UEB5HgqthVLZEnIrzruM3FCPUzD0w7gT9J6FFh1uYifG7V7b iZYrkYJh2M5gVDfoY/HPJ47GfnE4Mtg= X-Google-Smtp-Source: ABdhPJxbRSqsmPTAitLDYv71bVtu33w7gdTU65/dDMfCaiylEgSDEUEE7K1mucDdiRs19G7ClcQZ2g== X-Received: by 2002:ac8:6f42:: with SMTP id n2mr909420qtv.17.1606162256101; Mon, 23 Nov 2020 12:10:56 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id z30sm10549096qtc.15.2020.11.23.12.10.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:10:55 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKAsu4010521 for ; Mon, 23 Nov 2020 20:10:54 GMT Subject: [PATCH v3 79/85] NFSD: Replace READ* macros in nfsd4_decode_clone() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:10:54 -0500 Message-ID: <160616225464.51996.16399846881165369712.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 52 +++++++++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 1401ca744d95..493168608815 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -575,18 +575,6 @@ nfsd4_decode_fattr4(struct nfsd4_compoundargs *argp, u32 *bmval, u32 bmlen, return nfs_ok; } -static __be32 -nfsd4_decode_stateid(struct nfsd4_compoundargs *argp, stateid_t *sid) -{ - DECODE_HEAD; - - READ_BUF(sizeof(stateid_t)); - sid->si_generation = be32_to_cpup(p++); - COPYMEM(&sid->si_opaque, sizeof(stateid_opaque_t)); - - DECODE_TAIL; -} - static __be32 nfsd4_decode_stateid4(struct nfsd4_compoundargs *argp, stateid_t *sid) { @@ -1919,25 +1907,6 @@ nfsd4_decode_fallocate(struct nfsd4_compoundargs *argp, return nfs_ok; } -static __be32 -nfsd4_decode_clone(struct nfsd4_compoundargs *argp, struct nfsd4_clone *clone) -{ - DECODE_HEAD; - - status = nfsd4_decode_stateid(argp, &clone->cl_src_stateid); - if (status) - return status; - status = nfsd4_decode_stateid(argp, &clone->cl_dst_stateid); - if (status) - return status; - - READ_BUF(8 + 8 + 8); - p = xdr_decode_hyper(p, &clone->cl_src_pos); - p = xdr_decode_hyper(p, &clone->cl_dst_pos); - p = xdr_decode_hyper(p, &clone->cl_count); - DECODE_TAIL; -} - static __be32 nfsd4_decode_nl4_server(struct nfsd4_compoundargs *argp, struct nl4_server *ns) { @@ -2067,6 +2036,27 @@ nfsd4_decode_seek(struct nfsd4_compoundargs *argp, struct nfsd4_seek *seek) return nfs_ok; } +static __be32 +nfsd4_decode_clone(struct nfsd4_compoundargs *argp, struct nfsd4_clone *clone) +{ + __be32 status; + + status = nfsd4_decode_stateid4(argp, &clone->cl_src_stateid); + if (status) + return status; + status = nfsd4_decode_stateid4(argp, &clone->cl_dst_stateid); + if (status) + return status; + if (xdr_stream_decode_u64(argp->xdr, &clone->cl_src_pos) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, &clone->cl_dst_pos) < 0) + return nfserr_bad_xdr; + if (xdr_stream_decode_u64(argp->xdr, &clone->cl_count) < 0) + return nfserr_bad_xdr; + + return nfs_ok; +} + /* * XDR data that is more than PAGE_SIZE in size is normally part of a * read or write. However, the size of extended attributes is limited From patchwork Mon Nov 23 20:10:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A373C6379F for ; Mon, 23 Nov 2020 20:11:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E19B82071E for ; Mon, 23 Nov 2020 20:11:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cI+H17p7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732512AbgKWULC (ORCPT ); Mon, 23 Nov 2020 15:11:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728786AbgKWULC (ORCPT ); Mon, 23 Nov 2020 15:11:02 -0500 Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 269A4C0613CF for ; Mon, 23 Nov 2020 12:11:02 -0800 (PST) Received: by mail-qv1-xf42.google.com with SMTP id g19so9467221qvy.2 for ; Mon, 23 Nov 2020 12:11:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=2RQb4Lm3ONR+NnOJ0hloeQG7iNuglTAlDV5e7dmPZxU=; b=cI+H17p7UAkgbd8Q3tpjZvjWl6vlVRFrCQ+219aienVnd/yRibsPzRUOY/FO88TzSn v38/vLy22iOXR2z0TVFhicipltRxnapmKiHZI22g/uFKsj9tzhOXsHbvAlAv9ILvTk7m vdd8TVqMLFdwHXAfcm5IciqoOrj9RE7/Vh/8GMeW5yGJharlGq/SzZEs81o1kU+CAjag F2UU8CrxueJo0+lOwX8kBP+YpqNVZAPbLRdR0KWyhcFlsnh2NbbT9JDZIwGjf7B8WJVF U25qrZHJE6ux3/eRl1XU8Z48iFMT0h8JpH7wV5X3SCcKhZymFa6uM+6FW4XPxz3oo/hw ktSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=2RQb4Lm3ONR+NnOJ0hloeQG7iNuglTAlDV5e7dmPZxU=; b=LOEXiCGfoicAiHVm2H6NUVGdUKMG8rhT80O+GMXj5JN+jJEKpw7XIK8K/xMj5Fz/vi hqHZRJ8AqO/DpqW/HsZcxCs6vkWoWNOrPWMn7HPHj6Gky/1BpJMo8l4kT37aU1yRijkU jzjF9LEuw/cjqFVGR1SC9cPuOrDC4uKSoBknS+Njv1UeQfIquHoCm9QZkhBMa2UVYre/ qEGxW4vMTaCLeY3wB+5pAyqjYfEYkHW8X3y2sSm8F2K2f4ykukO+2QMMAuNIZPf8gaAP rO2tUgft1rRbDz8TTraprw29hnCMFLcaWDDmaqV/M17u6MKMQdpa/4V5wJ2HnEQ8gomv tySg== X-Gm-Message-State: AOAM533skPWvD8IE3P713yWl2tIuCzjctZC+5+obrGRbTxb6ullVPU8j HsQ/8ZiFiTM6zBsbaVPq+tuCCFmn/Fo= X-Google-Smtp-Source: ABdhPJz3acAhECDcDemKrL0QHSlQRyYz0Qo7fQZRRwtqNUsv5hMraEfphVHX5/jc7rSlkfXvbUBqLw== X-Received: by 2002:a0c:9d07:: with SMTP id m7mr1111438qvf.5.1606162261115; Mon, 23 Nov 2020 12:11:01 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id h8sm6254141qka.117.2020.11.23.12.11.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:11:00 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKAxCT010524 for ; Mon, 23 Nov 2020 20:10:59 GMT Subject: [PATCH v3 80/85] NFSD: Replace READ* macros in nfsd4_decode_xattr_name() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:10:59 -0500 Message-ID: <160616225970.51996.11211965596963744857.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 493168608815..90068c32a566 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2117,25 +2117,22 @@ nfsd4_vbuf_from_vector(struct nfsd4_compoundargs *argp, struct xdr_buf *xdr, static __be32 nfsd4_decode_xattr_name(struct nfsd4_compoundargs *argp, char **namep) { - DECODE_HEAD; char *name, *sp, *dp; u32 namelen, cnt; + __be32 *p; - READ_BUF(4); - namelen = be32_to_cpup(p++); - + if (xdr_stream_decode_u32(argp->xdr, &namelen) < 0) + return nfserr_bad_xdr; if (namelen > (XATTR_NAME_MAX - XATTR_USER_PREFIX_LEN)) return nfserr_nametoolong; - if (namelen == 0) - goto xdr_error; - - READ_BUF(namelen); - + return nfserr_bad_xdr; + p = xdr_inline_decode(argp->xdr, namelen); + if (!p) + return nfserr_bad_xdr; name = svcxdr_tmpalloc(argp, namelen + XATTR_USER_PREFIX_LEN + 1); if (!name) return nfserr_jukebox; - memcpy(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN); /* @@ -2148,14 +2145,14 @@ nfsd4_decode_xattr_name(struct nfsd4_compoundargs *argp, char **namep) while (cnt-- > 0) { if (*sp == '\0') - goto xdr_error; + return nfserr_bad_xdr; *dp++ = *sp++; } *dp = '\0'; *namep = name; - DECODE_TAIL; + return nfs_ok; } /* From patchwork Mon Nov 23 20:11:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926477 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50663C64E7C for ; Mon, 23 Nov 2020 20:11:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EBCD220717 for ; Mon, 23 Nov 2020 20:11:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Qvauw+U9" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732531AbgKWULJ (ORCPT ); Mon, 23 Nov 2020 15:11:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728738AbgKWULI (ORCPT ); Mon, 23 Nov 2020 15:11:08 -0500 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81C53C0613CF for ; Mon, 23 Nov 2020 12:11:07 -0800 (PST) Received: by mail-qk1-x743.google.com with SMTP id h11so6674658qkl.4 for ; Mon, 23 Nov 2020 12:11:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=u66n5aUMhzsCE97i4gsrGV9OfwPKtnOH6hPiaybQXyE=; b=Qvauw+U9+TD0v4ZUhuzXqJtEMG5kGj+YXqoObWabwsZePrdViFOUIGOHK3YJweh+uQ 7K/vhYeRKiv3mYr5dy3Te4QpSvgtYhx93E7FIm+Mex8xrorP9MdM2ZDl3ftJAWtsgTB5 gY8CpOUPKmHysioC7nvvBiX/8EckIBatibXlLFuoNzzdsipKpKYHt//8YzgLIkqlZDrO pI5hGn1osiJBlJsOvgYO6i5EijrFRML40CqlXhwJILsXlN13q5AKpFDBmBkWEWEHKVda 5oWM+ePgky1vWZXRUey2A7qZhZAogCkwhQ07ucjlBnl6oZ5McueBTZFrRr6pYyNImKEi jtJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=u66n5aUMhzsCE97i4gsrGV9OfwPKtnOH6hPiaybQXyE=; b=hnlr26kUljrHE7TcDVKfTe12K6nnP4J65skGJ4rkzuFj6nQ+ZI+loeki/X4cWficwe WkYj/9slm8lnpFOxcIfdcS1Z9JN0dHsQDrqTeaKZ3pN4rHmZIjVUaf8ebbfNFkIfuI/l 0jDNJ7zbt9p3dfRhjH9fl6R9b68f8xCqRj5jSfDKeIfyptqzMnCgpKMukPPbuDhZBxnw z4tCcnPbg6xi9MmNTsMrPvP1Xw6C2s0n92J+j1i8ZA64vmZv5vjHZ59c0SzT2N+GwfmU ap8ohk4r3DyS3HbCJAulJC6XTa6gN75rIMMM3ty/PI/upGgQyfZ0VyGrh1gDO9fe7iJE sIlA== X-Gm-Message-State: AOAM530JnBRFPg+QpAQvlhjICoceaoBoa82cKaqcNu2PY6YWPGlzwH6z YevyWOltd208KGuh6IEaaLIQ0/deQSY= X-Google-Smtp-Source: ABdhPJy7DAMoBFHwS0NuuCdAVepW2p+SOjSJMUpBeE0cWPdwupTBPCLGZ3XfkGsdmwVcneHxA+aagA== X-Received: by 2002:a37:8ec5:: with SMTP id q188mr1321157qkd.85.1606162266485; Mon, 23 Nov 2020 12:11:06 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id k188sm10736649qkd.98.2020.11.23.12.11.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:11:05 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKB4n7010527 for ; Mon, 23 Nov 2020 20:11:04 GMT Subject: [PATCH v3 81/85] NFSD: Replace READ* macros in nfsd4_decode_setxattr() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:11:04 -0500 Message-ID: <160616226477.51996.17111388682770526823.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 90068c32a566..2f47fef17b59 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2184,11 +2184,11 @@ static __be32 nfsd4_decode_setxattr(struct nfsd4_compoundargs *argp, struct nfsd4_setxattr *setxattr) { - DECODE_HEAD; u32 flags, maxcount, size; + __be32 status; - READ_BUF(4); - flags = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &flags) < 0) + return nfserr_bad_xdr; if (flags > SETXATTR4_REPLACE) return nfserr_inval; @@ -2201,8 +2201,8 @@ nfsd4_decode_setxattr(struct nfsd4_compoundargs *argp, maxcount = svc_max_payload(argp->rqstp); maxcount = min_t(u32, XATTR_SIZE_MAX, maxcount); - READ_BUF(4); - size = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &size) < 0) + return nfserr_bad_xdr; if (size > maxcount) return nfserr_xattr2big; @@ -2211,12 +2211,12 @@ nfsd4_decode_setxattr(struct nfsd4_compoundargs *argp, struct xdr_buf payload; if (!xdr_stream_subsegment(argp->xdr, &payload, size)) - goto xdr_error; + return nfserr_bad_xdr; status = nfsd4_vbuf_from_vector(argp, &payload, &setxattr->setxa_buf, size); } - DECODE_TAIL; + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:11:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926481 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50106C8300E for ; Mon, 23 Nov 2020 20:11:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DFFAC20717 for ; Mon, 23 Nov 2020 20:11:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ci6TfQ0v" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732701AbgKWULW (ORCPT ); Mon, 23 Nov 2020 15:11:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732613AbgKWULO (ORCPT ); Mon, 23 Nov 2020 15:11:14 -0500 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 035F1C0613CF for ; Mon, 23 Nov 2020 12:11:13 -0800 (PST) Received: by mail-qt1-x844.google.com with SMTP id g17so14381578qts.5 for ; Mon, 23 Nov 2020 12:11:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=4UEevN2uridC4rd22mTHJg89O0CJblgI8EsCgqcRg08=; b=Ci6TfQ0vrr7gKAnADbx4ZXbZY8vPXrLW0YaLk+8na3omc440SvaxNxbvAzx8cMgKmP v8lkS/eajO3avy+I/R32RF5Va58SYiLspYYH8XZiKbITEjfE1USUBrq09EMZhXaE68jN owMh0GKyCTb2tTyq1nNc0DfaFQ0cY7d/3JNNmqKwvslj5Zp2FOtFKCnI5V9yJRY4Uk44 /w4cINLBU7NOpTHAV6Qzp7JP3zjxOTmC15bWIATm3Ya2xXssm+ygMQhqYLQnE+lUc+tE b+tmu1L7C3m3HxJTmd5Mgv+oqwEZYmooumn+B0yvPNbW7TOT7mQL6QCHIguZsK4PiTfo hSZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=4UEevN2uridC4rd22mTHJg89O0CJblgI8EsCgqcRg08=; b=Js/CAcq/xAt/yTCJxFRodd0+BVbVtMJuyb1lxXlgGq/ittp1NrZVDT2Iot6lx7LOLZ fMmr5QEh9nUDKexaRLuIHX/cO8VCv8P47ll5aOVvehFSw5RD89JG6SuaQeylFPTUzU3Q MFfnQwZvcmTFP7COjl8rEKscsDPVGEWfE+9Fr0mcJTorjoHXccO++tLpkAEPauhmRV/G ZGgkOWtqnZAufrHKYbp6UXYSFOipiT+Pj+6lxn7mLGpQiZO3E0Qi/g2VSq6nSCBkHFsH 0+xP+W4Ui/apGIIleCgu5ADcwFuwCWwA14Z0TNdKAe+V/xY7Yat8xFraGJcCQmT+yz4c 1i5g== X-Gm-Message-State: AOAM5319QctNO/aCWyx8NjmQNkIsDDGs5suAlO1+YggwWXSHHP5fPhcI rXBmhSrez1P7fHiOIJUgUYLLLESUHbI= X-Google-Smtp-Source: ABdhPJyw5RsdtR5h0niILALRWz14WNYaE5sZLaTNuANUODNOexy4qP4rtAy1p59h+H97qumkU3zf5w== X-Received: by 2002:aed:22c5:: with SMTP id q5mr930109qtc.234.1606162271911; Mon, 23 Nov 2020 12:11:11 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id 199sm10562167qkm.62.2020.11.23.12.11.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:11:11 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKBAuO010530 for ; Mon, 23 Nov 2020 20:11:10 GMT Subject: [PATCH v3 82/85] NFSD: Replace READ* macros in nfsd4_decode_listxattrs() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:11:10 -0500 Message-ID: <160616227012.51996.1314752989338362514.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 2f47fef17b59..8163c529e497 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2223,11 +2223,10 @@ static __be32 nfsd4_decode_listxattrs(struct nfsd4_compoundargs *argp, struct nfsd4_listxattrs *listxattrs) { - DECODE_HEAD; u32 maxcount; - READ_BUF(12); - p = xdr_decode_hyper(p, &listxattrs->lsxa_cookie); + if (xdr_stream_decode_u64(argp->xdr, &listxattrs->lsxa_cookie) < 0) + return nfserr_bad_xdr; /* * If the cookie is too large to have even one user.x attribute @@ -2237,7 +2236,8 @@ nfsd4_decode_listxattrs(struct nfsd4_compoundargs *argp, (XATTR_LIST_MAX / (XATTR_USER_PREFIX_LEN + 2))) return nfserr_badcookie; - maxcount = be32_to_cpup(p++); + if (xdr_stream_decode_u32(argp->xdr, &maxcount) < 0) + return nfserr_bad_xdr; if (maxcount < 8) /* Always need at least 2 words (length and one character) */ return nfserr_inval; @@ -2245,7 +2245,7 @@ nfsd4_decode_listxattrs(struct nfsd4_compoundargs *argp, maxcount = min(maxcount, svc_max_payload(argp->rqstp)); listxattrs->lsxa_maxcount = maxcount; - DECODE_TAIL; + return nfs_ok; } static __be32 From patchwork Mon Nov 23 20:11:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926479 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24C4DC71156 for ; Mon, 23 Nov 2020 20:11:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C119120717 for ; Mon, 23 Nov 2020 20:11:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DpBF08nC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730034AbgKWULU (ORCPT ); Mon, 23 Nov 2020 15:11:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728805AbgKWULS (ORCPT ); Mon, 23 Nov 2020 15:11:18 -0500 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30F08C0613CF for ; Mon, 23 Nov 2020 12:11:18 -0800 (PST) Received: by mail-qv1-xf41.google.com with SMTP id 9so5250361qvk.9 for ; Mon, 23 Nov 2020 12:11:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=JchyUwTBcuGJcQ6GG8x1ugIgrFCQiEFYJIn5kih66pk=; b=DpBF08nCv8AJvsx6yrNH8hWUcmQ+scbPWVAj1RefX5bUKuaxjt+i7oJb9465lw3k4T FUIpBLQYt81Ss3IoEhsm3KEovlbqFETfuOtR7DqxMfnhGhKpweJHYbQ7ib3zUuYHcWoF JMRvXAH2geK5M5/l0mypq21BtB9gc/AA0+E7bDt7dSptkOSj+tbG1jcvZieuNyAM2RHm 28JoMR7IudY8VVwyI4+8cvTRKreM84Oz8mWjNxf3CwAdfIZDnGVgiaKsrt0heS5mNurK gXrtalPpTmJt1V8twNUViu8FIALhmCF1imOv+/iGnhbLgHpydE9jdrR7ZQwQUGLdKniF yuCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=JchyUwTBcuGJcQ6GG8x1ugIgrFCQiEFYJIn5kih66pk=; b=av5bfXyioGtsz5Qj8B1jsT7zGI2N8Ns6cQhXMujLWLqUzbMLjB/JVnT8A1ImsxYjb1 gUVfby+7NA8vEX47xjRWR9oRllOAZHXKzwoeplit5cWl+D7xCo17mppUYqg2we4WqPTW BbMEP5WG6UCsOLnoel/+osyQ8fA9hzL0CBHC8tiBlK6Kye2S7rcELltHOLEJfLcZMgcA O43oJQJqGqPX6T3r8Dwl3pr6FfEYGMRsGTEKE2kSw7bgmmsyB+n5HGeNtCVzduNw2XSZ exuj7jx5HMVz7YrydwcEvxmr7sPYSbjz9ct207jK/v6+U1XJMQyIeOkpTMqqMQKOBBUY 5Xsg== X-Gm-Message-State: AOAM5332mK13r4TuduzHEKGCfo9vqzZXLE15KX3VoOB5ZmjsAuVhJsYd wIkNbYlphWHJS8Pz+qrNZgozNIQexUA= X-Google-Smtp-Source: ABdhPJyE/99I8qSrLSZ6SMffGv1WbGdV4raDw20+kGk0Qh7Bs37YmiSEsJyU7hvswNFxRmGuYkugRQ== X-Received: by 2002:a0c:90a1:: with SMTP id p30mr1203070qvp.38.1606162277136; Mon, 23 Nov 2020 12:11:17 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id b18sm8830232qtr.84.2020.11.23.12.11.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:11:16 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKBF5O010533 for ; Mon, 23 Nov 2020 20:11:15 GMT Subject: [PATCH v3 83/85] NFSD: Make nfsd4_ops::opnum a u32 From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:11:15 -0500 Message-ID: <160616227547.51996.3683957349728629041.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Avoid passing a "pointer to int" argument to xdr_stream_decode_u32. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4proc.c | 2 +- fs/nfsd/nfs4xdr.c | 7 +++---- fs/nfsd/xdr4.h | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 56d074a6cb31..73e717609213 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -3282,7 +3282,7 @@ int nfsd4_max_reply(struct svc_rqst *rqstp, struct nfsd4_op *op) void warn_on_nonidempotent_op(struct nfsd4_op *op) { if (OPDESC(op)->op_flags & OP_MODIFIES_SOMETHING) { - pr_err("unable to encode reply to nonidempotent op %d (%s)\n", + pr_err("unable to encode reply to nonidempotent op %u (%s)\n", op->opnum, nfsd4_op_name(op->opnum)); WARN_ON_ONCE(1); } diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 8163c529e497..9dc67cf58684 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2419,9 +2419,8 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) op = &argp->ops[i]; op->replay = NULL; - READ_BUF(4); - op->opnum = be32_to_cpup(p++); - + if (xdr_stream_decode_u32(argp->xdr, &op->opnum) < 0) + return nfserr_bad_xdr; if (nfsd4_opnum_in_range(argp, op)) { op->status = nfsd4_dec_ops[op->opnum](argp, &op->u); if (op->status != nfs_ok) @@ -5378,7 +5377,7 @@ nfsd4_encode_operation(struct nfsd4_compoundres *resp, struct nfsd4_op *op) if (op->status && opdesc && !(opdesc->op_flags & OP_NONTRIVIAL_ERROR_ENCODE)) goto status; - BUG_ON(op->opnum < 0 || op->opnum >= ARRAY_SIZE(nfsd4_enc_ops) || + BUG_ON(op->opnum >= ARRAY_SIZE(nfsd4_enc_ops) || !nfsd4_enc_ops[op->opnum]); encoder = nfsd4_enc_ops[op->opnum]; op->status = encoder(resp, op->status, &op->u); diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index facc5762bf83..2c31f3a7d7c7 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -615,7 +615,7 @@ struct nfsd4_copy_notify { }; struct nfsd4_op { - int opnum; + u32 opnum; const struct nfsd4_operation * opdesc; __be32 status; union nfsd4_op_u { From patchwork Mon Nov 23 20:11:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926483 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F051DC8300C for ; Mon, 23 Nov 2020 20:11:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF58E20715 for ; Mon, 23 Nov 2020 20:11:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hmLl0qSN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728805AbgKWULZ (ORCPT ); Mon, 23 Nov 2020 15:11:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732692AbgKWULX (ORCPT ); Mon, 23 Nov 2020 15:11:23 -0500 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD800C0613CF for ; Mon, 23 Nov 2020 12:11:23 -0800 (PST) Received: by mail-qt1-x841.google.com with SMTP id g17so14382136qts.5 for ; Mon, 23 Nov 2020 12:11:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=AEIvx+SfYdCWj4v4dAdxH+w+eUkq4jQPWI0bSgr0+rk=; b=hmLl0qSNrjDOIV83+hRtxnWTJEWkrVcusCytus3erCHh6vkNSlDigYSuq91500lr6N nwm31ME9QvdtLuZpA6BniWbF5wdDqProguS3pqdA/7dQA5ptYORCikVCu8XuVks+784w 7Vilu93J0jytjzvdRnu6Mdyh9fsph/Vedu/Hkx0RtD30ubfskSl4/rKWSmNFXLJBTYXS DLxWQLTOw2rC2ycu7zUVOIx0Tw+0v9P/WYf2Wn0yNNyse14omcLNLvQ9pXu2qMuZcnpd 6o9HGqAw8zhkNEcEP7v5FYl18dqyxxiTZyWFQ0OfC7lzgHS1aR/Tk6bIeovJECUlFUtV XHXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=AEIvx+SfYdCWj4v4dAdxH+w+eUkq4jQPWI0bSgr0+rk=; b=PpKV1AvJxAOrDShMrSFIGLDZQh5wVAbIL63vJAC3/q0S4p2RsLw5OwinhBdZtbDO50 DGVyZPs54wHT3h6ukqCjH3ZfzXwhVSNaWIogZ2HzYRHsLBVGbyBljbEXErDhJGj/8NLb vaZQovDAd5cnhXHIOtBbgT+niGvU2ISo4NaWuEg18VfYxkqn9pZ7Z2NlPsHDnfve+K1i /sOKR6P7xzk8ABiHmpJEeTpLb/NHOSqx97iLJK6YZsEyA5giLRkTjioXbC8ItMNNWxEA NveG0CLQwk890Nj+aC8WnIdq8YY/SWF3PpC+CBr2BvQs/c5j1hSn976VMSoD1/WaEJkN iXAA== X-Gm-Message-State: AOAM533xZdn6kNlZqfVx5CPvyuULSHAxMqdOLUamOlNVlXHErrr6iMaR vz8eTOTArKIWrcXT0p7uN/gGWKl56BQ= X-Google-Smtp-Source: ABdhPJyAiBNzclYZIRYGWAlmwuSslWr8mMSw0S9Z3y/oKY6RIj+2tVFZ4XpE/tpbAHIbRvYrSoDe0g== X-Received: by 2002:ac8:594c:: with SMTP id 12mr934434qtz.224.1606162282561; Mon, 23 Nov 2020 12:11:22 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id w21sm3203082qki.6.2020.11.23.12.11.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:11:21 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKBKTO010536 for ; Mon, 23 Nov 2020 20:11:20 GMT Subject: [PATCH v3 84/85] NFSD: Replace READ* macros in nfsd4_decode_compound() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:11:20 -0500 Message-ID: <160616228082.51996.11001416060770878467.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org And clean-up: Now that we have removed the DECODE_TAIL macro from nfsd4_decode_compound(), we observe that there's no benefit for nfsd4_decode_compound() to return nfs_ok or nfserr_bad_xdr only to have its sole caller convert those values to one or zero, respectively. Have nfsd4_decode_compound() return 1/0 instead. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 69 ++++++++++++++++++++++------------------------------- 1 file changed, 29 insertions(+), 40 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 9dc67cf58684..1e81c8e1e98a 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -186,28 +186,6 @@ svcxdr_dupstr(struct nfsd4_compoundargs *argp, void *buf, u32 len) return p; } -/** - * savemem - duplicate a chunk of memory for later processing - * @argp: NFSv4 compound argument structure to be freed with - * @p: pointer to be duplicated - * @nbytes: length to be duplicated - * - * Returns a pointer to a copy of @nbytes bytes of memory at @p - * that are preserved until processing of the NFSv4 compound - * operation described by @argp finishes. - */ -static char *savemem(struct nfsd4_compoundargs *argp, __be32 *p, int nbytes) -{ - void *ret; - - ret = svcxdr_tmpalloc(argp, nbytes); - if (!ret) - return NULL; - memcpy(ret, p, nbytes); - return ret; -} - - /* * NFSv4 basic data type decoders */ @@ -2372,43 +2350,54 @@ nfsd4_opnum_in_range(struct nfsd4_compoundargs *argp, struct nfsd4_op *op) return true; } -static __be32 +static int nfsd4_decode_compound(struct nfsd4_compoundargs *argp) { - DECODE_HEAD; struct nfsd4_op *op; bool cachethis = false; int auth_slack= argp->rqstp->rq_auth_slack; int max_reply = auth_slack + 8; /* opcnt, status */ int readcount = 0; int readbytes = 0; + __be32 *p; int i; - READ_BUF(4); - argp->taglen = be32_to_cpup(p++); - READ_BUF(argp->taglen); - SAVEMEM(argp->tag, argp->taglen); - READ_BUF(8); - argp->minorversion = be32_to_cpup(p++); - argp->opcnt = be32_to_cpup(p++); - max_reply += 4 + (XDR_QUADLEN(argp->taglen) << 2); - - if (argp->taglen > NFSD4_MAX_TAGLEN) - goto xdr_error; + if (xdr_stream_decode_u32(argp->xdr, &argp->taglen) < 0) + return 0; + max_reply += XDR_UNIT; + argp->tag = NULL; + if (unlikely(argp->taglen)) { + if (argp->taglen > NFSD4_MAX_TAGLEN) + return 0; + p = xdr_inline_decode(argp->xdr, argp->taglen); + if (!p) + return 0; + argp->tag = svcxdr_tmpalloc(argp, argp->taglen); + if (!argp->tag) + return 0; + memcpy(argp->tag, p, argp->taglen); + max_reply += xdr_align_size(argp->taglen); + } + + if (xdr_stream_decode_u32(argp->xdr, &argp->minorversion) < 0) + return 0; + if (xdr_stream_decode_u32(argp->xdr, &argp->opcnt) < 0) + return 0; + /* * NFS4ERR_RESOURCE is a more helpful error than GARBAGE_ARGS * here, so we return success at the xdr level so that * nfsd4_proc can handle this is an NFS-level error. */ if (argp->opcnt > NFSD_MAX_OPS_PER_COMPOUND) - return 0; + return 1; if (argp->opcnt > ARRAY_SIZE(argp->iops)) { argp->ops = kzalloc(argp->opcnt * sizeof(*argp->ops), GFP_KERNEL); if (!argp->ops) { argp->ops = argp->iops; dprintk("nfsd: couldn't allocate room for COMPOUND\n"); - goto xdr_error; + return 0; } } @@ -2420,7 +2409,7 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) op->replay = NULL; if (xdr_stream_decode_u32(argp->xdr, &op->opnum) < 0) - return nfserr_bad_xdr; + return 0; if (nfsd4_opnum_in_range(argp, op)) { op->status = nfsd4_dec_ops[op->opnum](argp, &op->u); if (op->status != nfs_ok) @@ -2467,7 +2456,7 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) if (readcount > 1 || max_reply > PAGE_SIZE - auth_slack) clear_bit(RQ_SPLICE_OK, &argp->rqstp->rq_flags); - DECODE_TAIL; + return 1; } static __be32 *encode_change(__be32 *p, struct kstat *stat, struct inode *inode, @@ -5479,7 +5468,7 @@ nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p) args->ops = args->iops; args->rqstp = rqstp; - return !nfsd4_decode_compound(args); + return nfsd4_decode_compound(args); } int From patchwork Mon Nov 23 20:11:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 11926485 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06DACC63697 for ; Mon, 23 Nov 2020 20:11:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F50E20715 for ; Mon, 23 Nov 2020 20:11:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ari6p6NY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732643AbgKWUL3 (ORCPT ); Mon, 23 Nov 2020 15:11:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732750AbgKWUL3 (ORCPT ); Mon, 23 Nov 2020 15:11:29 -0500 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35F11C0613CF for ; Mon, 23 Nov 2020 12:11:29 -0800 (PST) Received: by mail-qk1-x743.google.com with SMTP id v143so18276967qkb.2 for ; Mon, 23 Nov 2020 12:11:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:from:to:date:message-id:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=Mmvlka5gfdV0+lyx25y6g02ZkCluirzUtz5sI79OE0c=; b=ari6p6NYQWUwM5wQ4P1Q4hc0+Xr4ZKEkAAf09t2bHLfJen5iwB+j/51fMqIvMfJ2pk IDzC83b/EJ5mHWEUJFWZ8WjuwJcawaPEt0IxzS+xxbsacS51fMB3h50UV+xt19QnMnUb ZGWaX+ahyCRrXTw3O9ZYggiKyBMAGVFftjYRXoYzAPakYSRzZC5I7UohuffS0RQv2HnR ysVmXRvMh7R1/Ay1bKp43yH2OMHdb17chAFsfxxItaZqnld5s5/Bn+SnqhbK4JKZAHqM lvcHoBG79re3x45fbapXuU/vijQiBnP3A66IXuOm3FJ2T1rpQ3GYT1qyMotCCXqnHshq uVvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:from:to:date:message-id :in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=Mmvlka5gfdV0+lyx25y6g02ZkCluirzUtz5sI79OE0c=; b=DcMnY2YyHeN9ng74KKR6edwe4UpieQVmUmiZrKXuYxHeJ0nsNV4agQzt1D+8pKrWwh y9JJpCt2T3HZDeK9aHB3zTFiooNg9HXf+Eu7zoTPBZz8axlM7sGZZVC+iXQw59Lsy47k 8FXluvhvqmkORZZmDpci9THl9uJXgr0EIPPoKs36l6CzUBR6CLjifY+QD5BwI+dWi55u a65yd+AbZ9Vz5mhC8Cf8R8Y/oksZG2+8UWTw5K6U7BzEZtmKZQW5y8mvemyMnDJvkRrT Dj6wsc8fnInvinqaPFSjcMTWM6/fgZC2j0WR+59g0NaX79fY8IcNUZmRtnueu0txmhdj AvXQ== X-Gm-Message-State: AOAM530ffiKVUJpqDAwEevrbW5If38TkF8Vh1NZOanWCVF6V3CO2kOes W5C2X7o5nqygvACx1t9tpHUlfJeLgKU= X-Google-Smtp-Source: ABdhPJyOYSKnwfBsmE3e23c8qPFf2eU+GcigCuvE9urfw8cJLjVw8iSsE78eNxDzWbc1WN1OwmZweQ== X-Received: by 2002:a37:6c06:: with SMTP id h6mr1274684qkc.288.1606162288103; Mon, 23 Nov 2020 12:11:28 -0800 (PST) Received: from gateway.1015granger.net (c-68-61-232-219.hsd1.mi.comcast.net. [68.61.232.219]) by smtp.gmail.com with ESMTPSA id m25sm10453795qka.107.2020.11.23.12.11.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Nov 2020 12:11:27 -0800 (PST) Sender: Chuck Lever Received: from klimt.1015granger.net (klimt.1015granger.net [192.168.1.55]) by gateway.1015granger.net (8.14.7/8.14.7) with ESMTP id 0ANKBQTV010539 for ; Mon, 23 Nov 2020 20:11:26 GMT Subject: [PATCH v3 85/85] NFSD: Remove macros that are no longer used From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 23 Nov 2020 15:11:26 -0500 Message-ID: <160616228617.51996.12808577536167674350.stgit@klimt.1015granger.net> In-Reply-To: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> References: <160616177104.51996.14915419165992024951.stgit@klimt.1015granger.net> User-Agent: StGit/0.23-29-ga622f1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Now that all the NFSv4 decoder functions have been converted to make direct calls to the xdr helpers, remove the unused C macros. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 40 ---------------------------------------- fs/nfsd/xdr4.h | 9 --------- 2 files changed, 49 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 1e81c8e1e98a..6a2d78be58ad 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -102,45 +102,6 @@ check_filename(char *str, int len) return 0; } -#define DECODE_HEAD \ - __be32 *p; \ - __be32 status -#define DECODE_TAIL \ - status = 0; \ -out: \ - return status; \ -xdr_error: \ - dprintk("NFSD: xdr error (%s:%d)\n", \ - __FILE__, __LINE__); \ - status = nfserr_bad_xdr; \ - goto out - -#define READMEM(x,nbytes) do { \ - x = (char *)p; \ - p += XDR_QUADLEN(nbytes); \ -} while (0) -#define SAVEMEM(x,nbytes) do { \ - if (!(x = (p==argp->tmp || p == argp->tmpp) ? \ - savemem(argp, p, nbytes) : \ - (char *)p)) { \ - dprintk("NFSD: xdr error (%s:%d)\n", \ - __FILE__, __LINE__); \ - goto xdr_error; \ - } \ - p += XDR_QUADLEN(nbytes); \ -} while (0) -#define COPYMEM(x,nbytes) do { \ - memcpy((x), p, nbytes); \ - p += XDR_QUADLEN(nbytes); \ -} while (0) -#define READ_BUF(nbytes) \ - do { \ - p = xdr_inline_decode(argp->xdr,\ - nbytes); \ - if (!p) \ - goto xdr_error; \ - } while (0) - static int zero_clientid(clientid_t *clid) { return (clid->cl_boot == 0) && (clid->cl_id == 0); @@ -5461,7 +5422,6 @@ nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p) struct nfsd4_compoundargs *args = rqstp->rq_argp; /* svcxdr_tmp_alloc */ - args->tmpp = NULL; args->to_free = NULL; args->xdr = &rqstp->rq_xdr_stream; diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 2c31f3a7d7c7..e12fbe382e3f 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h @@ -386,13 +386,6 @@ struct nfsd4_setclientid_confirm { nfs4_verifier sc_confirm; }; -struct nfsd4_saved_compoundargs { - __be32 *p; - __be32 *end; - int pagelen; - struct page **pagelist; -}; - struct nfsd4_test_stateid_id { __be32 ts_id_status; stateid_t ts_id_stateid; @@ -696,8 +689,6 @@ struct svcxdr_tmpbuf { struct nfsd4_compoundargs { /* scratch variables for XDR decode */ - __be32 tmp[8]; - __be32 * tmpp; struct xdr_stream *xdr; struct svcxdr_tmpbuf *to_free; struct svc_rqst *rqstp;