From patchwork Tue Jan 5 15:29:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999249 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 161C0C433E9 for ; Tue, 5 Jan 2021 15:30:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0CBD22BE8 for ; Tue, 5 Jan 2021 15:30:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726789AbhAEPab (ORCPT ); Tue, 5 Jan 2021 10:30:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726177AbhAEPaa (ORCPT ); Tue, 5 Jan 2021 10:30:30 -0500 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B04FC061574 for ; Tue, 5 Jan 2021 07:29:50 -0800 (PST) Received: by mail-qt1-x836.google.com with SMTP id g24so21029392qtq.12 for ; Tue, 05 Jan 2021 07:29: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=5N4FTn+TgpeoEyVCAU7XSKYvnvhJ/G4lnNXpgKpd1tM=; b=u59RGBEytHUWMc5xY3sTMhjQE6LP7OivOh67YIU46DZto1G5whSRCL2eMEMdu1R76F S7fpeUyLthAa4jIHq48Me1hZ4X8Q1vzgFqu9kBwV3lI21rSMVdCAyUdypBtFZt1MM4tW A+UR0xAj5+hIoz1AFcOji/pcgm8fFezRDjC5LJ0t0x7mYo15cNoOZA+pqQcus6zOW6A3 TrlP44t0Pdx7GEF/SfTESh2KuaWuu8P8eSIFc3fn2VTQrRPBDZUILSgxYqdTN281dNIG lFJV0YDn3mKgL/qQEgQXXxdXHlLh2HQUeiIclrX60pSPkqdGFuOu0OfKIo9GkdMQRGWm 3vFw== 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=5N4FTn+TgpeoEyVCAU7XSKYvnvhJ/G4lnNXpgKpd1tM=; b=FW22XSxR5JNN7R/MKK8nPW+H/sKS18FHyii1dpFxm2v7LzWq0mzWDSLVLhcVqnhfJE SqEkSJYf/kZcCPXBSCcpmXgCQM96gJDvzcd9MzPCitb69CfHx1d3wyUJE2wzcuJA8peN Ky2WF3X5OrBNlhJE9s+t8itqx5yQOtg+UeTucfw8Qsbbc3C89pbGjl4/WQRuKxDrgeZv BF6Kos/AJ8MOHkM3xjJOTHFjL79cYe8BQjcWO2pHaAQmwSHznFW7twf3AQ6bM9FGZ+md EeCOv9PMOMzkoWOYMVILrbONr5ATEjDkBe+nV5X9cPij59KIFLbcdqFRwte3uWh2nbGC LKqQ== X-Gm-Message-State: AOAM533H0s3dfW1uOPVaj3bU3hS+G4i5TBG1X13bdvGYxcafWnB9i+gv hAOn0difk+qVPR0kDKFLAOpAjcCa6g4= X-Google-Smtp-Source: ABdhPJzxAQNqTO6yHeZpfFntG4JZ8436qQ0xNyrcgLclSiD7sNgDnzOxLc4IYGhHczLXfK+3vUqR0A== X-Received: by 2002:aed:2ae2:: with SMTP id t89mr75408qtd.82.1609860588723; Tue, 05 Jan 2021 07:29: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 70sm166705qkk.10.2021.01.05.07.29.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:29: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 105FTkwo020814 for ; Tue, 5 Jan 2021 15:29:46 GMT Subject: [PATCH v1 01/42] SUNRPC: Make trace_svc_process() display the RPC procedure symbolically From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:29:46 -0500 Message-ID: <160986058682.5532.8737122728649327044.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 The next few patches will employ these strings to help make server- side trace logs more human-readable. A similar technique is already in use in kernel RPC client code. Signed-off-by: Chuck Lever --- fs/lockd/svc4proc.c | 24 ++++++++++++++++++++++++ fs/lockd/svcproc.c | 24 ++++++++++++++++++++++++ fs/nfs/callback_xdr.c | 2 ++ fs/nfsd/nfs2acl.c | 5 +++++ fs/nfsd/nfs3acl.c | 3 +++ fs/nfsd/nfs3proc.c | 22 ++++++++++++++++++++++ fs/nfsd/nfs4proc.c | 2 ++ fs/nfsd/nfsproc.c | 18 ++++++++++++++++++ include/linux/sunrpc/svc.h | 1 + 9 files changed, 101 insertions(+) diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c index fa41dda39925..4c10fb5138f1 100644 --- a/fs/lockd/svc4proc.c +++ b/fs/lockd/svc4proc.c @@ -512,6 +512,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_void), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "NULL", }, [NLMPROC_TEST] = { .pc_func = nlm4svc_proc_test, @@ -520,6 +521,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St+2+No+Rg, + .pc_name = "TEST", }, [NLMPROC_LOCK] = { .pc_func = nlm4svc_proc_lock, @@ -528,6 +530,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St, + .pc_name = "LOCK", }, [NLMPROC_CANCEL] = { .pc_func = nlm4svc_proc_cancel, @@ -536,6 +539,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St, + .pc_name = "CANCEL", }, [NLMPROC_UNLOCK] = { .pc_func = nlm4svc_proc_unlock, @@ -544,6 +548,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St, + .pc_name = "UNLOCK", }, [NLMPROC_GRANTED] = { .pc_func = nlm4svc_proc_granted, @@ -552,6 +557,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St, + .pc_name = "GRANTED", }, [NLMPROC_TEST_MSG] = { .pc_func = nlm4svc_proc_test_msg, @@ -560,6 +566,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "TEST_MSG", }, [NLMPROC_LOCK_MSG] = { .pc_func = nlm4svc_proc_lock_msg, @@ -568,6 +575,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "LOCK_MSG", }, [NLMPROC_CANCEL_MSG] = { .pc_func = nlm4svc_proc_cancel_msg, @@ -576,6 +584,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "CANCEL_MSG", }, [NLMPROC_UNLOCK_MSG] = { .pc_func = nlm4svc_proc_unlock_msg, @@ -584,6 +593,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "UNLOCK_MSG", }, [NLMPROC_GRANTED_MSG] = { .pc_func = nlm4svc_proc_granted_msg, @@ -592,6 +602,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "GRANTED_MSG", }, [NLMPROC_TEST_RES] = { .pc_func = nlm4svc_proc_null, @@ -600,6 +611,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_res), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "TEST_RES", }, [NLMPROC_LOCK_RES] = { .pc_func = nlm4svc_proc_null, @@ -608,6 +620,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_res), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "LOCK_RES", }, [NLMPROC_CANCEL_RES] = { .pc_func = nlm4svc_proc_null, @@ -616,6 +629,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_res), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "CANCEL_RES", }, [NLMPROC_UNLOCK_RES] = { .pc_func = nlm4svc_proc_null, @@ -624,6 +638,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_res), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "UNLOCK_RES", }, [NLMPROC_GRANTED_RES] = { .pc_func = nlm4svc_proc_granted_res, @@ -632,6 +647,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_res), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "GRANTED_RES", }, [NLMPROC_NSM_NOTIFY] = { .pc_func = nlm4svc_proc_sm_notify, @@ -640,6 +656,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_reboot), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "SM_NOTIFY", }, [17] = { .pc_func = nlm4svc_proc_unused, @@ -648,6 +665,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_void), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = 0, + .pc_name = "UNUSED", }, [18] = { .pc_func = nlm4svc_proc_unused, @@ -656,6 +674,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_void), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = 0, + .pc_name = "UNUSED", }, [19] = { .pc_func = nlm4svc_proc_unused, @@ -664,6 +683,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_void), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = 0, + .pc_name = "UNUSED", }, [NLMPROC_SHARE] = { .pc_func = nlm4svc_proc_share, @@ -672,6 +692,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St+1, + .pc_name = "SHARE", }, [NLMPROC_UNSHARE] = { .pc_func = nlm4svc_proc_unshare, @@ -680,6 +701,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St+1, + .pc_name = "UNSHARE", }, [NLMPROC_NM_LOCK] = { .pc_func = nlm4svc_proc_nm_lock, @@ -688,6 +710,7 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St, + .pc_name = "NM_LOCK", }, [NLMPROC_FREE_ALL] = { .pc_func = nlm4svc_proc_free_all, @@ -696,5 +719,6 @@ const struct svc_procedure nlmsvc_procedures4[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "FREE_ALL", }, }; diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index 50855f2c1f4b..4ae4b63b5392 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c @@ -554,6 +554,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_void), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "NULL", }, [NLMPROC_TEST] = { .pc_func = nlmsvc_proc_test, @@ -562,6 +563,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St+2+No+Rg, + .pc_name = "TEST", }, [NLMPROC_LOCK] = { .pc_func = nlmsvc_proc_lock, @@ -570,6 +572,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St, + .pc_name = "LOCK", }, [NLMPROC_CANCEL] = { .pc_func = nlmsvc_proc_cancel, @@ -578,6 +581,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St, + .pc_name = "CANCEL", }, [NLMPROC_UNLOCK] = { .pc_func = nlmsvc_proc_unlock, @@ -586,6 +590,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St, + .pc_name = "UNLOCK", }, [NLMPROC_GRANTED] = { .pc_func = nlmsvc_proc_granted, @@ -594,6 +599,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St, + .pc_name = "GRANTED", }, [NLMPROC_TEST_MSG] = { .pc_func = nlmsvc_proc_test_msg, @@ -602,6 +608,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "TEST_MSG", }, [NLMPROC_LOCK_MSG] = { .pc_func = nlmsvc_proc_lock_msg, @@ -610,6 +617,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "LOCK_MSG", }, [NLMPROC_CANCEL_MSG] = { .pc_func = nlmsvc_proc_cancel_msg, @@ -618,6 +626,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "CANCEL_MSG", }, [NLMPROC_UNLOCK_MSG] = { .pc_func = nlmsvc_proc_unlock_msg, @@ -626,6 +635,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "UNLOCK_MSG", }, [NLMPROC_GRANTED_MSG] = { .pc_func = nlmsvc_proc_granted_msg, @@ -634,6 +644,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "GRANTED_MSG", }, [NLMPROC_TEST_RES] = { .pc_func = nlmsvc_proc_null, @@ -642,6 +653,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_res), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "TEST_RES", }, [NLMPROC_LOCK_RES] = { .pc_func = nlmsvc_proc_null, @@ -650,6 +662,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_res), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "LOCK_RES", }, [NLMPROC_CANCEL_RES] = { .pc_func = nlmsvc_proc_null, @@ -658,6 +671,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_res), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "CANCEL_RES", }, [NLMPROC_UNLOCK_RES] = { .pc_func = nlmsvc_proc_null, @@ -666,6 +680,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_res), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "UNLOCK_RES", }, [NLMPROC_GRANTED_RES] = { .pc_func = nlmsvc_proc_granted_res, @@ -674,6 +689,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_res), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "GRANTED_RES", }, [NLMPROC_NSM_NOTIFY] = { .pc_func = nlmsvc_proc_sm_notify, @@ -682,6 +698,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_reboot), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "SM_NOTIFY", }, [17] = { .pc_func = nlmsvc_proc_unused, @@ -690,6 +707,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_void), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "UNUSED", }, [18] = { .pc_func = nlmsvc_proc_unused, @@ -698,6 +716,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_void), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "UNUSED", }, [19] = { .pc_func = nlmsvc_proc_unused, @@ -706,6 +725,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_void), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = St, + .pc_name = "UNUSED", }, [NLMPROC_SHARE] = { .pc_func = nlmsvc_proc_share, @@ -714,6 +734,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St+1, + .pc_name = "SHARE", }, [NLMPROC_UNSHARE] = { .pc_func = nlmsvc_proc_unshare, @@ -722,6 +743,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St+1, + .pc_name = "UNSHARE", }, [NLMPROC_NM_LOCK] = { .pc_func = nlmsvc_proc_nm_lock, @@ -730,6 +752,7 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_res), .pc_xdrressize = Ck+St, + .pc_name = "NM_LOCK", }, [NLMPROC_FREE_ALL] = { .pc_func = nlmsvc_proc_free_all, @@ -738,5 +761,6 @@ const struct svc_procedure nlmsvc_procedures[24] = { .pc_argsize = sizeof(struct nlm_args), .pc_ressize = sizeof(struct nlm_void), .pc_xdrressize = 0, + .pc_name = "FREE_ALL", }, }; diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c index 79ff172eb1c8..c5348ba81129 100644 --- a/fs/nfs/callback_xdr.c +++ b/fs/nfs/callback_xdr.c @@ -1060,6 +1060,7 @@ static const struct svc_procedure nfs4_callback_procedures1[] = { .pc_decode = nfs4_decode_void, .pc_encode = nfs4_encode_void, .pc_xdrressize = 1, + .pc_name = "NULL", }, [CB_COMPOUND] = { .pc_func = nfs4_callback_compound, @@ -1067,6 +1068,7 @@ static const struct svc_procedure nfs4_callback_procedures1[] = { .pc_argsize = 256, .pc_ressize = 256, .pc_xdrressize = NFS4_CALLBACK_BUFSIZE, + .pc_name = "COMPOUND", } }; diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c index b0f66604532a..899762da23c9 100644 --- a/fs/nfsd/nfs2acl.c +++ b/fs/nfsd/nfs2acl.c @@ -371,6 +371,7 @@ static const struct svc_procedure nfsd_acl_procedures2[5] = { .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST, + .pc_name = "NULL", }, [ACLPROC2_GETACL] = { .pc_func = nfsacld_proc_getacl, @@ -381,6 +382,7 @@ static const struct svc_procedure nfsd_acl_procedures2[5] = { .pc_ressize = sizeof(struct nfsd3_getaclres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+1+2*(1+ACL), + .pc_name = "GETACL", }, [ACLPROC2_SETACL] = { .pc_func = nfsacld_proc_setacl, @@ -391,6 +393,7 @@ static const struct svc_procedure nfsd_acl_procedures2[5] = { .pc_ressize = sizeof(struct nfsd_attrstat), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+AT, + .pc_name = "SETACL", }, [ACLPROC2_GETATTR] = { .pc_func = nfsacld_proc_getattr, @@ -401,6 +404,7 @@ static const struct svc_procedure nfsd_acl_procedures2[5] = { .pc_ressize = sizeof(struct nfsd_attrstat), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+AT, + .pc_name = "GETATTR", }, [ACLPROC2_ACCESS] = { .pc_func = nfsacld_proc_access, @@ -411,6 +415,7 @@ static const struct svc_procedure nfsd_acl_procedures2[5] = { .pc_ressize = sizeof(struct nfsd3_accessres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+AT+1, + .pc_name = "SETATTR", }, }; diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c index 7c30876a31a1..9e1a92fb9771 100644 --- a/fs/nfsd/nfs3acl.c +++ b/fs/nfsd/nfs3acl.c @@ -251,6 +251,7 @@ static const struct svc_procedure nfsd_acl_procedures3[3] = { .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST, + .pc_name = "NULL", }, [ACLPROC3_GETACL] = { .pc_func = nfsd3_proc_getacl, @@ -261,6 +262,7 @@ static const struct svc_procedure nfsd_acl_procedures3[3] = { .pc_ressize = sizeof(struct nfsd3_getaclres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+1+2*(1+ACL), + .pc_name = "GETACL", }, [ACLPROC3_SETACL] = { .pc_func = nfsd3_proc_setacl, @@ -271,6 +273,7 @@ static const struct svc_procedure nfsd_acl_procedures3[3] = { .pc_ressize = sizeof(struct nfsd3_attrstat), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+pAT, + .pc_name = "SETACL", }, }; diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index 76931f4f57c3..c9c64471c568 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -708,6 +708,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST, + .pc_name = "NULL", }, [NFS3PROC_GETATTR] = { .pc_func = nfsd3_proc_getattr, @@ -718,6 +719,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_attrstatres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+AT, + .pc_name = "GETATTR", }, [NFS3PROC_SETATTR] = { .pc_func = nfsd3_proc_setattr, @@ -728,6 +730,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_wccstatres), .pc_cachetype = RC_REPLBUFF, .pc_xdrressize = ST+WC, + .pc_name = "SETATTR", }, [NFS3PROC_LOOKUP] = { .pc_func = nfsd3_proc_lookup, @@ -738,6 +741,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_diropres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+FH+pAT+pAT, + .pc_name = "LOOKUP", }, [NFS3PROC_ACCESS] = { .pc_func = nfsd3_proc_access, @@ -748,6 +752,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_accessres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+pAT+1, + .pc_name = "ACCESS", }, [NFS3PROC_READLINK] = { .pc_func = nfsd3_proc_readlink, @@ -758,6 +763,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_readlinkres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4, + .pc_name = "READLINK", }, [NFS3PROC_READ] = { .pc_func = nfsd3_proc_read, @@ -768,6 +774,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_readres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+pAT+4+NFSSVC_MAXBLKSIZE/4, + .pc_name = "READ", }, [NFS3PROC_WRITE] = { .pc_func = nfsd3_proc_write, @@ -778,6 +785,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_writeres), .pc_cachetype = RC_REPLBUFF, .pc_xdrressize = ST+WC+4, + .pc_name = "WRITE", }, [NFS3PROC_CREATE] = { .pc_func = nfsd3_proc_create, @@ -788,6 +796,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_createres), .pc_cachetype = RC_REPLBUFF, .pc_xdrressize = ST+(1+FH+pAT)+WC, + .pc_name = "CREATE", }, [NFS3PROC_MKDIR] = { .pc_func = nfsd3_proc_mkdir, @@ -798,6 +807,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_createres), .pc_cachetype = RC_REPLBUFF, .pc_xdrressize = ST+(1+FH+pAT)+WC, + .pc_name = "MKDIR", }, [NFS3PROC_SYMLINK] = { .pc_func = nfsd3_proc_symlink, @@ -808,6 +818,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_createres), .pc_cachetype = RC_REPLBUFF, .pc_xdrressize = ST+(1+FH+pAT)+WC, + .pc_name = "SYMLINK", }, [NFS3PROC_MKNOD] = { .pc_func = nfsd3_proc_mknod, @@ -818,6 +829,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_createres), .pc_cachetype = RC_REPLBUFF, .pc_xdrressize = ST+(1+FH+pAT)+WC, + .pc_name = "MKNOD", }, [NFS3PROC_REMOVE] = { .pc_func = nfsd3_proc_remove, @@ -828,6 +840,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_wccstatres), .pc_cachetype = RC_REPLBUFF, .pc_xdrressize = ST+WC, + .pc_name = "REMOVE", }, [NFS3PROC_RMDIR] = { .pc_func = nfsd3_proc_rmdir, @@ -838,6 +851,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_wccstatres), .pc_cachetype = RC_REPLBUFF, .pc_xdrressize = ST+WC, + .pc_name = "RMDIR", }, [NFS3PROC_RENAME] = { .pc_func = nfsd3_proc_rename, @@ -848,6 +862,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_renameres), .pc_cachetype = RC_REPLBUFF, .pc_xdrressize = ST+WC+WC, + .pc_name = "RENAME", }, [NFS3PROC_LINK] = { .pc_func = nfsd3_proc_link, @@ -858,6 +873,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_linkres), .pc_cachetype = RC_REPLBUFF, .pc_xdrressize = ST+pAT+WC, + .pc_name = "LINK", }, [NFS3PROC_READDIR] = { .pc_func = nfsd3_proc_readdir, @@ -867,6 +883,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_argsize = sizeof(struct nfsd3_readdirargs), .pc_ressize = sizeof(struct nfsd3_readdirres), .pc_cachetype = RC_NOCACHE, + .pc_name = "READDIR", }, [NFS3PROC_READDIRPLUS] = { .pc_func = nfsd3_proc_readdirplus, @@ -876,6 +893,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_argsize = sizeof(struct nfsd3_readdirplusargs), .pc_ressize = sizeof(struct nfsd3_readdirres), .pc_cachetype = RC_NOCACHE, + .pc_name = "READDIRPLUS", }, [NFS3PROC_FSSTAT] = { .pc_func = nfsd3_proc_fsstat, @@ -885,6 +903,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_fsstatres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+pAT+2*6+1, + .pc_name = "FSSTAT", }, [NFS3PROC_FSINFO] = { .pc_func = nfsd3_proc_fsinfo, @@ -894,6 +913,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_fsinfores), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+pAT+12, + .pc_name = "FSINFO", }, [NFS3PROC_PATHCONF] = { .pc_func = nfsd3_proc_pathconf, @@ -903,6 +923,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_pathconfres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+pAT+6, + .pc_name = "PATHCONF", }, [NFS3PROC_COMMIT] = { .pc_func = nfsd3_proc_commit, @@ -913,6 +934,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_ressize = sizeof(struct nfsd3_commitres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+WC+2, + .pc_name = "COMMIT", }, }; diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 8d6d2678abad..f567592692ee 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -3305,6 +3305,7 @@ static const struct svc_procedure nfsd_procedures4[2] = { .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = 1, + .pc_name = "NULL", }, [NFSPROC4_COMPOUND] = { .pc_func = nfsd4_proc_compound, @@ -3315,6 +3316,7 @@ static const struct svc_procedure nfsd_procedures4[2] = { .pc_release = nfsd4_release_compoundargs, .pc_cachetype = RC_NOCACHE, .pc_xdrressize = NFSD_BUFSIZE/4, + .pc_name = "COMPOUND", }, }; diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index 9473d048efec..1f85a4dc9d1b 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -623,6 +623,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = 0, + .pc_name = "NULL", }, [NFSPROC_GETATTR] = { .pc_func = nfsd_proc_getattr, @@ -633,6 +634,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_attrstat), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+AT, + .pc_name = "GETATTR", }, [NFSPROC_SETATTR] = { .pc_func = nfsd_proc_setattr, @@ -643,6 +645,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_attrstat), .pc_cachetype = RC_REPLBUFF, .pc_xdrressize = ST+AT, + .pc_name = "SETATTR", }, [NFSPROC_ROOT] = { .pc_func = nfsd_proc_root, @@ -652,6 +655,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = 0, + .pc_name = "ROOT", }, [NFSPROC_LOOKUP] = { .pc_func = nfsd_proc_lookup, @@ -662,6 +666,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_diropres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+FH+AT, + .pc_name = "LOOKUP", }, [NFSPROC_READLINK] = { .pc_func = nfsd_proc_readlink, @@ -671,6 +676,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_readlinkres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+1+NFS_MAXPATHLEN/4, + .pc_name = "READLINK", }, [NFSPROC_READ] = { .pc_func = nfsd_proc_read, @@ -681,6 +687,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_readres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+AT+1+NFSSVC_MAXBLKSIZE_V2/4, + .pc_name = "READ", }, [NFSPROC_WRITECACHE] = { .pc_func = nfsd_proc_writecache, @@ -690,6 +697,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_voidres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = 0, + .pc_name = "WRITECACHE", }, [NFSPROC_WRITE] = { .pc_func = nfsd_proc_write, @@ -700,6 +708,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_attrstat), .pc_cachetype = RC_REPLBUFF, .pc_xdrressize = ST+AT, + .pc_name = "WRITE", }, [NFSPROC_CREATE] = { .pc_func = nfsd_proc_create, @@ -710,6 +719,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_diropres), .pc_cachetype = RC_REPLBUFF, .pc_xdrressize = ST+FH+AT, + .pc_name = "CREATE", }, [NFSPROC_REMOVE] = { .pc_func = nfsd_proc_remove, @@ -719,6 +729,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_stat), .pc_cachetype = RC_REPLSTAT, .pc_xdrressize = ST, + .pc_name = "REMOVE", }, [NFSPROC_RENAME] = { .pc_func = nfsd_proc_rename, @@ -728,6 +739,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_stat), .pc_cachetype = RC_REPLSTAT, .pc_xdrressize = ST, + .pc_name = "RENAME", }, [NFSPROC_LINK] = { .pc_func = nfsd_proc_link, @@ -737,6 +749,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_stat), .pc_cachetype = RC_REPLSTAT, .pc_xdrressize = ST, + .pc_name = "LINK", }, [NFSPROC_SYMLINK] = { .pc_func = nfsd_proc_symlink, @@ -746,6 +759,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_stat), .pc_cachetype = RC_REPLSTAT, .pc_xdrressize = ST, + .pc_name = "SYMLINK", }, [NFSPROC_MKDIR] = { .pc_func = nfsd_proc_mkdir, @@ -756,6 +770,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_diropres), .pc_cachetype = RC_REPLBUFF, .pc_xdrressize = ST+FH+AT, + .pc_name = "MKDIR", }, [NFSPROC_RMDIR] = { .pc_func = nfsd_proc_rmdir, @@ -765,6 +780,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_stat), .pc_cachetype = RC_REPLSTAT, .pc_xdrressize = ST, + .pc_name = "RMDIR", }, [NFSPROC_READDIR] = { .pc_func = nfsd_proc_readdir, @@ -773,6 +789,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_argsize = sizeof(struct nfsd_readdirargs), .pc_ressize = sizeof(struct nfsd_readdirres), .pc_cachetype = RC_NOCACHE, + .pc_name = "READDIR", }, [NFSPROC_STATFS] = { .pc_func = nfsd_proc_statfs, @@ -782,6 +799,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { .pc_ressize = sizeof(struct nfsd_statfsres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+5, + .pc_name = "STATFS", }, }; diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 34c2a69820e9..31ee3b6047c3 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -463,6 +463,7 @@ struct svc_procedure { unsigned int pc_ressize; /* result struct size */ unsigned int pc_cachetype; /* cache info (NFS) */ unsigned int pc_xdrressize; /* maximum size of XDR reply */ + const char * pc_name; /* for display */ }; /* From patchwork Tue Jan 5 15:29:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999247 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 51D12C4332D for ; Tue, 5 Jan 2021 15:30:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0D17222AAA for ; Tue, 5 Jan 2021 15:30:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726851AbhAEPaf (ORCPT ); Tue, 5 Jan 2021 10:30:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726177AbhAEPaf (ORCPT ); Tue, 5 Jan 2021 10:30:35 -0500 Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1F31C061796 for ; Tue, 5 Jan 2021 07:29:54 -0800 (PST) Received: by mail-qv1-xf2e.google.com with SMTP id et9so14814578qvb.10 for ; Tue, 05 Jan 2021 07:29: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=HPoTfLOu6jh7S73eQiyM6a8ds1EMrEQwWK7v+DXpuA8=; b=kLydSBWKt0VY+PdWCFvmkBDBjMSdCKVpY5xcjFaqr2zcS2rJsdZNTAkrlvpEsTLc3u LeoHCM8xXyWwbJiuxe5SQVm5HzjL1J49w26gXCHFeH3zsXbTJZq29R82OyFUVmISBSTm tn1487SB/rngTZ83Rsqq+lv3Z1XWoDu37c062ihIznSwIuvmEYJTeEXXEgQqZwoVnCqM te5YA7zH0IMtEWtwTNUSabpKZHtjA/TQWnKyAXBP0/Z0jbt+XJBFACeYL9FvQQ34AcyJ 1HD6rTVdrkQjatGLSNIcdfSuraZclH7BeImBz2tlQNQaAntmMpei7W82v7SFQ4EgcHvZ QrVw== 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=HPoTfLOu6jh7S73eQiyM6a8ds1EMrEQwWK7v+DXpuA8=; b=NgbuXwu+KfN3mdqk33N4/uRUbw1TcIEzSM7v1j146xu012QaoykIgOsmURbQ9tiz+g rOZkurqvfPyX+Lu+lq0zhjLQA9PkFHRC0M07Sl/7jrBscdxwo6vTDLzLByRfvxFrtPVu izvokquqGVJGcrCuGN3WdaxO0JT4vWvW+dAO32teF2phEfJDvkS6uhsBK6a7IuyK2+LV UUvfj+ZxMtn3xrLG7rlflw2e9vyUp4sXtSgnx7VrbVv/na06M0zg1xcya4sq/iaH21zg k7UfGh2cWnJlwUv4in9yZozxYx6ligXnZr2Yt62nYVjTg4U0io3610hv2DkNbxNpt2/c S5hQ== X-Gm-Message-State: AOAM532Ek5huX0tXDowCRe3us82YATQmvoUOIRTDPIWi3T0nYqP4jvKe VE/guHUw0ZaTWGN5ZeN8SUnfVXFbqj4= X-Google-Smtp-Source: ABdhPJySNdm3WEs6WySaJcST4iUPl8o+5VdVzd7FMWWZQVAkGsX8jpkkb6hBDby0iXteqVu3SLmgFA== X-Received: by 2002:ad4:4b21:: with SMTP id s1mr56673878qvw.59.1609860593778; Tue, 05 Jan 2021 07:29: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 y22sm116607qkj.129.2021.01.05.07.29.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:29:53 -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 105FTqEH020817 for ; Tue, 5 Jan 2021 15:29:52 GMT Subject: [PATCH v1 02/42] SUNRPC: Display RPC procedure names instead of proc numbers From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:29:52 -0500 Message-ID: <160986059213.5532.17552186357969566215.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 Make the sunrpc trace subsystem trace events easier to use. Signed-off-by: Chuck Lever --- include/trace/events/sunrpc.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h index 58994e013022..562f2bb1e3ff 100644 --- a/include/trace/events/sunrpc.h +++ b/include/trace/events/sunrpc.h @@ -1556,6 +1556,7 @@ TRACE_EVENT(svc_process, __field(u32, vers) __field(u32, proc) __string(service, name) + __string(procedure, rqst->rq_procinfo->pc_name) __string(addr, rqst->rq_xprt ? rqst->rq_xprt->xpt_remotebuf : "(null)") ), @@ -1565,13 +1566,16 @@ TRACE_EVENT(svc_process, __entry->vers = rqst->rq_vers; __entry->proc = rqst->rq_proc; __assign_str(service, name); + __assign_str(procedure, rqst->rq_procinfo->pc_name); __assign_str(addr, rqst->rq_xprt ? rqst->rq_xprt->xpt_remotebuf : "(null)"); ), - TP_printk("addr=%s xid=0x%08x service=%s vers=%u proc=%u", + TP_printk("addr=%s xid=0x%08x service=%s vers=%u proc=%s", __get_str(addr), __entry->xid, - __get_str(service), __entry->vers, __entry->proc) + __get_str(service), __entry->vers, + __get_str(procedure) + ) ); DECLARE_EVENT_CLASS(svc_rqst_event, @@ -1827,6 +1831,7 @@ TRACE_EVENT(svc_stats_latency, TP_STRUCT__entry( __field(u32, xid) __field(unsigned long, execute) + __string(procedure, rqst->rq_procinfo->pc_name) __string(addr, rqst->rq_xprt->xpt_remotebuf) ), @@ -1834,11 +1839,13 @@ TRACE_EVENT(svc_stats_latency, __entry->xid = be32_to_cpu(rqst->rq_xid); __entry->execute = ktime_to_us(ktime_sub(ktime_get(), rqst->rq_stime)); + __assign_str(procedure, rqst->rq_procinfo->pc_name); __assign_str(addr, rqst->rq_xprt->xpt_remotebuf); ), - TP_printk("addr=%s xid=0x%08x execute-us=%lu", - __get_str(addr), __entry->xid, __entry->execute) + TP_printk("addr=%s xid=0x%08x proc=%s execute-us=%lu", + __get_str(addr), __entry->xid, __get_str(procedure), + __entry->execute) ); DECLARE_EVENT_CLASS(svc_deferred_event, From patchwork Tue Jan 5 15:29:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999251 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 7969CC433DB for ; Tue, 5 Jan 2021 15:30:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DC4722AAA for ; Tue, 5 Jan 2021 15:30:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726655AbhAEPak (ORCPT ); Tue, 5 Jan 2021 10:30:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726177AbhAEPak (ORCPT ); Tue, 5 Jan 2021 10:30:40 -0500 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30AA9C061798 for ; Tue, 5 Jan 2021 07:30:00 -0800 (PST) Received: by mail-qt1-x82b.google.com with SMTP id g24so21029782qtq.12 for ; Tue, 05 Jan 2021 07:30: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=iKVdinXngdEoCUgnIQSNWZSkMjjHieXbtc37ayHSX7Y=; b=HsDbmZuAVhw45PTS0TMRJsH+eYKmj90C1bIC6sz1tP3i/E5Hxs5mJA3I9P/H1+YRj9 BCQl7J3VtkmFirwiq9nuBkkph8UTJ/XruH0dGPY4anHz7IgwUQBZ9J43kBb5U6ZYbEgJ aqF0dM3J8n+0uVoASH8EMednUQIWfjdsgJ7o0pX2pP65HEzwVyFHFrvwV1PU+psB09uU a4/OQ3zaJYJDTBacFDolS/qnbsXB5Y1XQaBcoa4ORGhTfgWuHJNIgVuqkO6YxKx7eOFE K3l2Y2wlDnxPgKS6sn81dbJPKOlYgOh+I1v3BBqAWULiA7OGBQooU5/jjACUXNmo32GJ lh9w== 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=iKVdinXngdEoCUgnIQSNWZSkMjjHieXbtc37ayHSX7Y=; b=IYNHgoswkzWpl7sEiBqCk9/suc6ME83Hkclipgm0Sx3Ktbv08BMeYOl9YDNyJu6ayl EXheXcW2gnMArRnxUhID7D4Y8iik5CIme/3IdDM18GkPcIegrC5bXtbQ63M8QqkvivhP hDTr/9GwQgxoBQVkpcPaB68Ns+/VeEZFCEvuLDVm8bTHlrhtvk0NDO2iQIbAsyWElpru xNmZ7yMTUlMXfQaRTfcoWpcps/J9a9WD+L3eixiQXj/Z7Ik/adPr81V9ECRjLxviqDlK 3NblqK9u+UhaQnsI3hmI10xu30rkBIBvJrNOgVmUSEeMiHvGK3bE9cnFd7B1G/6HBjW7 Cehw== X-Gm-Message-State: AOAM531zeAhtS1/Z72wHrQznuPbyjQWDWjagyfzSKsdC0wc5q8sjFbGv ihm6aflde7R4e8d80MS9oeOEPoAGmVU= X-Google-Smtp-Source: ABdhPJzF7J4UfxrY3wTc91MO6DWY/301vMjqzLnI/1RLoFfD6e2XazvimamzEwbRAWtbLxFXU9LcQA== X-Received: by 2002:aed:3441:: with SMTP id w59mr18525qtd.153.1609860599117; Tue, 05 Jan 2021 07:29: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 y15sm38687qto.51.2021.01.05.07.29.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:29: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 105FTvUt020820 for ; Tue, 5 Jan 2021 15:29:57 GMT Subject: [PATCH v1 03/42] SUNRPC: Move definition of XDR_UNIT From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:29:57 -0500 Message-ID: <160986059742.5532.14612206049969450349.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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: The unit of XDR alignment is defined by RFC 4506, not as part of the RPC message header. Thus it belongs in include/linux/sunrpc/xdr.h. Signed-off-by: Chuck Lever --- include/linux/sunrpc/msg_prot.h | 3 --- include/linux/sunrpc/xdr.h | 13 ++++++++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/include/linux/sunrpc/msg_prot.h b/include/linux/sunrpc/msg_prot.h index 43f854487539..938c2bf29db8 100644 --- a/include/linux/sunrpc/msg_prot.h +++ b/include/linux/sunrpc/msg_prot.h @@ -10,9 +10,6 @@ #define RPC_VERSION 2 -/* size of an XDR encoding unit in bytes, i.e. 32bit */ -#define XDR_UNIT (4) - /* spec defines authentication flavor as an unsigned 32 bit integer */ typedef u32 rpc_authflavor_t; diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index 9b35ce50cf2b..8b61ec92366f 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -19,6 +19,13 @@ struct bio_vec; struct rpc_rqst; +/* + * Size of an XDR encoding unit in bytes, i.e. 32 bits, + * as defined in Section 3 of RFC 4506. All encoded + * XDR data items are aligned on a boundary of 32 bits. + */ +#define XDR_UNIT sizeof(__be32) + /* * Buffer adjustment */ @@ -331,7 +338,7 @@ ssize_t xdr_stream_decode_string_dup(struct xdr_stream *xdr, char **str, static inline size_t xdr_align_size(size_t n) { - const size_t mask = sizeof(__u32) - 1; + const size_t mask = XDR_UNIT - 1; return (n + mask) & ~mask; } @@ -361,7 +368,7 @@ static inline size_t xdr_pad_size(size_t n) */ static inline ssize_t xdr_stream_encode_item_present(struct xdr_stream *xdr) { - const size_t len = sizeof(__be32); + const size_t len = XDR_UNIT; __be32 *p = xdr_reserve_space(xdr, len); if (unlikely(!p)) @@ -380,7 +387,7 @@ static inline ssize_t xdr_stream_encode_item_present(struct xdr_stream *xdr) */ static inline int xdr_stream_encode_item_absent(struct xdr_stream *xdr) { - const size_t len = sizeof(__be32); + const size_t len = XDR_UNIT; __be32 *p = xdr_reserve_space(xdr, len); if (unlikely(!p)) From patchwork Tue Jan 5 15:30:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999263 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 802B3C433DB for ; Tue, 5 Jan 2021 15:31:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 508A222B4B for ; Tue, 5 Jan 2021 15:31:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727378AbhAEPbB (ORCPT ); Tue, 5 Jan 2021 10:31:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727334AbhAEPbB (ORCPT ); Tue, 5 Jan 2021 10:31:01 -0500 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37717C06179E for ; Tue, 5 Jan 2021 07:30:05 -0800 (PST) Received: by mail-qk1-x730.google.com with SMTP id h4so26807743qkk.4 for ; Tue, 05 Jan 2021 07:30: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=api75vfmsi7YaiUQDuMlZUbdyC7cX4thBLVHuevlZoo=; b=HO6lhPfZZ99aHrJN2/iG9cg2WKWep0yNDlarhKbxIYLQirwNOPa8sM9bxposVrKEMr fQ4D9BMWzz8sxhGYNy6frLWrMtjfNpxmbG6KTnOqwW8v3FnhOvTe2aKXaqB4aaKrOx/A vFDwkTLFjjcxmjRdARnQLDLhDhrofOcoTlhKbiUlvZWbaOAV4iIbekQZSyRCVwIMqGPy lUizduLTeWY8i4lc7fbTd658KnD3M+zCqMiTu5fYIfni0+4Hw5LdttnruvrHbS2cXFJi k4KzJMawlrGIh2uG0cJk4TYZCLvJ52GNRs9L/92l3eY10nqujHaZ0mNWw8648Wd+A6lU DMeA== 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=api75vfmsi7YaiUQDuMlZUbdyC7cX4thBLVHuevlZoo=; b=e3eWt6fbiJDeSzDVFjlKchwlFJ1qxnq0Bgy2470lVtuVYp7ZcSXhQw5SQ5LJhTaSnQ aUYWDw2E25v6J1Zp7uO/eHR6dNX1J/tV+BhWqnGTgwx/nLmrjm9/3HqorsDAW43sym+y K/I42ef76rptApFUvOOjpL1YV6NPAq4fAfssGru8qG7M3M+XXTmQpJdnrT947LhQPJeT h2WLlk5djnLgUZk+9rA/LayQ47zVmpdOhHb9D43JoHzcff4JhAMocYAoT0POvGO3UH0z R5L6RKVVzxceuAEFMPAa8B8hnB/ODdXQGMRaxOC46H6hPhZ7pC7gPYTwSD8PKJWI7c8+ OjRQ== X-Gm-Message-State: AOAM532FYPWPDExR2QppcNziMbhaAVvW3Ej79Ia5aRtYQ2baDtBMya7m zNa+jTR7eme/BJuqMLZgoWibcjtni8M= X-Google-Smtp-Source: ABdhPJz0gu5E4hg4lBLmxMrIRFK8hjYB5ON9L8vnOC+/q9q7+KhkAgFERgzctIzmSZFEhNIcWtOltw== X-Received: by 2002:a05:620a:15ea:: with SMTP id p10mr73502qkm.172.1609860604141; Tue, 05 Jan 2021 07:30: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 h1sm60820qtr.1.2021.01.05.07.30.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:30: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 105FU2aQ020832 for ; Tue, 5 Jan 2021 15:30:02 GMT Subject: [PATCH v1 04/42] NFSD: Update GETATTR3args decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:30:02 -0500 Message-ID: <160986060270.5532.7651375067308848822.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs3proc.c | 3 +-- fs/nfsd/nfs3xdr.c | 31 +++++++++++++++++++++++++------ fs/nfsd/xdr3.h | 2 +- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index c9c64471c568..4b66f055141b 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -683,7 +683,6 @@ nfsd3_proc_commit(struct svc_rqst *rqstp) * NFSv3 Server procedures. * Only the results of non-idempotent operations are cached. */ -#define nfs3svc_decode_fhandleargs nfs3svc_decode_fhandle #define nfs3svc_encode_attrstatres nfs3svc_encode_attrstat #define nfs3svc_encode_wccstatres nfs3svc_encode_wccstat #define nfsd3_mkdirargs nfsd3_createargs @@ -715,7 +714,7 @@ static const struct svc_procedure nfsd_procedures3[22] = { .pc_decode = nfs3svc_decode_fhandleargs, .pc_encode = nfs3svc_encode_attrstatres, .pc_release = nfs3svc_release_fhandle, - .pc_argsize = sizeof(struct nfsd3_fhandleargs), + .pc_argsize = sizeof(struct nfsd_fhandle), .pc_ressize = sizeof(struct nfsd3_attrstatres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+AT, diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 821db21ba072..01335b0e7c60 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -29,8 +29,9 @@ static u32 nfs3_ftypes[] = { /* - * XDR functions for basic NFS types + * Basic NFSv3 data types (RFC 1813 Sections 2.5 and 2.6) */ + static __be32 * encode_time3(__be32 *p, struct timespec64 *time) { @@ -46,6 +47,26 @@ decode_time3(__be32 *p, struct timespec64 *time) return p; } +static bool +svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp) +{ + __be32 *p; + u32 size; + + if (xdr_stream_decode_u32(xdr, &size) < 0) + return false; + if (size == 0 || size > NFS3_FHSIZE) + return false; + p = xdr_inline_decode(xdr, size); + if (!p) + return false; + fh_init(fhp, NFS3_FHSIZE); + fhp->fh_handle.fh_size = size; + memcpy(&fhp->fh_handle.fh_base, p, size); + + return true; +} + static __be32 * decode_fh(__be32 *p, struct svc_fh *fhp) { @@ -312,14 +333,12 @@ void fill_post_wcc(struct svc_fh *fhp) */ int -nfs3svc_decode_fhandle(struct svc_rqst *rqstp, __be32 *p) +nfs3svc_decode_fhandleargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd_fhandle *args = rqstp->rq_argp; - p = decode_fh(p, &args->fh); - if (!p) - return 0; - return xdr_argsize_check(rqstp, p); + return svcxdr_decode_nfs_fh3(xdr, &args->fh); } int diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h index 456fcd7a1038..62ea669768cf 100644 --- a/fs/nfsd/xdr3.h +++ b/fs/nfsd/xdr3.h @@ -273,7 +273,7 @@ union nfsd3_xdrstore { #define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore) -int nfs3svc_decode_fhandle(struct svc_rqst *, __be32 *); +int nfs3svc_decode_fhandleargs(struct svc_rqst *, __be32 *); int nfs3svc_decode_sattrargs(struct svc_rqst *, __be32 *); int nfs3svc_decode_diropargs(struct svc_rqst *, __be32 *); int nfs3svc_decode_accessargs(struct svc_rqst *, __be32 *); From patchwork Tue Jan 5 15:30:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999261 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 51D61C433E0 for ; Tue, 5 Jan 2021 15:31:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A69022AAA for ; Tue, 5 Jan 2021 15:31:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727457AbhAEPbB (ORCPT ); Tue, 5 Jan 2021 10:31:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727378AbhAEPbB (ORCPT ); Tue, 5 Jan 2021 10:31:01 -0500 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [IPv6:2607:f8b0:4864:20::72b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3E2FC06179F for ; Tue, 5 Jan 2021 07:30:10 -0800 (PST) Received: by mail-qk1-x72b.google.com with SMTP id n142so26774651qkn.2 for ; Tue, 05 Jan 2021 07:30: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=qo76xpLcKBnS58A413kyRClIdq86F+9xZlxhfW2Jr1k=; b=nTnIiKntaTSEqOId194RrRjaOnaMLeSKguDiHMO8RX1IpRstRprVqaKGBbJGYoOwve E5yw34tqZtfPhj2sl8oqFkHMY6Qs/P3Nt84XMY1jd/gfY/s795FSqXoZmc1CWSQBgQzY dqMoaw1Op1+0skhy/EIYO9d+A5S9YOFp34dL9uFdq3tyeevh+KRZirpsp23r8i3c9egr dKrzlC/ntvVn7uo44BMeV+3LMriFHLIWbdxz2W/OYKmx8DcqFdNLi81nzukqaHsott0g LN97mqJgdTN9ur6U3H7UnK3uwt6PJyOk1zfD+LDCvSzAphup5/jnsPy1DRS3YQ4O4yt8 7B6g== 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=qo76xpLcKBnS58A413kyRClIdq86F+9xZlxhfW2Jr1k=; b=NbZLpvgPOSL+sD3xdS46Hav2/IaNQyHsRGr4JrC1+O9dL53VYxoKe0eoyliMtiBK4z OKCXAbwOrsrlqziTsGeAp6+dUR8nhmh5Yz03K1fyDTQm9vbIvGw/TWvjx3KUFG7y+AJ3 2HJX6a9obEud8M4o1g6a/55YZgtROkU3YUX8c8unIqD1WRDTiIeNMgp2pMQPy2ES9Jv8 OtIKgex/LhcJsZB1AyGWbr+jpbSeIM5sjcU/vvIL0uLvXEKRn3SRKzO6kGGnMUemHsQ1 k7wfUe6trzexbUGZamQvhkmTzAlng6iwTiluxnnV56W9dyge+aLb9lfXdxPf05dgVWC/ Sx+w== X-Gm-Message-State: AOAM533mp7hEj7r4BoP2TVq3lU0tXtpAod4qRNzqKDn8KI+ZslOFRUnd 4kKCit/PzjVTRT017cGDrs6Ogvlfig8= X-Google-Smtp-Source: ABdhPJzOZY+e/oUWiyFqsI3aLIVvrzaJAYl1dvEuCpQd6is+BOdCOz5fObqsizUGqnZxKrDsdgXzYg== X-Received: by 2002:a37:c89:: with SMTP id 131mr40049qkm.468.1609860609784; Tue, 05 Jan 2021 07:30: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 b67sm141482qkc.44.2021.01.05.07.30.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:30: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 105FU7qZ020835 for ; Tue, 5 Jan 2021 15:30:07 GMT Subject: [PATCH v1 05/42] NFSD: Update ACCESS3arg decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:30:07 -0500 Message-ID: <160986060777.5532.11667377354502389840.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs3xdr.c | 9 +++++---- fs/nfsd/xdr3.h | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 01335b0e7c60..ac680f34fcba 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -375,14 +375,15 @@ nfs3svc_decode_diropargs(struct svc_rqst *rqstp, __be32 *p) int nfs3svc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_accessargs *args = rqstp->rq_argp; - p = decode_fh(p, &args->fh); - if (!p) + if (!svcxdr_decode_nfs_fh3(xdr, &args->fh)) + return 0; + if (xdr_stream_decode_u32(xdr, &args->access) < 0) return 0; - args->access = ntohl(*p++); - return xdr_argsize_check(rqstp, p); + return 1; } int diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h index 62ea669768cf..a4dce4baec7c 100644 --- a/fs/nfsd/xdr3.h +++ b/fs/nfsd/xdr3.h @@ -25,7 +25,7 @@ struct nfsd3_diropargs { struct nfsd3_accessargs { struct svc_fh fh; - unsigned int access; + __u32 access; }; struct nfsd3_readargs { From patchwork Tue Jan 5 15:30:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999253 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 641F7C433DB for ; Tue, 5 Jan 2021 15:30:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3528D22AAA for ; Tue, 5 Jan 2021 15:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727155AbhAEPam (ORCPT ); Tue, 5 Jan 2021 10:30:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726177AbhAEPam (ORCPT ); Tue, 5 Jan 2021 10:30:42 -0500 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E308C0617A0 for ; Tue, 5 Jan 2021 07:30:15 -0800 (PST) Received: by mail-qk1-x730.google.com with SMTP id 22so26745531qkf.9 for ; Tue, 05 Jan 2021 07:30: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=lgOPBssOoEXl+FYJvwhUQej6ZdNMZl4H/mvYHxOmzRE=; b=Qd72ktgu6w5Zus/y6J0nP3L+o+Qn9EDX+RvHJ34KmAhKM5UK+rZ6Ee/WMcQEZ7BPUX n5HcoYWAQMN8EVaBVyXKK15y7bjKhDyDXytLyuEBbasjgGhydoMS0TYK/AV68LsrM3d4 qPdyW89KKVRVdFHGxiC8KZvtk9DviGTZ1igG8HE0EA+7Af/L0PlRu5XHKvMC2/q3Zi0A mfwjPT6f/lGxVliObOZ5XeJFV8OumdCEVe2VlD5V/Pc/E3n72coVi+8j7WCSwnig9y+2 EH2qNydgvdtAobnrD9Py+jhQnH+YNt4lypHjbXlbX3UgqE+o7WH0R+Qaey8t3SvVEAME oHBw== 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=lgOPBssOoEXl+FYJvwhUQej6ZdNMZl4H/mvYHxOmzRE=; b=F/l5TBqnEppFEsrv/h71zaORRp3SxrdYxJ8/OFz3rliioo2oLKmVcHhB6Bgt7pZBJI JpMNkqvHFpaYBcdeMaK9pkLkBU/b6s5RQGLM+mD53+warqhkygDPO8sYFClHsP4L2How XEGfWR6kIbjfvgYSKMsZxY128caEjTvJWKb6OYnhXY+ElgeVHyoeR7QRSoflOkDm5wFm SxePv0ikDuYZoqrsEkeHeumS1bWz86WdcK/nswCczlWvaKvAvd6ZwQFU7S3k1+FD1KHb pdJBnxHFdRQUKW0JHmY6vNIJzx8PgHwgIk9LFKaZqLAcW9kw1IO6to4JxNEMrJHgw8yw XtZg== X-Gm-Message-State: AOAM532572Y+6Lw7s07tiOrz+5Ioxan7UDiW3ikOKEdGY5JZp5uFjv7d 3IMcaxWf2c19Rbg412g3Ha8AflPOimo= X-Google-Smtp-Source: ABdhPJz5fW3tq1vStifk4h0+cTMzR8DT4dAsUUQLVtYKjxqLSfSWK+RhAmDCCZzDCdtgXQNXp2HQ2g== X-Received: by 2002:a37:495:: with SMTP id 143mr31905qke.37.1609860614497; Tue, 05 Jan 2021 07:30: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 d123sm118463qke.95.2021.01.05.07.30.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:30: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 105FUD1a020838 for ; Tue, 5 Jan 2021 15:30:13 GMT Subject: [PATCH v1 06/42] NFSD: Update READ3arg decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:30:13 -0500 Message-ID: <160986061305.5532.14704732180124620703.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 The code that sets up rq_vec is refactored so that it is now adjacent to the nfsd_read() call site where it is used. Signed-off-by: Chuck Lever --- fs/nfsd/nfs3proc.c | 23 ++++++++++++++++++----- fs/nfsd/nfs3xdr.c | 28 +++++++--------------------- fs/nfsd/xdr3.h | 1 - 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index 4b66f055141b..acdf47179a38 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -144,25 +144,38 @@ nfsd3_proc_read(struct svc_rqst *rqstp) { struct nfsd3_readargs *argp = rqstp->rq_argp; struct nfsd3_readres *resp = rqstp->rq_resp; - u32 max_blocksize = svc_max_payload(rqstp); - unsigned long cnt = min(argp->count, max_blocksize); + u32 max_blocksize = svc_max_payload(rqstp); + unsigned int len; + int v; + + argp->count = min_t(u32, argp->count, max_blocksize); dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n", SVCFH_fmt(&argp->fh), (unsigned long) argp->count, (unsigned long long) argp->offset); + v = 0; + len = argp->count; + while (len > 0) { + struct page *page = *(rqstp->rq_next_page++); + + rqstp->rq_vec[v].iov_base = page_address(page); + rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE); + len -= rqstp->rq_vec[v].iov_len; + v++; + } + /* Obtain buffer pointer for payload. * 1 (status) + 22 (post_op_attr) + 1 (count) + 1 (eof) * + 1 (xdr opaque byte count) = 26 */ - resp->count = cnt; + resp->count = argp->count; svc_reserve_auth(rqstp, ((1 + NFS3_POST_OP_ATTR_WORDS + 3)<<2) + resp->count +4); fh_copy(&resp->fh, &argp->fh); resp->status = nfsd_read(rqstp, &resp->fh, argp->offset, - rqstp->rq_vec, argp->vlen, &resp->count, - &resp->eof); + rqstp->rq_vec, v, &resp->count, &resp->eof); return rpc_success; } diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index ac680f34fcba..ff98eae5db81 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -389,31 +389,17 @@ nfs3svc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p) int nfs3svc_decode_readargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_readargs *args = rqstp->rq_argp; - unsigned int len; - int v; - u32 max_blocksize = svc_max_payload(rqstp); - p = decode_fh(p, &args->fh); - if (!p) + if (!svcxdr_decode_nfs_fh3(xdr, &args->fh)) + return 0; + if (xdr_stream_decode_u64(xdr, &args->offset) < 0) + return 0; + if (xdr_stream_decode_u32(xdr, &args->count) < 0) return 0; - p = xdr_decode_hyper(p, &args->offset); - - args->count = ntohl(*p++); - len = min(args->count, max_blocksize); - - /* set up the kvec */ - v=0; - while (len > 0) { - struct page *p = *(rqstp->rq_next_page++); - rqstp->rq_vec[v].iov_base = page_address(p); - rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE); - len -= rqstp->rq_vec[v].iov_len; - v++; - } - args->vlen = v; - return xdr_argsize_check(rqstp, p); + return 1; } int diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h index a4dce4baec7c..7dfeeaa4e1df 100644 --- a/fs/nfsd/xdr3.h +++ b/fs/nfsd/xdr3.h @@ -32,7 +32,6 @@ struct nfsd3_readargs { struct svc_fh fh; __u64 offset; __u32 count; - int vlen; }; struct nfsd3_writeargs { From patchwork Tue Jan 5 15:30:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999269 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 03D7AC433DB for ; Tue, 5 Jan 2021 15:31:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CB46922AAA for ; Tue, 5 Jan 2021 15:31:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727561AbhAEPbI (ORCPT ); Tue, 5 Jan 2021 10:31:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727529AbhAEPbH (ORCPT ); Tue, 5 Jan 2021 10:31:07 -0500 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35801C061793 for ; Tue, 5 Jan 2021 07:30:21 -0800 (PST) Received: by mail-qk1-x734.google.com with SMTP id 186so26795760qkj.3 for ; Tue, 05 Jan 2021 07:30:21 -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=1pVZopU2CsbRndKPbGGCSJiKrCH8+GFDj1p4QPlGB8I=; b=n63S6pmlZTGo4N1D/XJEmHMb9dZKqPYMafVdD+kO80cKgjZ5hhsYccfLNuAodTr4vC E2nT6GCLFCLo8XPGIs+cQRrDvydFsBy1ifdRRY/RwX4Z1EWTDTFnxVWoZ2Z5WCLtZwXt 44/BFfur4MxVH/CyjsO8CatahzhdS1ybPbI4rJJcalDS1LL/ojLyHbgfs3R21DPtYYNb Fjnu7U4GM2QJqDZ2CBKsvhpkzKUpT0CiU1d8Q0HXyPCZhHyXdarGAxCxMyUk9WJZgeLT c2YnHYwRHc+JLWIJQzxMtZrixJl2ceNZ7Yj/cVnb1C4Nalc5gbxVlCDL84fhrXk5VaHd ZHYQ== 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=1pVZopU2CsbRndKPbGGCSJiKrCH8+GFDj1p4QPlGB8I=; b=QaWJlnWQGHbdVObdZjuYpMtia9tcg+bnmpYPJmJVC/2RR9txUoP2FTkbX4YMC5xEFt DvAgFYjqQTe9CswXErHXDAQXWTmlLx/ecmcKVF4en5KrcoEiCBbA0D9/462a/SplgaYg uF9MCFCyemv76zE+dMpqWsNoRmPu6+BebU4zq51fG6oXj2+C8u8eqxRdAIueS3BufY4p kQgtOLJvoZ4eJYinJdcqNgxVYRW7Xm/yf2jbjxLdisDH8sSDVm6t52zV5fCehtIjV6G9 uEwxc+6OwWMIBiKalwLNH+xqs/Czbs4MbAtghcI+kBoaGtT8vnLBuOCVcVyaW92ogEKu 25VA== X-Gm-Message-State: AOAM533KqKkdFQp3WgD57YRla9y3TocF7ZLp4MJLwDuBysBtvRMMy46O TeCfXZZv9cbeFmqUi0Yx3B5NpKhqTgE= X-Google-Smtp-Source: ABdhPJwroRa0rc0tAT+yFWCeefyEikiDqCCg7Ccst7q436fithZ3E+kkoVZEHICAyM62WFxklkNTIQ== X-Received: by 2002:a37:76c6:: with SMTP id r189mr83210qkc.24.1609860620107; Tue, 05 Jan 2021 07:30:20 -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 n66sm117010qkn.136.2021.01.05.07.30.18 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:30: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 105FUIxj020841 for ; Tue, 5 Jan 2021 15:30:18 GMT Subject: [PATCH v1 07/42] NFSD: Update WRITE3arg decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:30:18 -0500 Message-ID: <160986061812.5532.3122782251888690881.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 As part of the update, open code that sanity-checks the size of the data payload against the length of the RPC Call message has to be re-implemented to use xdr_stream infrastructure. Signed-off-by: Chuck Lever --- fs/nfsd/nfs3xdr.c | 51 ++++++++++++++++++++------------------------------- 1 file changed, 20 insertions(+), 31 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index ff98eae5db81..0aafb096de91 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -405,52 +405,41 @@ nfs3svc_decode_readargs(struct svc_rqst *rqstp, __be32 *p) int nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_writeargs *args = rqstp->rq_argp; - unsigned int len, hdr, dlen; u32 max_blocksize = svc_max_payload(rqstp); struct kvec *head = rqstp->rq_arg.head; struct kvec *tail = rqstp->rq_arg.tail; + size_t remaining; - p = decode_fh(p, &args->fh); - if (!p) + if (!svcxdr_decode_nfs_fh3(xdr, &args->fh)) return 0; - p = xdr_decode_hyper(p, &args->offset); - - args->count = ntohl(*p++); - args->stable = ntohl(*p++); - len = args->len = ntohl(*p++); - if ((void *)p > head->iov_base + head->iov_len) + if (xdr_stream_decode_u64(xdr, &args->offset) < 0) return 0; - /* - * The count must equal the amount of data passed. - */ - if (args->count != args->len) + if (xdr_stream_decode_u32(xdr, &args->count) < 0) + return 0; + if (xdr_stream_decode_u32(xdr, &args->stable) < 0) return 0; - /* - * Check to make sure that we got the right number of - * bytes. - */ - hdr = (void*)p - head->iov_base; - dlen = head->iov_len + rqstp->rq_arg.page_len + tail->iov_len - hdr; - /* - * Round the length of the data which was specified up to - * the next multiple of XDR units and then compare that - * against the length which was actually received. - * Note that when RPCSEC/GSS (for example) is used, the - * data buffer can be padded so dlen might be larger - * than required. It must never be smaller. - */ - if (dlen < XDR_QUADLEN(len)*4) + /* opaque data */ + if (xdr_stream_decode_u32(xdr, &args->len) < 0) return 0; + /* request sanity */ + if (args->count != args->len) + return 0; + remaining = head->iov_len + rqstp->rq_arg.page_len + tail->iov_len; + remaining -= xdr_stream_pos(xdr); + if (remaining < xdr_align_size(args->len)) + return 0; if (args->count > max_blocksize) { args->count = max_blocksize; - len = args->len = max_blocksize; + args->len = max_blocksize; } - args->first.iov_base = (void *)p; - args->first.iov_len = head->iov_len - hdr; + args->first.iov_base = xdr->p; + args->first.iov_len = head->iov_len - xdr_stream_pos(xdr); + return 1; } From patchwork Tue Jan 5 15:30:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999255 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 21550C433E0 for ; Tue, 5 Jan 2021 15:30:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EDD2F22AAA for ; Tue, 5 Jan 2021 15:30:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727163AbhAEPaq (ORCPT ); Tue, 5 Jan 2021 10:30:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726984AbhAEPaq (ORCPT ); Tue, 5 Jan 2021 10:30:46 -0500 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22AC9C0617A2 for ; Tue, 5 Jan 2021 07:30:26 -0800 (PST) Received: by mail-qt1-x82f.google.com with SMTP id v5so21034121qtv.7 for ; Tue, 05 Jan 2021 07:30: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=nqH4pO1Cnsm5uRCc488sXPf62GQEp80KVq1oMzCX/M0=; b=FCGfKJ5YrLFVGklKZeYb89YI+hvxhBgSF4oEEXu9t+IlQXoPC6lCgNx3fPI/H2Lnc9 xs/24QWwGEA1zQo38eZ96oIVr9ePlsXlDu8FtFToi57kJxr400AHM+5wndQwNUcm7DOq ZrlFpCvuGS2cBE2ye6tnkiWxw9S7pmuPNMxD1ALuhtOiiDnd/Vp5FY+Kr6jdLDSVcG0S wbHkvX4SIY2QP+6DfH1FWq2tgS54zbgVwtKOpV9BflPF9ijPinXUTzJUS7kIcTEJLEj7 2Wv7iLT0WkTtBpTc4nzUj0QGXwBsR40yfV+GFXs4gYRCMKglcM0pfIkT/YbaBeeQamls KZbA== 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=nqH4pO1Cnsm5uRCc488sXPf62GQEp80KVq1oMzCX/M0=; b=GHSZnzE0mb2u2ppCp5R0FuMqSugaMXBbwAvFRt1EkmqB/UGn4Vmfb8rrCDnqUuPuOM TPPVaH7Us13ry9Oo8i6Z8veLmizgd9Sme6/INGeTRNkfC7fYS3lAsKtxJca//8nSDI3f 3ArFE3HITNrPKFsddaVNysow6/Z60t4hbpwccoKk9ZV2nZ4fCHDmJea2jdl608rjHZJW tUSUN+9L+Go1e15/aq33BBw0C2WsFo1WE/4RM6UFApwSbdbUfJk5+5dy9ZDkSjaLEUC+ vMuiZ2YqsZZBxFzbjr2h/w7grQ1SpwQuVQS8mW37HcYnciBRW5s5idi/ssDlA2FVF9ND u8bQ== X-Gm-Message-State: AOAM530pqDUcmdhkm/FOjHKQ1FhCKNyz7pt/dW/xn/eqhMMpM8MIwVsU JM57vb6wL/p/Yeqf2uC/zGj4xUdu/ys= X-Google-Smtp-Source: ABdhPJyinUhOPIRVdqzlW2xIQrDMd3jZe1P6KvFTqvSazsGJ87scnP1cRV0wut7kgNzZ/sQqpiIAGQ== X-Received: by 2002:ac8:5c0e:: with SMTP id i14mr44184qti.328.1609860625016; Tue, 05 Jan 2021 07:30: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 h26sm52036qtq.18.2021.01.05.07.30.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:30: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 105FUNBm020844 for ; Tue, 5 Jan 2021 15:30:23 GMT Subject: [PATCH v1 08/42] NFSD: Update READLINK3arg decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:30:23 -0500 Message-ID: <160986062340.5532.17166784261045454715.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 The NFSv3 READLINK request takes a single filehandle, so it can re-use GETATTR's decoder. Signed-off-by: Chuck Lever --- fs/nfsd/nfs3proc.c | 9 +++++---- fs/nfsd/nfs3xdr.c | 13 ------------- fs/nfsd/xdr3.h | 6 ------ 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index acdf47179a38..9e289e0f439b 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -124,15 +124,16 @@ nfsd3_proc_access(struct svc_rqst *rqstp) static __be32 nfsd3_proc_readlink(struct svc_rqst *rqstp) { - struct nfsd3_readlinkargs *argp = rqstp->rq_argp; + struct nfsd_fhandle *argp = rqstp->rq_argp; struct nfsd3_readlinkres *resp = rqstp->rq_resp; + char *buffer = page_address(*(rqstp->rq_next_page++)); dprintk("nfsd: READLINK(3) %s\n", SVCFH_fmt(&argp->fh)); /* Read the symlink. */ fh_copy(&resp->fh, &argp->fh); resp->len = NFS3_MAXPATHLEN; - resp->status = nfsd_readlink(rqstp, &resp->fh, argp->buffer, &resp->len); + resp->status = nfsd_readlink(rqstp, &resp->fh, buffer, &resp->len); return rpc_success; } @@ -768,10 +769,10 @@ static const struct svc_procedure nfsd_procedures3[22] = { }, [NFS3PROC_READLINK] = { .pc_func = nfsd3_proc_readlink, - .pc_decode = nfs3svc_decode_readlinkargs, + .pc_decode = nfs3svc_decode_fhandleargs, .pc_encode = nfs3svc_encode_readlinkres, .pc_release = nfs3svc_release_fhandle, - .pc_argsize = sizeof(struct nfsd3_readlinkargs), + .pc_argsize = sizeof(struct nfsd_fhandle), .pc_ressize = sizeof(struct nfsd3_readlinkres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+pAT+1+NFS3_MAXPATHLEN/4, diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 0aafb096de91..db1d6ebf1353 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -543,19 +543,6 @@ nfs3svc_decode_renameargs(struct svc_rqst *rqstp, __be32 *p) return xdr_argsize_check(rqstp, p); } -int -nfs3svc_decode_readlinkargs(struct svc_rqst *rqstp, __be32 *p) -{ - struct nfsd3_readlinkargs *args = rqstp->rq_argp; - - p = decode_fh(p, &args->fh); - if (!p) - return 0; - args->buffer = page_address(*(rqstp->rq_next_page++)); - - return xdr_argsize_check(rqstp, p); -} - int nfs3svc_decode_linkargs(struct svc_rqst *rqstp, __be32 *p) { diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h index 7dfeeaa4e1df..08f909142ddf 100644 --- a/fs/nfsd/xdr3.h +++ b/fs/nfsd/xdr3.h @@ -70,11 +70,6 @@ struct nfsd3_renameargs { unsigned int tlen; }; -struct nfsd3_readlinkargs { - struct svc_fh fh; - char * buffer; -}; - struct nfsd3_linkargs { struct svc_fh ffh; struct svc_fh tfh; @@ -282,7 +277,6 @@ int nfs3svc_decode_createargs(struct svc_rqst *, __be32 *); int nfs3svc_decode_mkdirargs(struct svc_rqst *, __be32 *); int nfs3svc_decode_mknodargs(struct svc_rqst *, __be32 *); int nfs3svc_decode_renameargs(struct svc_rqst *, __be32 *); -int nfs3svc_decode_readlinkargs(struct svc_rqst *, __be32 *); int nfs3svc_decode_linkargs(struct svc_rqst *, __be32 *); int nfs3svc_decode_symlinkargs(struct svc_rqst *, __be32 *); int nfs3svc_decode_readdirargs(struct svc_rqst *, __be32 *); From patchwork Tue Jan 5 15:30:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999271 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 33AA6C433E0 for ; Tue, 5 Jan 2021 15:31:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CFDD22AAA for ; Tue, 5 Jan 2021 15:31:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727795AbhAEPbM (ORCPT ); Tue, 5 Jan 2021 10:31:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727680AbhAEPbL (ORCPT ); Tue, 5 Jan 2021 10:31:11 -0500 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D670C061574 for ; Tue, 5 Jan 2021 07:30:31 -0800 (PST) Received: by mail-qk1-x72a.google.com with SMTP id c7so26778025qke.1 for ; Tue, 05 Jan 2021 07:30: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=His8wXJJ6Md9Zao5EcfjkbJnoHe65nCQDA9M06KsFag=; b=imlLuH14PuPSUUsMUMxDcbxAldovNPcJxBUYDpkU9qXg5SH8yhT1TTJzRzR928zknm 1UqNNuarg6bGtECF9o9ICDV9VUxxG1v1pLhHK4pSDc6G3zYlcxTIHq1t4AgCBnjFrlLb l4i5J6oz8Eh7yGyq02ztwd52TtS5lkEiwHJtl/Uh9tCXShcmL8cUCnM2oO8JsMZpgnmY 3bE8p6J4ylFXzv39BVEKTfTO7tN2ApwEYKVZip/oO4XEoBf87xdK7FCFjZITo9SDhaB6 l0a3e5UFqlQb2U7GZZsSNPXaNit375JkO3XCbGk8GJXNW+TiUOQ0YB9iHZe64HBWL4Qh kykw== 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=His8wXJJ6Md9Zao5EcfjkbJnoHe65nCQDA9M06KsFag=; b=q49mlQKw43SI4X4zKkdWV8+LuJostZqZiLEGgpsy5g4Q+/wLEoelXmRo2z+i1eU3UG lk1GehDcn/TnEYIL5YQBYQKZNz/2h92DIF16AdeYjRjGIBhO2rg4YFnnSgOay60eaOfU exT1dQ/YUtulIZqXGguXyzQKc2RmsCdu6FhfkxtBj4WKGg6gwkzvIGfm9Rf20QO7Nme6 zaYwK3xnRL7RH3g9RdbHKdXs3KBUDRiXctL57s/MpOo1sDtb70qSCvqpA6eqroSyB9uM hN9fTyYAElrVIFNQa+x70KT7TTqogdscCrlzJrbi/OS1AjJtWwTWRc4KPyLTwbDRw1PS Qxsg== X-Gm-Message-State: AOAM53336SPINUQYkKLEa+2LdCOHn67QO+XlruAL39iYts/ljtgkIaUk GfC6aL0n8gjasE6LSxTjBKUDrh9h9Ns= X-Google-Smtp-Source: ABdhPJxYYsIO/EU+af78mPfT8/cFXHPfE98urosvaJxVPTx30fSC9YEonGMTOtpMbr7Ns0VMUS5ADg== X-Received: by 2002:a37:9c82:: with SMTP id f124mr2000qke.369.1609860630333; Tue, 05 Jan 2021 07:30: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 b15sm27353qta.75.2021.01.05.07.30.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:30: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 105FUSOL020847 for ; Tue, 5 Jan 2021 15:30:28 GMT Subject: [PATCH v1 09/42] NFSD: Fix returned READDIR offset cookie From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:30:28 -0500 Message-ID: <160986062865.5532.2413664838273345962.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 Code inspection shows that the server's NFSv3 READDIR implementation handles offset cookies slightly differently than the NFSv2 READDIR, NFSv3 READDIRPLUS, and NFSv4 READDIR implementations, and there doesn't seem to be any need for this difference. As a clean up, I copied the logic from nfsd3_proc_readdirplus(). Signed-off-by: Chuck Lever --- fs/nfsd/nfs3proc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index 9e289e0f439b..7ea2fb127f6f 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -444,6 +444,7 @@ nfsd3_proc_readdir(struct svc_rqst *rqstp) struct nfsd3_readdirargs *argp = rqstp->rq_argp; struct nfsd3_readdirres *resp = rqstp->rq_resp; int count = 0; + loff_t offset; struct page **p; caddr_t page_addr = NULL; @@ -462,7 +463,9 @@ nfsd3_proc_readdir(struct svc_rqst *rqstp) resp->common.err = nfs_ok; resp->buffer = argp->buffer; resp->rqstp = rqstp; - resp->status = nfsd_readdir(rqstp, &resp->fh, (loff_t *)&argp->cookie, + offset = argp->cookie; + + resp->status = nfsd_readdir(rqstp, &resp->fh, &offset, &resp->common, nfs3svc_encode_entry); memcpy(resp->verf, argp->verf, 8); count = 0; @@ -478,8 +481,6 @@ nfsd3_proc_readdir(struct svc_rqst *rqstp) } resp->count = count >> 2; if (resp->offset) { - loff_t offset = argp->cookie; - if (unlikely(resp->offset1)) { /* we ended up with offset on a page boundary */ *resp->offset = htonl(offset >> 32); From patchwork Tue Jan 5 15:30:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999257 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 2A02BC433DB for ; Tue, 5 Jan 2021 15:30:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC4AD22AAA for ; Tue, 5 Jan 2021 15:30:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726718AbhAEPaw (ORCPT ); Tue, 5 Jan 2021 10:30:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725925AbhAEPaw (ORCPT ); Tue, 5 Jan 2021 10:30:52 -0500 Received: from mail-qk1-x736.google.com (mail-qk1-x736.google.com [IPv6:2607:f8b0:4864:20::736]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8084AC061795 for ; Tue, 5 Jan 2021 07:30:36 -0800 (PST) Received: by mail-qk1-x736.google.com with SMTP id 19so26747017qkm.8 for ; Tue, 05 Jan 2021 07:30: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=9dSk3Mv8A4t4rF3p0ZZ95kkr2TeDYiyldkVbX+1Fsjk=; b=qo07Y8F0W6aqDFuuoD/NoXlOl5TELk1vIogxPd+ba+S28ZTq7mqYwwYmgadn0XOWYr EkhJnxSJKHgPP1lz9g/X72So/wybq76LPzNiHKbEhNJHr6Gdlgalo+pg1t54WpxZvw9e HP+DRdkh3J7SzyFIlPh1w2wLHm0CPc46OKq6BgnCF59s21u4u9yKLaxub1+puDUgWd1O 2LEe6ryzsZAywrrS4tK3181nN5jbAMN36hCRnqoqyHRUHzKHgd1bWYWdyq4HCCotHy8t JIAYIXvlw+Sjnk4JzxxBIjl+bte+t6vLU9iUdavR1bw//jdXzSviyo8+rIVIZQfEQr1I 3/Iw== 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=9dSk3Mv8A4t4rF3p0ZZ95kkr2TeDYiyldkVbX+1Fsjk=; b=hGbrlZKSA+YhuHjDaSWIVHWNnZFfLcq/g4ccrIj0Bqw1/8aKxNLjp6PSmOqEEmGH8s e4BGx2dYcI2M+GXCzJfIg5klViBv2QAXL0L9kWHsTpSF+Ys9RGiAFTQvC3ZXYbrqfJgJ 43CPeC/FpPPLcesvYGXBNlY0usN11D9DqDxYU2U01nmuUvnTiVh1sZ3LLWyBPw/+xEAG 0obEC9j+gO5UZs6caClSdV02ZvWOQGZH2G/mHRfXc3k80rjTOWrb7kDcQ9lujYrQBsR+ e4FT4M5nthC2WYHYOmFIiuehPXx57+zQEzZpG95RcWYZmOKAezbeFHjq9iOJw6rYfuX9 16Eg== X-Gm-Message-State: AOAM530pO/hukw5KZ6V4mIiMO5lDfTamuEc6hXxmaCFpWtA/WzXbtozA 8BmZSHdE3Et9ft9TdGub3vuN8hc/PUE= X-Google-Smtp-Source: ABdhPJy3cwp+Hu8d3T5WBhDMqzC0bc6xD43RNoeuCc+fv0URNJ4dCiQwRd4e01qlmqQet4G2I91F4g== X-Received: by 2002:a37:544:: with SMTP id 65mr67764qkf.204.1609860635400; Tue, 05 Jan 2021 07:30: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 e11sm47294qtg.46.2021.01.05.07.30.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:30: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 105FUX7E020850 for ; Tue, 5 Jan 2021 15:30:33 GMT Subject: [PATCH v1 10/42] NFSD: Add helper to set up the pages where the dirlist is encoded From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:30:33 -0500 Message-ID: <160986063393.5532.9597204694840100223.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 that is used by both READDIR and READDIRPLUS to build the dirlist in the Reply. Because this code is not related to decoding READ arguments, it is moved to a more appropriate spot. Signed-off-by: Chuck Lever --- fs/nfsd/nfs3proc.c | 29 +++++++++++++++++++---------- fs/nfsd/nfs3xdr.c | 20 -------------------- fs/nfsd/xdr3.h | 1 - 3 files changed, 19 insertions(+), 31 deletions(-) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index 7ea2fb127f6f..8675851199f8 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -435,6 +435,23 @@ nfsd3_proc_link(struct svc_rqst *rqstp) return rpc_success; } +static void nfsd3_init_dirlist_pages(struct svc_rqst *rqstp, + struct nfsd3_readdirres *resp, + int count) +{ + count = min_t(u32, count, svc_max_payload(rqstp)); + + /* Convert byte count to number of words (i.e. >> 2), + * and reserve room for the NULL ptr & eof flag (-2 words) */ + resp->buflen = (count >> 2) - 2; + + resp->buffer = page_address(*rqstp->rq_next_page); + while (count > 0) { + rqstp->rq_next_page++; + count -= PAGE_SIZE; + } +} + /* * Read a portion of a directory. */ @@ -452,16 +469,12 @@ nfsd3_proc_readdir(struct svc_rqst *rqstp) SVCFH_fmt(&argp->fh), argp->count, (u32) argp->cookie); - /* Make sure we've room for the NULL ptr & eof flag, and shrink to - * client read size */ - count = (argp->count >> 2) - 2; + nfsd3_init_dirlist_pages(rqstp, resp, argp->count); /* Read directory and encode entries on the fly */ fh_copy(&resp->fh, &argp->fh); - resp->buflen = count; resp->common.err = nfs_ok; - resp->buffer = argp->buffer; resp->rqstp = rqstp; offset = argp->cookie; @@ -513,16 +526,12 @@ nfsd3_proc_readdirplus(struct svc_rqst *rqstp) SVCFH_fmt(&argp->fh), argp->count, (u32) argp->cookie); - /* Convert byte count to number of words (i.e. >> 2), - * and reserve room for the NULL ptr & eof flag (-2 words) */ - resp->count = (argp->count >> 2) - 2; + nfsd3_init_dirlist_pages(rqstp, resp, argp->count); /* Read directory and encode entries on the fly */ fh_copy(&resp->fh, &argp->fh); resp->common.err = nfs_ok; - resp->buffer = argp->buffer; - resp->buflen = resp->count; resp->rqstp = rqstp; offset = argp->cookie; diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index db1d6ebf1353..b601f0c6156f 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -560,8 +560,6 @@ int nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p) { struct nfsd3_readdirargs *args = rqstp->rq_argp; - int len; - u32 max_blocksize = svc_max_payload(rqstp); p = decode_fh(p, &args->fh); if (!p) @@ -570,14 +568,6 @@ nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p) args->verf = p; p += 2; args->dircount = ~0; args->count = ntohl(*p++); - len = args->count = min_t(u32, args->count, max_blocksize); - - while (len > 0) { - struct page *p = *(rqstp->rq_next_page++); - if (!args->buffer) - args->buffer = page_address(p); - len -= PAGE_SIZE; - } return xdr_argsize_check(rqstp, p); } @@ -586,8 +576,6 @@ int nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, __be32 *p) { struct nfsd3_readdirargs *args = rqstp->rq_argp; - int len; - u32 max_blocksize = svc_max_payload(rqstp); p = decode_fh(p, &args->fh); if (!p) @@ -597,14 +585,6 @@ nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, __be32 *p) args->dircount = ntohl(*p++); args->count = ntohl(*p++); - len = args->count = min(args->count, max_blocksize); - while (len > 0) { - struct page *p = *(rqstp->rq_next_page++); - if (!args->buffer) - args->buffer = page_address(p); - len -= PAGE_SIZE; - } - return xdr_argsize_check(rqstp, p); } diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h index 08f909142ddf..789a364d5e69 100644 --- a/fs/nfsd/xdr3.h +++ b/fs/nfsd/xdr3.h @@ -93,7 +93,6 @@ struct nfsd3_readdirargs { __u32 dircount; __u32 count; __be32 * verf; - __be32 * buffer; }; struct nfsd3_commitargs { From patchwork Tue Jan 5 15:30:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999259 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 44CCCC433E6 for ; Tue, 5 Jan 2021 15:30:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 18AAD22AAA for ; Tue, 5 Jan 2021 15:30:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727336AbhAEPa5 (ORCPT ); Tue, 5 Jan 2021 10:30:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727334AbhAEPa4 (ORCPT ); Tue, 5 Jan 2021 10:30:56 -0500 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFD0DC061796 for ; Tue, 5 Jan 2021 07:30:41 -0800 (PST) Received: by mail-qt1-x835.google.com with SMTP id 7so21091394qtp.1 for ; Tue, 05 Jan 2021 07:30:41 -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=6KD2ww9giGctRKj5g3zpnKTnSzfsLVKrA4a9YvvdysY=; b=AlDfu+bjxNuyqEOlWWiYcGJ0uwu8vPJiwc42kl0cuKgXKh3/8SHhp+Xh7eOHSQ+bzP AGheHiKeKVJq7QwfLLa32nSIA7bB5MAoYHt50r/MPTyh/RM4KN7rGUgVcqyiiBgd8ZeK dOM3Imj0OKI66ygKACRb2tJ6w7cFfWWlxgVnUiC4oGtr74ipsKu1KLOrTC8qGGEuiZ2q zLvVN9AABzt3pT5sdpwtvI90AIMaSXNMDQP6Q32Z3SsAkQCudo+QShpnCVxZ3v9UzLit Jq2il9ONyA1tW24TkPfcLmDJV64ujCzw2x4Q9YPcffVDI+wHM8zT0+QRhQ8ItJ6M7SxG H6Wg== 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=6KD2ww9giGctRKj5g3zpnKTnSzfsLVKrA4a9YvvdysY=; b=Ero4v+l6MIu70Zcy8bJxZP5QQOKGSF4tNj1RNgMApLDkFffIxKqJ30lvUUK6DCCe9X 6XtSm9z4XYbrWGOM6Adta9sT9F8SJq3TU504b/xKsX9kLD0DtiA6LftImvlqIhxv1O17 CeXpABXam8NybSGLTYFnBXCW4aZkEWQ5BZr8Kq8oP7d1u9IUUg++FWBAWR5hX9ASvbz1 /917tO0pPoXtD2NUYQTrAvrOlIgnqIjj7/vL0XyeRP5WqBvdzOvg0fas+GiNh8s0IWnE Bicf2j7pYZEMm1uPPorDEdIOjCJmxDMqafZ1jvT7Igxe84pB6TFw4KPiH0Fib02/iVjT xE+g== X-Gm-Message-State: AOAM5315XFuWuD7jWmj9GNGrjJMHz9Ij33uqII+dbhHiGFesclOTmf2p O8OBD1+puYeuqn4QY4T/i0KTwgPgxRs= X-Google-Smtp-Source: ABdhPJzD27JwH74RG4QyMARtqSyHC4BVKGiS6XC8enEPWSQeGLSILN2VVhIKjLwlE01Ah3Wa4EJi+Q== X-Received: by 2002:ac8:47da:: with SMTP id d26mr85634qtr.4.1609860640658; Tue, 05 Jan 2021 07:30: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 c2sm129980qke.109.2021.01.05.07.30.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:30: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 105FUdE6020853 for ; Tue, 5 Jan 2021 15:30:39 GMT Subject: [PATCH v1 11/42] NFSD: Update READDIR3args decoders to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:30:39 -0500 Message-ID: <160986063900.5532.12435650481339734359.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 As an additional clean up, neither nfsd3_proc_readdir() nor nfsd3_proc_readdirplus() make use of the dircount argument, so remove it from struct nfsd3_readdirargs. Signed-off-by: Chuck Lever --- fs/nfsd/nfs3xdr.c | 38 ++++++++++++++++++++++++-------------- fs/nfsd/xdr3.h | 1 - 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index b601f0c6156f..6167955475e7 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -559,33 +559,43 @@ nfs3svc_decode_linkargs(struct svc_rqst *rqstp, __be32 *p) int nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_readdirargs *args = rqstp->rq_argp; - p = decode_fh(p, &args->fh); - if (!p) + if (!svcxdr_decode_nfs_fh3(xdr, &args->fh)) + return 0; + if (xdr_stream_decode_u64(xdr, &args->cookie) < 0) + return 0; + args->verf = xdr_inline_decode(xdr, NFS3_COOKIEVERFSIZE); + if (!args->verf) + return 0; + if (xdr_stream_decode_u32(xdr, &args->count) < 0) return 0; - p = xdr_decode_hyper(p, &args->cookie); - args->verf = p; p += 2; - args->dircount = ~0; - args->count = ntohl(*p++); - return xdr_argsize_check(rqstp, p); + return 1; } int nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_readdirargs *args = rqstp->rq_argp; + u32 dircount; - p = decode_fh(p, &args->fh); - if (!p) + if (!svcxdr_decode_nfs_fh3(xdr, &args->fh)) + return 0; + if (xdr_stream_decode_u64(xdr, &args->cookie) < 0) + return 0; + args->verf = xdr_inline_decode(xdr, NFS3_COOKIEVERFSIZE); + if (!args->verf) + return 0; + /* dircount is ignored */ + if (xdr_stream_decode_u32(xdr, &dircount) < 0) + return 0; + if (xdr_stream_decode_u32(xdr, &args->count) < 0) return 0; - p = xdr_decode_hyper(p, &args->cookie); - args->verf = p; p += 2; - args->dircount = ntohl(*p++); - args->count = ntohl(*p++); - return xdr_argsize_check(rqstp, p); + return 1; } int diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h index 789a364d5e69..64af5b01c5d7 100644 --- a/fs/nfsd/xdr3.h +++ b/fs/nfsd/xdr3.h @@ -90,7 +90,6 @@ struct nfsd3_symlinkargs { struct nfsd3_readdirargs { struct svc_fh fh; __u64 cookie; - __u32 dircount; __u32 count; __be32 * verf; }; From patchwork Tue Jan 5 15:30:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999265 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 50B14C433E6 for ; Tue, 5 Jan 2021 15:31:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A03E22AAA for ; Tue, 5 Jan 2021 15:31:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727481AbhAEPbC (ORCPT ); Tue, 5 Jan 2021 10:31:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727334AbhAEPbC (ORCPT ); Tue, 5 Jan 2021 10:31:02 -0500 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3559C061798 for ; Tue, 5 Jan 2021 07:30:46 -0800 (PST) Received: by mail-qt1-x82c.google.com with SMTP id a6so21082312qtw.6 for ; Tue, 05 Jan 2021 07:30: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=mp4mJpNywkRAiHMDm8UhPidX7v6cBTArsuTPwx8KSRY=; b=us9cSBiYEBz0PM9iCHp6nMj3cXc/j2PSSY8ap5TOKegUkm8ahpIzU1w0XbaWUTHirE mkxJ2pO9oGXhWzuIBpwaFAmToJjHDhCevzwr0MBRKW/TGr8/xXl7g0E0dkGwOv7wowcF W3UW+XyM9aUc8DaVTVnS83n9J8mIiLsKMj57eE6eiePOF4KNFff3BS/NHS8FVluaW7o1 Jlb9dpsZigINOv38kR1MaXlgNwOYYyA/Cb8/Nafhl6VpepZnTvY1NsUmzUc8K5gBWX/u XvGH8WNCYYtq3M+nI69Z+QMRS1gGD73iu0kYaWE+sXpyJTMOkf3plgAvrB4k61062rSa Ja6A== 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=mp4mJpNywkRAiHMDm8UhPidX7v6cBTArsuTPwx8KSRY=; b=ZWwHQyXHbTEfTlYvPp2g/ZFDgwT+gZvftsXgnibrXNeLpgNNQ/rz2UFA6hYXGvaSu6 heVpSDSlcwjY8VOMB9Ia7ZvSsVIVVyZJMzRpwkuwSrainJIgpX0pDa0rsDNzNqay+70K APDrqxXIzJUWcCkB2CFFEwo8AaD1f08yLzcULLgdv4QMHgMUtfB4NAnHlo2/Z6X4qDek ww5QTeD6olLqIE/RxcK4H2NXzcW/D0jCsie17Aw2MKy8BY2YHcWn8y7g5MEGjjWBwKBQ ofc/JJyFlH20bYR1noFeGhVQUaRvdhYPhJW9HgQ6ToMI/GxPvx5suU9vlFnSDP7jyumF lfLw== X-Gm-Message-State: AOAM532W7hfGXEcndQNVrbbWpsXGwjGdVi6U/h+7g+SJcj4Xo4GB2CIm LXDXqmtNYyuzkUmOsNozMfPtQrVUxZM= X-Google-Smtp-Source: ABdhPJz8xB4fXGMSnVVFDSMJZN5AySXxE9PvRjfsUQNdcNJoHtrUMtXY0prO8B7qU6ne3zKzym0CIQ== X-Received: by 2002:ac8:7507:: with SMTP id u7mr15191qtq.217.1609860645752; Tue, 05 Jan 2021 07:30:45 -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 134sm147311qkh.62.2021.01.05.07.30.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:30: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 105FUiSk020856 for ; Tue, 5 Jan 2021 15:30:44 GMT Subject: [PATCH v1 12/42] NFSD: Update COMMIT3arg decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:30:44 -0500 Message-ID: <160986064429.5532.15980289615760697662.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs3xdr.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 6167955475e7..bda6f3aed1e3 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -601,14 +601,17 @@ nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, __be32 *p) int nfs3svc_decode_commitargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_commitargs *args = rqstp->rq_argp; - p = decode_fh(p, &args->fh); - if (!p) + + if (!svcxdr_decode_nfs_fh3(xdr, &args->fh)) + return 0; + if (xdr_stream_decode_u64(xdr, &args->offset) < 0) + return 0; + if (xdr_stream_decode_u32(xdr, &args->count) < 0) return 0; - p = xdr_decode_hyper(p, &args->offset); - args->count = ntohl(*p++); - return xdr_argsize_check(rqstp, p); + return 1; } /* From patchwork Tue Jan 5 15:30:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999267 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 8D281C433E0 for ; Tue, 5 Jan 2021 15:31:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68E5922AAA for ; Tue, 5 Jan 2021 15:31:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727571AbhAEPbH (ORCPT ); Tue, 5 Jan 2021 10:31:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727561AbhAEPbH (ORCPT ); Tue, 5 Jan 2021 10:31:07 -0500 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E09AC06179A for ; Tue, 5 Jan 2021 07:30:52 -0800 (PST) Received: by mail-qt1-x832.google.com with SMTP id j26so21033436qtq.8 for ; Tue, 05 Jan 2021 07:30: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=uVePB3ddDPjDzwgaIDdJ/pXJi4FgraPntM5j5zHTfSs=; b=TNhhSYLOpNMOMs5iPahMm07jTfwP0ihpJcj+z79dQ1jQlfp4DDQawwQVKB6bgiONOM zxxzowEIqEHZn2wcyeabXNGSVKgWg9CeYSCBKWrLhWIX5OWhMSI/7OTLJTun7J1LA1V0 0aArjmlTHE5pBfPv38LBPD+H7x8TT7Xxqexl2OzIBL3UqHYsZpCYmR6yIPys1oYkHr5e tJDTuvp2ttZ1tuG1KZyquF3BfVAvW1RTArZBb4EyQwoyCOwb8zmGf0ke2C1V190FEHuL 5PJ+9Tdk0MizcxUiM3QhvnLaLNa2QgEr4xwxnNqOd9/eoiZUEGMqDY8FkZpdpa8MKCFc ErGA== 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=uVePB3ddDPjDzwgaIDdJ/pXJi4FgraPntM5j5zHTfSs=; b=EIUqxbf6U5txN8bUDy5tt/y87Jko4ENndbnhsk6tkFfk+RGwH1ycGApFNqvs0qYzfm w0kToI+D76LMs4ALOnUPzezCc5tDSU8TBt5EBFGuahzZ9hh5K3VoZzPWxIHM8KqQFleL a8rVbFo9SC6pBtzgwusDqxmu4Jr26NzJesdTpaAzQaMEAmN+2KMlGF/wsFDTbjW4hk/3 SOrO/nSQGDqWpJax+jS+iRIXp1mWtDW8JPJm6sfKuZ/npOasm4upw2tXjtr+vVqoE3ON AEVt9rr5eSL70rC6g4QOh1kOuKGsLx2z/VMpaFRAuxAZ5cvmEZg6GszICINKAG0s2/p3 +xRA== X-Gm-Message-State: AOAM530KIAgniapi8DNcIHW5gmaFpIxbrlE3r7IQXBdRIuOJRY8iltEY ouzndZyfUWOf9dd4Ju6z+IArck3YLns= X-Google-Smtp-Source: ABdhPJxF44k07OD5nrCnphMMJ64d5W/HtWoohT7DnUjXmXWuMZjBeg9b1DqkLQRBeY2htTWFUTW3lw== X-Received: by 2002:ac8:4986:: with SMTP id f6mr34981qtq.43.1609860651060; Tue, 05 Jan 2021 07:30: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 z15sm129754qkz.103.2021.01.05.07.30.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:30: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 105FUnge020859 for ; Tue, 5 Jan 2021 15:30:49 GMT Subject: [PATCH v1 13/42] NFSD: Update the NFSv3 DIROPargs decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:30:49 -0500 Message-ID: <160986064935.5532.1976966532601912001.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs3xdr.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index bda6f3aed1e3..7175b7315df0 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -117,6 +117,39 @@ decode_filename(__be32 *p, char **namp, unsigned int *lenp) return p; } +static bool +svcxdr_decode_filename3(struct xdr_stream *xdr, char **name, unsigned int *len) +{ + u32 size, i; + __be32 *p; + char *c; + + if (xdr_stream_decode_u32(xdr, &size) < 0) + return false; + if (size == 0 || size > NFS3_MAXNAMLEN) + return false; + p = xdr_inline_decode(xdr, size); + if (!p) + return false; + + *len = size; + *name = (char *)p; + for (i = 0, c = *name; i < size; i++, c++) { + if (*c == '\0' || *c == '/') + return false; + } + + return true; +} + +static bool +svcxdr_decode_diropargs3(struct xdr_stream *xdr, struct svc_fh *fhp, + char **name, unsigned int *len) +{ + return svcxdr_decode_nfs_fh3(xdr, fhp) && + svcxdr_decode_filename3(xdr, name, len); +} + static __be32 * decode_sattr3(__be32 *p, struct iattr *iap, struct user_namespace *userns) { @@ -363,13 +396,10 @@ nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, __be32 *p) int nfs3svc_decode_diropargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_diropargs *args = rqstp->rq_argp; - if (!(p = decode_fh(p, &args->fh)) - || !(p = decode_filename(p, &args->name, &args->len))) - return 0; - - return xdr_argsize_check(rqstp, p); + return svcxdr_decode_diropargs3(xdr, &args->fh, &args->name, &args->len); } int From patchwork Tue Jan 5 15:30:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999273 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 1F641C433DB for ; Tue, 5 Jan 2021 15:31:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EB27E22AAA for ; Tue, 5 Jan 2021 15:31:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727414AbhAEPbN (ORCPT ); Tue, 5 Jan 2021 10:31:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727529AbhAEPbM (ORCPT ); Tue, 5 Jan 2021 10:31:12 -0500 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24BA6C061795 for ; Tue, 5 Jan 2021 07:30:57 -0800 (PST) Received: by mail-qv1-xf30.google.com with SMTP id et9so14816459qvb.10 for ; Tue, 05 Jan 2021 07:30: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=PUqZzFFjRPa9e7AkqA7LUtYdd4p21auipb3gQ5t02bU=; b=Ga5Aex1TGlB5SRGuWXm/GdtHvi8BOj9zit1Lob7CLk4apyo2D+5PJtaGxTontQYUus pQnTf0JorvM07DIga0MS3Z68HoDbbfAhPo+Xefase36Dui4WaoODvvx4rAvUneHjluQx nNsIWjhroTijR28TMiIoZhul7PkoW5Ki87n2TYY/+gwgZwxIJ8gPiuPTQgxsBqURL6vz GA4aEu5en77Dm4JX1HzHqI5b/EDFxruuS4gWB/5QmyMS+/zNUhK228KRvupGcxTLwy7f TiMKZfXLx0Q0MiIYkxflHGXW88eepIPvdx4Bd4743wWAayltJ+3wZyOu8I+KGLxyz8Ay bvQQ== 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=PUqZzFFjRPa9e7AkqA7LUtYdd4p21auipb3gQ5t02bU=; b=mmKnjdv5S+58etDqeU8LCQdd/PEt5tt4CCScwz64puqAGPKqwHNXkRnlYfV8dZlxo2 F54lGiRStHJZJrk7remNwoN9j2P5dNzkB5Np6mXk+8xoEqN0DEP1vwGSkq7XEA0eoTUg 0ws4ATa2H0Pk3fJOxuS3oxW05UwtZyLEUDnKZgMjlPk0DNfdTSpHy5xGfyKPMHPnun+l QbOctgUeAz10UT1NCfPyR/Y1acO+DER9nJ11ncIn2aa4PedPpOXTWsO4ezBcLc6nd8TD WlYG68cDdpt8u3W1OZ/wDcFBXWubjoXsFIYWBfZBZrz+iYpLi+xY+ETP27VOjXmuWJ3d jUFw== X-Gm-Message-State: AOAM531l9ppMLU4l4KKeSEvKMSfT9CJ1EXvF0Z9rO1Zhced3sKuUtB15 dJ8TBpRl29h2UyvBsWb5wzTG1oj3o6s= X-Google-Smtp-Source: ABdhPJzVzHerZkuPS64cBeD1gccX397rDP0zq5rvux1fRwMzGqE0coTdRhlcQ2wCWq9pq8NDWqPQkQ== X-Received: by 2002:ad4:496c:: with SMTP id p12mr157621qvy.40.1609860656148; Tue, 05 Jan 2021 07:30: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 m65sm58568qtd.5.2021.01.05.07.30.55 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:30: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 105FUsII020862 for ; Tue, 5 Jan 2021 15:30:54 GMT Subject: [PATCH v1 14/42] NFSD: Update the RENAME3args decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:30:54 -0500 Message-ID: <160986065463.5532.8561383822279453786.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs3xdr.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 7175b7315df0..a5bbf9571821 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -562,15 +562,13 @@ nfs3svc_decode_mknodargs(struct svc_rqst *rqstp, __be32 *p) int nfs3svc_decode_renameargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_renameargs *args = rqstp->rq_argp; - if (!(p = decode_fh(p, &args->ffh)) - || !(p = decode_filename(p, &args->fname, &args->flen)) - || !(p = decode_fh(p, &args->tfh)) - || !(p = decode_filename(p, &args->tname, &args->tlen))) - return 0; - - return xdr_argsize_check(rqstp, p); + return svcxdr_decode_diropargs3(xdr, &args->ffh, + &args->fname, &args->flen) && + svcxdr_decode_diropargs3(xdr, &args->tfh, + &args->tname, &args->tlen); } int From patchwork Tue Jan 5 15:30:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999275 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 87496C433DB for ; Tue, 5 Jan 2021 15:31:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 51F2922AAA for ; Tue, 5 Jan 2021 15:31:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727827AbhAEPbS (ORCPT ); Tue, 5 Jan 2021 10:31:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727680AbhAEPbS (ORCPT ); Tue, 5 Jan 2021 10:31:18 -0500 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 005C4C061796 for ; Tue, 5 Jan 2021 07:31:02 -0800 (PST) Received: by mail-qk1-x72d.google.com with SMTP id v126so26712475qkd.11 for ; Tue, 05 Jan 2021 07:31: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=0Y8TkPWSG0A5AAw5oQM15pPVLvuUh1CSHPSe4B7fuGA=; b=U4lELdMKqMjxuhgPD2X2kZAQbLL4hAY7brXDJVUC/im4L6e3fpt+c6l2fStW6NrmXO PtUBDUocpMlfe31xGuTCWBDL/75gzM1jycqIjgnLRwvZOMdiECSdN7YPi4rz8fbcw8J+ SMQVMSEdowcXE/CPiAEPiY0ybFXDGZNyStQl+AGLlZYkFyEyZgmKiSVCkPVcUtVfHNtL rIeqg3jV6ba/Wdnrgh/OtJbvb3Mne3Ag4nqEOhFU9w3LGEh0vL8UClWP66NbucNJViQl Ap/MmB+CHPiNYC5ooi5IgZO74rFkLFpH6Pyy3veCjyC8G8PlbM+NDIX8tNWVKVH+Wlbk lYhw== 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=0Y8TkPWSG0A5AAw5oQM15pPVLvuUh1CSHPSe4B7fuGA=; b=nkIQShBEAuNeLjqXk1yuJ05dCvvOECpcZ0P5m4PhZQ8YytZLB4K5Owy+rTRekofPQS XR8C+77aIn/mGiSbDuHBaUcR4SCcNv4nStSwGPSHYbwpCVuBEWjXhSNT2k0bnT92xinI DMNr0YuheHtE+NSGKS6LuJYdUxDYoukvAeVdJp23fBrYJgC6H/nisJn4pl76Fg2CwY6E 759ojJlX88O4b2rJXWFYhdgOWe+K3KNpdJH5n26BUp3KPoOLDmEhPM8jz8QrTGSJGijl E43Jc1Uc7L0ear4zrhHtCywpxcyaTtDMcIJGqRYPuVYtePcolOR5d6XpG+rMt1DUks4N H2XQ== X-Gm-Message-State: AOAM5317DbZsaY1qjKndPUcjwSx3yhUkZSl19byzTG71cW4nPhVh7srt lx4aD4+HVcQ4imYiZokyDFU8ziPAtaw= X-Google-Smtp-Source: ABdhPJw092qalrCBTP5XMH0tWaqMqO5egz+tPS6INRa151474YIsYHjYtJyU3h1rwEac14eCZiRBdA== X-Received: by 2002:a05:620a:528:: with SMTP id h8mr91882qkh.40.1609860661932; Tue, 05 Jan 2021 07:31: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 n62sm127557qkn.125.2021.01.05.07.31.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:31: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 105FUxPl020865 for ; Tue, 5 Jan 2021 15:30:59 GMT Subject: [PATCH v1 15/42] NFSD: Update the LINK3args decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:30:59 -0500 Message-ID: <160986065972.5532.14792984567589235354.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs3xdr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index a5bbf9571821..ba5ec9cdafa1 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -574,14 +574,12 @@ nfs3svc_decode_renameargs(struct svc_rqst *rqstp, __be32 *p) int nfs3svc_decode_linkargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_linkargs *args = rqstp->rq_argp; - if (!(p = decode_fh(p, &args->ffh)) - || !(p = decode_fh(p, &args->tfh)) - || !(p = decode_filename(p, &args->tname, &args->tlen))) - return 0; - - return xdr_argsize_check(rqstp, p); + return svcxdr_decode_nfs_fh3(xdr, &args->ffh) && + svcxdr_decode_diropargs3(xdr, &args->tfh, + &args->tname, &args->tlen); } int From patchwork Tue Jan 5 15:31:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999277 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 8DEBDC433DB for ; Tue, 5 Jan 2021 15:31:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56E7522AAA for ; Tue, 5 Jan 2021 15:31:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727680AbhAEPbY (ORCPT ); Tue, 5 Jan 2021 10:31:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727529AbhAEPbX (ORCPT ); Tue, 5 Jan 2021 10:31:23 -0500 Received: from mail-qv1-xf36.google.com (mail-qv1-xf36.google.com [IPv6:2607:f8b0:4864:20::f36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5759AC061793 for ; Tue, 5 Jan 2021 07:31:08 -0800 (PST) Received: by mail-qv1-xf36.google.com with SMTP id p12so14792068qvj.13 for ; Tue, 05 Jan 2021 07:31: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=jCiRhMsV6l4X31uQ1X1AFI8v6fZQhcwaKsC66Yho4ys=; b=MBHlU1FIhlRWDfPjelnA7aXaE77OlizxFWINsSaJquhmwc0cuhqewOHuV6YdLSVhCo ElKnvnQCbwfFogha5we8Eml1GIg6GxVMi0p8PLzfBg+TH7MaCEO1cIijmuBvz0e0gQJv pEb9qo+4USI4MkyO7wAmXIwOvMvSTosAqPdr1Otd7m0J7Hlu7ibvpsXixqh+zfMq1MfJ +yEObBUaXJ/tQLagquwX4f7/7OthyhHv29oXznYfqgc9hrSPPiN9B5h0fcfd1GR0ay1c BqSMVc2TN4LuftCpRWBfDUhoBpsWXXdwDUZf1x2FM3p68vlSgannO38EkZzpO99xaAKh hw0w== 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=jCiRhMsV6l4X31uQ1X1AFI8v6fZQhcwaKsC66Yho4ys=; b=IT0Rv3Zf7vmJDMjFq0u1RSN+SMY8NKmOuxCS4RR1xqUn5ahDhaOrDrJdvZ4ysou2Qh TbnPgvOxChZAmqmdtsZEFfZaiNVKPCDqfRlEaJ0RKdKC/dllKijbSqhM6W0hlLnJmbXm t9Dd51QdBYWtEXoKDzFopcrx8/nzESA1AwjOZqls04m7cWYyBl0tsp3PrmQVxLSaZ7CX swVZV/eMrXp+RGbVr7BxaZFSkGJ6JCYt75tbbT/u5tHfsqSViWUSp99/Td83C48J0CFy v4VVBfVpFnJZwD0ke9cHRESfg35w9jsMlzmZU9f+yLnHpsiqRgkn33I9LoFQ06FI1Zuz heCA== X-Gm-Message-State: AOAM532yBzv3XNNF0jsz2XqtVN8y1BHNfC8ih3HtNcEYYmilooMLcPRI bbYSs1g9NgMNqJi55RCAN/+u4JkTat8= X-Google-Smtp-Source: ABdhPJzalMpho+npmPje33CvKELEK/b5Fp1mO/hcbfg8aAAsEoiDQZZ3fMhVNHhauM7x2xG3BGps9w== X-Received: by 2002:a05:6214:80d:: with SMTP id df13mr83027920qvb.10.1609860667108; Tue, 05 Jan 2021 07:31: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 p13sm144982qkg.80.2021.01.05.07.31.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:31: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 105FV5Rp020868 for ; Tue, 5 Jan 2021 15:31:05 GMT Subject: [PATCH v1 16/42] NFSD: Update the SETATTR3args decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:31:05 -0500 Message-ID: <160986066509.5532.6754187221390664193.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs3xdr.c | 138 +++++++++++++++++++++++++++++++++++++++------ include/uapi/linux/nfs3.h | 6 ++ 2 files changed, 127 insertions(+), 17 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index ba5ec9cdafa1..ef536fb00728 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -39,12 +39,18 @@ encode_time3(__be32 *p, struct timespec64 *time) return p; } -static __be32 * -decode_time3(__be32 *p, struct timespec64 *time) +static bool +svcxdr_decode_nfstime3(struct xdr_stream *xdr, struct timespec64 *timep) { - time->tv_sec = ntohl(*p++); - time->tv_nsec = ntohl(*p++); - return p; + __be32 *p; + + p = xdr_inline_decode(xdr, XDR_UNIT * 2); + if (!p) + return false; + timep->tv_sec = be32_to_cpup(p++); + timep->tv_nsec = be32_to_cpup(p); + + return true; } static bool @@ -150,6 +156,112 @@ svcxdr_decode_diropargs3(struct xdr_stream *xdr, struct svc_fh *fhp, svcxdr_decode_filename3(xdr, name, len); } +static bool +svcxdr_decode_sattr3(struct svc_rqst *rqstp, struct xdr_stream *xdr, + struct iattr *iap) +{ + u32 set_it; + + iap->ia_valid = 0; + + if (xdr_stream_decode_bool(xdr, &set_it) < 0) + return false; + if (set_it) { + u32 mode; + + if (xdr_stream_decode_u32(xdr, &mode) < 0) + return false; + iap->ia_valid |= ATTR_MODE; + iap->ia_mode = mode; + } + if (xdr_stream_decode_bool(xdr, &set_it) < 0) + return false; + if (set_it) { + u32 uid; + + if (xdr_stream_decode_u32(xdr, &uid) < 0) + return false; + iap->ia_uid = make_kuid(nfsd_user_namespace(rqstp), uid); + if (uid_valid(iap->ia_uid)) + iap->ia_valid |= ATTR_UID; + } + if (xdr_stream_decode_bool(xdr, &set_it) < 0) + return false; + if (set_it) { + u32 gid; + + if (xdr_stream_decode_u32(xdr, &gid) < 0) + return false; + iap->ia_gid = make_kgid(nfsd_user_namespace(rqstp), gid); + if (gid_valid(iap->ia_gid)) + iap->ia_valid |= ATTR_GID; + } + if (xdr_stream_decode_bool(xdr, &set_it) < 0) + return false; + if (set_it) { + u64 newsize; + + if (xdr_stream_decode_u64(xdr, &newsize) < 0) + return false; + iap->ia_valid |= ATTR_SIZE; + iap->ia_size = min_t(u64, newsize, NFS_OFFSET_MAX); + } + if (xdr_stream_decode_u32(xdr, &set_it) < 0) + return false; + switch (set_it) { + case DONT_CHANGE: + break; + case SET_TO_SERVER_TIME: + iap->ia_valid |= ATTR_ATIME; + break; + case SET_TO_CLIENT_TIME: + if (!svcxdr_decode_nfstime3(xdr, &iap->ia_atime)) + return false; + iap->ia_valid |= ATTR_ATIME | ATTR_ATIME_SET; + break; + default: + return false; + } + if (xdr_stream_decode_u32(xdr, &set_it) < 0) + return false; + switch (set_it) { + case DONT_CHANGE: + break; + case SET_TO_SERVER_TIME: + iap->ia_valid |= ATTR_MTIME; + break; + case SET_TO_CLIENT_TIME: + if (!svcxdr_decode_nfstime3(xdr, &iap->ia_mtime)) + return false; + iap->ia_valid |= ATTR_MTIME | ATTR_MTIME_SET; + break; + default: + return false; + } + + return true; +} + +static bool +svcxdr_decode_sattrguard3(struct xdr_stream *xdr, struct nfsd3_sattrargs *args) +{ + __be32 *p; + u32 check; + + if (xdr_stream_decode_bool(xdr, &check) < 0) + return false; + if (check) { + p = xdr_inline_decode(xdr, XDR_UNIT * 2); + if (!p) + return false; + args->check_guard = 1; + args->guardtime = be32_to_cpup(p); + } else + args->check_guard = 0; + + return true; +} + static __be32 * decode_sattr3(__be32 *p, struct iattr *iap, struct user_namespace *userns) { @@ -377,20 +489,12 @@ nfs3svc_decode_fhandleargs(struct svc_rqst *rqstp, __be32 *p) int nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_sattrargs *args = rqstp->rq_argp; - p = decode_fh(p, &args->fh); - if (!p) - return 0; - p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp)); - - if ((args->check_guard = ntohl(*p++)) != 0) { - struct timespec64 time; - p = decode_time3(p, &time); - args->guardtime = time.tv_sec; - } - - return xdr_argsize_check(rqstp, p); + return svcxdr_decode_nfs_fh3(xdr, &args->fh) && + svcxdr_decode_sattr3(rqstp, xdr, &args->attrs) && + svcxdr_decode_sattrguard3(xdr, args); } int diff --git a/include/uapi/linux/nfs3.h b/include/uapi/linux/nfs3.h index 37e4b34e6b43..c22ab77713bd 100644 --- a/include/uapi/linux/nfs3.h +++ b/include/uapi/linux/nfs3.h @@ -63,6 +63,12 @@ enum nfs3_ftype { NF3BAD = 8 }; +enum nfs3_time_how { + DONT_CHANGE = 0, + SET_TO_SERVER_TIME = 1, + SET_TO_CLIENT_TIME = 2, +}; + struct nfs3_fh { unsigned short size; unsigned char data[NFS3_FHSIZE]; From patchwork Tue Jan 5 15:31:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999279 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 2CDA4C433DB for ; Tue, 5 Jan 2021 15:31:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0607C22AAA for ; Tue, 5 Jan 2021 15:31:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727984AbhAEPb3 (ORCPT ); Tue, 5 Jan 2021 10:31:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727925AbhAEPb2 (ORCPT ); Tue, 5 Jan 2021 10:31:28 -0500 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C966C061574 for ; Tue, 5 Jan 2021 07:31:13 -0800 (PST) Received: by mail-qt1-x830.google.com with SMTP id z3so21021896qtw.9 for ; Tue, 05 Jan 2021 07:31: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=T9U5ag9DLt7J5bSYP8Pf1bsDxgr8EiUPWCu7Lzp07Cc=; b=ulO9vc1xHW5nwTBN6tsS+IOmX2tNU78Vzli7VT6rMARpPu9idJ8mjZnHR9d/sCiwOI xg+6uTbi7Mu/YZ6YaiUB7CwrLcns40JdrqjUvMlBt9aCC6+fMjdyPyRNu/m/y0+P9qe3 cUSSonH4+kPXcEgnvRU0Vx2xbgqDxMO+L8/dkJizc2szjggqBlXr+6imRkmX65B+cbfC mu4bInStrJxxu5L0bz4EMU8+nJWX8GblRdCoGv8GnrO0PH9Dn6PMh27xqxJqMQtacJ05 PLeuD/U3KbGh/D7owYLPV/REQFECpugqh7V4zwlNHabyGi55PeRhoT65b2AC2gw5fojT nQbw== 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=T9U5ag9DLt7J5bSYP8Pf1bsDxgr8EiUPWCu7Lzp07Cc=; b=dG0dwPGe97nxQrLQ7TWmjQ/6UzThDfnCU5eeADAuLYWFSRfI6B61/oLA8EYIlvtfU9 MS8HiLz4KVPnIoCd4LesvDQR0tEq0zkqB04mmpxU86J4hCVEDFAwgBzbdwlFZoIpkxOO BRiTsWuNcYepCzy7jIlWVQ/LuQx+dnLB+7LQswqTUmFq4VDkh+hJ0H0v9AgdnNNAkZi5 C81VQHJ/FH1dqk8B6lYo6EioJo8XfdvGu9b0R/V5qvjwewOVKlq7SoyGgvOxuhQ5iNux sNviSn0jR3jlhHQxL3pTFSIqRqz33D4bnxstnffyL6HodRRWS/mKskt5tHsUqZibY//8 0AUQ== X-Gm-Message-State: AOAM5328YnhZNRq08C65jqX0k2YxJhv+l3IInK+H5dFwyPmB99NczSzn elX6Ua5COHImvo5STvMgeRvHwzP2NSE= X-Google-Smtp-Source: ABdhPJyeja9/SXEH86PSbrC7r+scrfCUPoT6mMg4Ud0zcRUQowa4IzK63AECQkMpiqzAaAhT0PS2JQ== X-Received: by 2002:ac8:6987:: with SMTP id o7mr8964qtq.295.1609860672411; Tue, 05 Jan 2021 07:31: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 b12sm60934qtj.12.2021.01.05.07.31.11 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:31: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 105FVAON020871 for ; Tue, 5 Jan 2021 15:31:10 GMT Subject: [PATCH v1 17/42] NFSD: Update the CREATE3args decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:31:10 -0500 Message-ID: <160986067046.5532.729852070349122190.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs3xdr.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index ef536fb00728..559344c95de9 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -580,26 +580,26 @@ nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p) int nfs3svc_decode_createargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_createargs *args = rqstp->rq_argp; - if (!(p = decode_fh(p, &args->fh)) - || !(p = decode_filename(p, &args->name, &args->len))) + if (!svcxdr_decode_diropargs3(xdr, &args->fh, &args->name, &args->len)) return 0; - - switch (args->createmode = ntohl(*p++)) { + if (xdr_stream_decode_u32(xdr, &args->createmode) < 0) + return 0; + switch (args->createmode) { case NFS3_CREATE_UNCHECKED: case NFS3_CREATE_GUARDED: - p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp)); - break; + return svcxdr_decode_sattr3(rqstp, xdr, &args->attrs); case NFS3_CREATE_EXCLUSIVE: - args->verf = p; - p += 2; + args->verf = xdr_inline_decode(xdr, NFS3_CREATEVERFSIZE); + if (!args->verf) + return 0; break; default: return 0; } - - return xdr_argsize_check(rqstp, p); + return 1; } int From patchwork Tue Jan 5 15:31:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999281 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 3E4D9C433DB for ; Tue, 5 Jan 2021 15:31:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1281F22AAA for ; Tue, 5 Jan 2021 15:31:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727988AbhAEPbe (ORCPT ); Tue, 5 Jan 2021 10:31:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727925AbhAEPbd (ORCPT ); Tue, 5 Jan 2021 10:31:33 -0500 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0E40C061795 for ; Tue, 5 Jan 2021 07:31:18 -0800 (PST) Received: by mail-qv1-xf32.google.com with SMTP id p12so14792361qvj.13 for ; Tue, 05 Jan 2021 07:31: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=BOxgS0FJ1NzLgI6F21JD/o0tzVIZ/CHmLCW+HnYPLt4=; b=QiDuI0rN1TNiDnZy0qErbMuBLDsfjDSsUmtctMEzE0uoUICHye56kwkluH8KEWfrB/ oi9Lag4Bq94j9vm9rjKGfLJqt7NyXelUvn3/psT/uiLvLeOuztOcU/jGBqhfwlVfq+/B GregwaNLyAC1F9tP0zw4s0kNMaeZ+qwgZLNJsNeIoVhtVIF4fqr4m9VsT2hteC5X1dc5 mIcyRewp7HBytQVhKwbpZI5omIjS1HNEo/oJ04D8lHGaTH2ZhKpZx0lLFyL+RB9tHPbo K8PvCCX98lF+aTexDIqnljUPTjk5wg11lSYS7WJf/B4ID0AKAH3WeRTzOKl193yz5A6H nYHw== 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=BOxgS0FJ1NzLgI6F21JD/o0tzVIZ/CHmLCW+HnYPLt4=; b=cezZx1zRQLILP/YWd1FZzl5ZLeyNaBNLbofSwMdkcVMm2MGI2gGWlDFjJv//slR27k hluYZt4+U/n7Z8OSo5AwCnT6EgeZHBo+ovJZIbfQOGRTaxXNQZzPi5nYJ0RpnZ2rYJ4O Jxbmw447JM1Iua7EmN6ZndqhaC4yzMiZQSEy83m+WVdtWSnbFCasZe0vQ3OH3PVyQR0D 6wcGMnHbK+7Lmc0xQVFmvonhl8ib+HPW5Hmx2B+OK+m6X6G57snYC14i64Fp2YeRvqs5 CwRlbbmHbHGs6h8Nl1fG0SQHnqdwHz5gwzMO0soN0riILIzdz8hQeDbj17tHZNPQn/xR SLpA== X-Gm-Message-State: AOAM532CJ2cSXkf/IeIp6knUR3JXzOnh9QnZ4K81Yp4OdaibZcfaSey0 yekreflC5u4luaMPV7VW4DNtEKL/PM0= X-Google-Smtp-Source: ABdhPJw48f00pZzi2FRQrjTiy1Haz5FEqUrhGyALuczKJAi37qoFodTwFbWjUkCbXt4+StpNXLEeGQ== X-Received: by 2002:ad4:4f41:: with SMTP id eu1mr140948qvb.1.1609860677600; Tue, 05 Jan 2021 07:31: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 v4sm62029qth.16.2021.01.05.07.31.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:31: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 105FVFw3020874 for ; Tue, 5 Jan 2021 15:31:15 GMT Subject: [PATCH v1 18/42] NFSD: Update the MKDIR3args decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:31:15 -0500 Message-ID: <160986067582.5532.3518167003498333903.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs3xdr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 559344c95de9..45975fdb033e 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -605,14 +605,12 @@ nfs3svc_decode_createargs(struct svc_rqst *rqstp, __be32 *p) int nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_createargs *args = rqstp->rq_argp; - if (!(p = decode_fh(p, &args->fh)) || - !(p = decode_filename(p, &args->name, &args->len))) - return 0; - p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp)); - - return xdr_argsize_check(rqstp, p); + return svcxdr_decode_diropargs3(xdr, &args->fh, + &args->name, &args->len) && + svcxdr_decode_sattr3(rqstp, xdr, &args->attrs); } int From patchwork Tue Jan 5 15:31:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999325 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 5FE53C433E6 for ; Tue, 5 Jan 2021 15:32:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 320FB22B45 for ; Tue, 5 Jan 2021 15:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727529AbhAEPcE (ORCPT ); Tue, 5 Jan 2021 10:32:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38124 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727408AbhAEPcE (ORCPT ); Tue, 5 Jan 2021 10:32:04 -0500 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB722C061796 for ; Tue, 5 Jan 2021 07:31:23 -0800 (PST) Received: by mail-qt1-x82d.google.com with SMTP id b9so21086774qtr.2 for ; Tue, 05 Jan 2021 07:31: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=JIjn3vuBDM7Pb4LQaHHXPilj0m1OshyLTk1RWQWz7f8=; b=Hy4NzIkviqUoU2A5GrTOJsxKx093NzL083ZFgAdUpU9UW0gF3khIXeNLYMVKva3EEi Cn3E/pXfrIITt7aPbFbZi7hUksxmI+s1YbLTzfMdAPh6+Csa2SrS7nXxhyb60bo3jfll e2L71DC/CqMjDDyAtv9dV516aJzym1EeBvK+kdfED6zjlVG7z0xvVj7l5+BUf0L5bk7W fxXBmbt3M1IV1DKVJTwb3W4Bi/Aq+d8aYqWy8EeStqV5lubLN3V5zu8enzfhJeSJU6Kj Yn115muMRx4Ny74USZExAFDWEtwWB8w63ZRu3OnANCdMTfh/Y+ude4Jz3csVTmNZNN18 jLQA== 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=JIjn3vuBDM7Pb4LQaHHXPilj0m1OshyLTk1RWQWz7f8=; b=gMzZOY7zrwFCruPESbRM9yWKWgOC2CV5ozyj12QD1YCCSLfJeOpeXvBj8lUKrlpgY0 s2gfek70jwUvGzVXlH5PXE312NiCSYQgNK30sPWpQS2gIIe/WhKcsCyv/ET7773RthJp 9XQ5EUjcadOcd3IsJn04xIyLs/KCY0cLnuLkQdrVqtOmF/3WVZCKk2D1wSTm1i/Zvnzl HwDo8+uUi293+1XzgthtFOPUDd+wUpQ4gdbOfIaOkSyOItyMDplGYVAtvrQG3CtDnPu7 myMGt3A1T3YjWboaPPhvw/4Lh7wL/t2DCeYUfUjBhLh4mBJBDs85ysSC/wUQX2N95JdR v6PA== X-Gm-Message-State: AOAM530H95f31YHubsSoguE3x7OEZPnrLYzQB6ispzPZ9jDbaJ6qWEVr biU7qabb2pDa76mB5LnwmBTpPoPDDO0= X-Google-Smtp-Source: ABdhPJwau1C9QBIkhLCW3FCcNAZNywZCAT4fNQWDlrGmdE9wgtI7rrjzdgGtOw9ciP8Cun0Uugg/Xg== X-Received: by 2002:aed:2f64:: with SMTP id l91mr266qtd.363.1609860682661; Tue, 05 Jan 2021 07:31: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 m41sm55825qtc.28.2021.01.05.07.31.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:31: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 105FVLaM020877 for ; Tue, 5 Jan 2021 15:31:21 GMT Subject: [PATCH v1 19/42] NFSD: Update the SYMLINK3args decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:31:21 -0500 Message-ID: <160986068119.5532.7090899294624791804.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 Similar to the WRITE decoder, code that checks the sanity of the payload size is re-wired to work with xdr_stream infrastructure. Signed-off-by: Chuck Lever --- fs/nfsd/nfs3xdr.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 45975fdb033e..e599d1481b2d 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -616,25 +616,28 @@ nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, __be32 *p) int nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_symlinkargs *args = rqstp->rq_argp; - char *base = (char *)p; - size_t dlen; + struct kvec *head = rqstp->rq_arg.head; + struct kvec *tail = rqstp->rq_arg.tail; + size_t remaining; - if (!(p = decode_fh(p, &args->ffh)) || - !(p = decode_filename(p, &args->fname, &args->flen))) + if (!svcxdr_decode_diropargs3(xdr, &args->ffh, &args->fname, &args->flen)) + return 0; + if (!svcxdr_decode_sattr3(rqstp, xdr, &args->attrs)) + return 0; + if (xdr_stream_decode_u32(xdr, &args->tlen) < 0) return 0; - p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp)); - args->tlen = ntohl(*p++); + /* request sanity */ + remaining = head->iov_len + rqstp->rq_arg.page_len + tail->iov_len; + remaining -= xdr_stream_pos(xdr); + if (remaining < xdr_align_size(args->tlen)) + return 0; - args->first.iov_base = p; - args->first.iov_len = rqstp->rq_arg.head[0].iov_len; - args->first.iov_len -= (char *)p - base; + args->first.iov_base = xdr->p; + args->first.iov_len = head->iov_len - xdr_stream_pos(xdr); - dlen = args->first.iov_len + rqstp->rq_arg.page_len + - rqstp->rq_arg.tail[0].iov_len; - if (dlen < XDR_QUADLEN(args->tlen) << 2) - return 0; return 1; } From patchwork Tue Jan 5 15:31:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999283 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 C5318C433DB for ; Tue, 5 Jan 2021 15:31:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A83A22AAA for ; Tue, 5 Jan 2021 15:31:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725925AbhAEPbo (ORCPT ); Tue, 5 Jan 2021 10:31:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727126AbhAEPbo (ORCPT ); Tue, 5 Jan 2021 10:31:44 -0500 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B923C061574 for ; Tue, 5 Jan 2021 07:31:29 -0800 (PST) Received: by mail-qk1-x72c.google.com with SMTP id z11so26787363qkj.7 for ; Tue, 05 Jan 2021 07:31: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=Mahf9IRkHH9EZ+lU/nog2IaIVN+9KiP4zb4gqG5Mkq4=; b=F3YqwcD9pt8+0oxRkRuHvZaeUGUqT1xza0WYjdn9JEWHndcL6PQQhBk/oxKTGI4FwE I8bkasyNs86d1WH5y3Q+jPjH8/l+2oHAho3lBp+YV8BmqLVNZX7QlTcR183I41FWgedr FkSeyZ6N+a+VDIDzKSab9U4qPcTxIrR0o5hGFU8Nqp88ym6x9emL9Xz37JB+kKdaB2Q/ Vr3zozoxZqrMMCMHjdQvGqjF5+4+b6QvvZ0JErK3L/rth+CY/X454NZ9sAHhvkLr3Ugo B+qpwZBx6bJvcuE8crYazjzLM2YCIhuYNhYiIgyT226XXV4x6cvfbRw1jBd7Ru9K/+Fg +S3g== 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=Mahf9IRkHH9EZ+lU/nog2IaIVN+9KiP4zb4gqG5Mkq4=; b=FzwHO2lNa4piAKpMLfrUiTkKfjhrjIBsVWmtoORjU1huuL098Gqc0xwvKAwprhbF3r Vk8ishzMUGNjxBowycz4DlYutx4TKWIWSIWN4Zm0gzjnpDtAW8K2rNXr29AXxDUmhyof uh+cDDg45mz4io2KEqI3f0vZXly1mncDDJHlJXVxtbSQB00hu2sHRYkW97xYe5N91g4c wSqKUnoURp3Gkjh4jByd9zHplbHVScdb7wnv8hg2n9QDZjHab4NgkmB7i4d6tB56uo53 28pqjlkvdxIwlAMrixwUZrvBYw/iq7L0hCjPnqxfXd6iFMeasw7gnQOhlNRfIWeqbbq8 zBNA== X-Gm-Message-State: AOAM530tgXbNleSIz+HJquapPbux6DZp+kOtqLh39UE7J+U46nlOekY2 hqWPjC2pmaONc2udmiGBM1r5YC3B1ts= X-Google-Smtp-Source: ABdhPJy8LV6EoaCtqegikBen5z24X+p0N0GeFEaZtoLEMUIuswm82ggaByRYORn+5vJvtF2f04B9Qw== X-Received: by 2002:a37:a50c:: with SMTP id o12mr90976qke.98.1609860687930; Tue, 05 Jan 2021 07:31: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 r22sm147514qkk.67.2021.01.05.07.31.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:31: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 105FVQ13020880 for ; Tue, 5 Jan 2021 15:31:26 GMT Subject: [PATCH v1 20/42] NFSD: Update the MKNOD3args decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:31:26 -0500 Message-ID: <160986068625.5532.13338988223363460604.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 commit removes the last usage of the original decode_sattr3(), so it is removed as a clean-up. Signed-off-by: Chuck Lever --- fs/nfsd/nfs3xdr.c | 107 +++++++++++++++++------------------------------------ 1 file changed, 35 insertions(+), 72 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index e599d1481b2d..5fb7e8a599c4 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -103,26 +103,6 @@ encode_fh(__be32 *p, struct svc_fh *fhp) return p + XDR_QUADLEN(size); } -/* - * Decode a file name and make sure that the path contains - * no slashes or null bytes. - */ -static __be32 * -decode_filename(__be32 *p, char **namp, unsigned int *lenp) -{ - char *name; - unsigned int i; - - if ((p = xdr_decode_string_inplace(p, namp, lenp, NFS3_MAXNAMLEN)) != NULL) { - for (i = 0, name = *namp; i < *lenp; i++, name++) { - if (*name == '\0' || *name == '/') - return NULL; - } - } - - return p; -} - static bool svcxdr_decode_filename3(struct xdr_stream *xdr, char **name, unsigned int *len) { @@ -262,49 +242,26 @@ svcxdr_decode_sattrguard3(struct xdr_stream *xdr, struct nfsd3_sattrargs *args) return true; } -static __be32 * -decode_sattr3(__be32 *p, struct iattr *iap, struct user_namespace *userns) +static bool +svcxdr_decode_specdata3(struct xdr_stream *xdr, struct nfsd3_mknodargs *args) { - u32 tmp; + __be32 *p; - iap->ia_valid = 0; + p = xdr_inline_decode(xdr, XDR_UNIT * 2); + if (!p) + return false; + args->major = be32_to_cpup(p++); + args->minor = be32_to_cpup(p); - if (*p++) { - iap->ia_valid |= ATTR_MODE; - iap->ia_mode = ntohl(*p++); - } - if (*p++) { - iap->ia_uid = make_kuid(userns, ntohl(*p++)); - if (uid_valid(iap->ia_uid)) - iap->ia_valid |= ATTR_UID; - } - if (*p++) { - iap->ia_gid = make_kgid(userns, ntohl(*p++)); - if (gid_valid(iap->ia_gid)) - iap->ia_valid |= ATTR_GID; - } - if (*p++) { - u64 newsize; + return true; +} - iap->ia_valid |= ATTR_SIZE; - p = xdr_decode_hyper(p, &newsize); - iap->ia_size = min_t(u64, newsize, NFS_OFFSET_MAX); - } - if ((tmp = ntohl(*p++)) == 1) { /* set to server time */ - iap->ia_valid |= ATTR_ATIME; - } else if (tmp == 2) { /* set to client time */ - iap->ia_valid |= ATTR_ATIME | ATTR_ATIME_SET; - iap->ia_atime.tv_sec = ntohl(*p++); - iap->ia_atime.tv_nsec = ntohl(*p++); - } - if ((tmp = ntohl(*p++)) == 1) { /* set to server time */ - iap->ia_valid |= ATTR_MTIME; - } else if (tmp == 2) { /* set to client time */ - iap->ia_valid |= ATTR_MTIME | ATTR_MTIME_SET; - iap->ia_mtime.tv_sec = ntohl(*p++); - iap->ia_mtime.tv_nsec = ntohl(*p++); - } - return p; +static bool +svcxdr_decode_devicedata3(struct svc_rqst *rqstp, struct xdr_stream *xdr, + struct nfsd3_mknodargs *args) +{ + return svcxdr_decode_sattr3(rqstp, xdr, &args->attrs) && + svcxdr_decode_specdata3(xdr, args); } static __be32 *encode_fsid(__be32 *p, struct svc_fh *fhp) @@ -644,24 +601,30 @@ nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p) int nfs3svc_decode_mknodargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_mknodargs *args = rqstp->rq_argp; - if (!(p = decode_fh(p, &args->fh)) - || !(p = decode_filename(p, &args->name, &args->len))) + if (!svcxdr_decode_diropargs3(xdr, &args->fh, &args->name, &args->len)) + return 0; + if (xdr_stream_decode_u32(xdr, &args->ftype) < 0) + return 0; + switch (args->ftype) { + case NF3CHR: + case NF3BLK: + return svcxdr_decode_devicedata3(rqstp, xdr, args); + case NF3SOCK: + case NF3FIFO: + return svcxdr_decode_sattr3(rqstp, xdr, &args->attrs); + case NF3REG: + case NF3DIR: + case NF3LNK: + /* Valid XDR but illegal file types */ + break; + default: return 0; - - args->ftype = ntohl(*p++); - - if (args->ftype == NF3BLK || args->ftype == NF3CHR - || args->ftype == NF3SOCK || args->ftype == NF3FIFO) - p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp)); - - if (args->ftype == NF3BLK || args->ftype == NF3CHR) { - args->major = ntohl(*p++); - args->minor = ntohl(*p++); } - return xdr_argsize_check(rqstp, p); + return 1; } int From patchwork Tue Jan 5 15:31:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999285 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 C4D32C433DB for ; Tue, 5 Jan 2021 15:31:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 885F422AAA for ; Tue, 5 Jan 2021 15:31:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726177AbhAEPbt (ORCPT ); Tue, 5 Jan 2021 10:31:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726020AbhAEPbt (ORCPT ); Tue, 5 Jan 2021 10:31:49 -0500 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DEFFC061793 for ; Tue, 5 Jan 2021 07:31:34 -0800 (PST) Received: by mail-qk1-x735.google.com with SMTP id p14so26786612qke.6 for ; Tue, 05 Jan 2021 07:31: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=+qeCAeb1hdNWv49AZvNpZobfUYtECvNdrSN/jZ0uEdY=; b=dsv3JRvtHTJusKIOGhoo0+bUQj9PczYGUWeZEpF8CvR0umZkrw4spok6tW2EpBwXTJ 7jOK+QFbBsE2hHGuwkGvaxxkzdS/Jxb4AzlqE1LE5chVDDaIIxecWd/yQoNnD21v1qDe Dan7SKYcSdUTdQNgmFK5GD8XwolbAogMgSXl2O7oupCo0dLOfLsgYIbmmlmK9BLH4FV/ iYfMX7qPELqUs4lit2fOtO/4t2g6uq3fl4zX5Q6c65YWIwYghAZvIlHkM9qlIEg6+8pB FFxlEL1cqj/YVZgY+KmVWe2WYnuilN6gEJo5wjuqYrjT5LOLzu7qCwnSA3KRqIa3iVK6 ErRQ== 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=+qeCAeb1hdNWv49AZvNpZobfUYtECvNdrSN/jZ0uEdY=; b=QrJJK+yFCGmXezlOMzShTIe3nRubggNcEWmR8e4h0zGpqOsXBdyEMEbEqqJpxjVqFn dGQRwG1hGWcRa5d4x0tVELAIQUiyvKb5Q63gNzaJkII0ltdi5GAgGzakbjn98GNsHPat NKHgQUjdxe9KYSXWhyD426oBLDZhU4AgpH59vDACpj06yJo+fUqDglXhO9YtZnwfL4CF 4oU4g6ngPFL5sMSS2OVz3RhFAd0SVnfvsumIaqN00q77bheIzKDD8UDsJ07somxgq7ol WJD9M65Wacbo09nJ2BlCggLukevz4FK1OTacpwVo022IhNU26gfnCLE7tfo8MqFikTCe fTmA== X-Gm-Message-State: AOAM532YD4dtY7hf1QadhXDsnarXv0uQECdyLDxZkc7QzhIboePSFw45 r/szqHjKo7lmrneiM/D04Lc8RxbhfGE= X-Google-Smtp-Source: ABdhPJy2jJ8SsELqb1EgrVzacZ+WXXiDcfuY7eh0RVTGwxYiDfxvZyBtYfb1W2IYBXbSfW6GCgI1Rw== X-Received: by 2002:a37:a796:: with SMTP id q144mr95463qke.38.1609860693171; Tue, 05 Jan 2021 07:31: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 195sm132724qke.108.2021.01.05.07.31.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:31: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 105FVVaQ020883 for ; Tue, 5 Jan 2021 15:31:31 GMT Subject: [PATCH v1 21/42] NFSD: Update the NFSv2 GETATTR argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:31:31 -0500 Message-ID: <160986069154.5532.12958943826555170241.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfsproc.c | 4 ++-- fs/nfsd/nfsxdr.c | 26 ++++++++++++++++++++------ fs/nfsd/xdr.h | 2 +- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index 1f85a4dc9d1b..b9bc162a5c77 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -627,7 +627,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { }, [NFSPROC_GETATTR] = { .pc_func = nfsd_proc_getattr, - .pc_decode = nfssvc_decode_fhandle, + .pc_decode = nfssvc_decode_fhandleargs, .pc_encode = nfssvc_encode_attrstat, .pc_release = nfssvc_release_attrstat, .pc_argsize = sizeof(struct nfsd_fhandle), @@ -793,7 +793,7 @@ static const struct svc_procedure nfsd_procedures2[18] = { }, [NFSPROC_STATFS] = { .pc_func = nfsd_proc_statfs, - .pc_decode = nfssvc_decode_fhandle, + .pc_decode = nfssvc_decode_fhandleargs, .pc_encode = nfssvc_encode_statfsres, .pc_argsize = sizeof(struct nfsd_fhandle), .pc_ressize = sizeof(struct nfsd_statfsres), diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index 7aa6e8aca2c1..f3189e1be20f 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -23,8 +23,9 @@ static u32 nfs_ftypes[] = { /* - * XDR functions for basic NFS types + * Basic NFSv2 data types (RFC 1094 Section 2.3) */ + static __be32 * decode_fh(__be32 *p, struct svc_fh *fhp) { @@ -37,6 +38,21 @@ decode_fh(__be32 *p, struct svc_fh *fhp) return p + (NFS_FHSIZE >> 2); } +static bool +svcxdr_decode_fhandle(struct xdr_stream *xdr, struct svc_fh *fhp) +{ + __be32 *p; + + p = xdr_inline_decode(xdr, NFS_FHSIZE); + if (!p) + return false; + fh_init(fhp, NFS_FHSIZE); + memcpy(&fhp->fh_handle.fh_base, p, NFS_FHSIZE); + fhp->fh_handle.fh_size = NFS_FHSIZE; + + return true; +} + /* Helper function for NFSv2 ACL code */ __be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp) { @@ -194,14 +210,12 @@ __be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *f */ int -nfssvc_decode_fhandle(struct svc_rqst *rqstp, __be32 *p) +nfssvc_decode_fhandleargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd_fhandle *args = rqstp->rq_argp; - p = decode_fh(p, &args->fh); - if (!p) - return 0; - return xdr_argsize_check(rqstp, p); + return svcxdr_decode_fhandle(xdr, &args->fh); } int diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h index ad77387734cc..84256a6a1ba1 100644 --- a/fs/nfsd/xdr.h +++ b/fs/nfsd/xdr.h @@ -144,7 +144,7 @@ union nfsd_xdrstore { #define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore) -int nfssvc_decode_fhandle(struct svc_rqst *, __be32 *); +int nfssvc_decode_fhandleargs(struct svc_rqst *, __be32 *); int nfssvc_decode_sattrargs(struct svc_rqst *, __be32 *); int nfssvc_decode_diropargs(struct svc_rqst *, __be32 *); int nfssvc_decode_readargs(struct svc_rqst *, __be32 *); From patchwork Tue Jan 5 15:31:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999333 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 8161AC433E0 for ; Tue, 5 Jan 2021 15:32:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DC4422AAA for ; Tue, 5 Jan 2021 15:32:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728011AbhAEPcU (ORCPT ); Tue, 5 Jan 2021 10:32:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727994AbhAEPcU (ORCPT ); Tue, 5 Jan 2021 10:32:20 -0500 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9464AC061795 for ; Tue, 5 Jan 2021 07:31:39 -0800 (PST) Received: by mail-qk1-x72a.google.com with SMTP id p14so26786979qke.6 for ; Tue, 05 Jan 2021 07:31: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=Zf/yoElT6MWQefrSE2xQsbQMfIvzjt/LKHYK3aScOJM=; b=aVDRuJLnOz2OgMWdcOFp+lGNwnEEnNTiosBnevqRXdUCGzwSpu69D7wNWcuK1V2ym8 H/Ki0iiTIAVNUd9Lf4mMJsCFVmdT3bog6Cr8Y0C0141tP5kZSYGk1rTqQwlDsvU4ZJa1 1qyrf8xxJtML37Jjtg+2EV4X2CM6DMicgwpaTMdTuLHKfWjHE9V4DDvd3pVJXPFmx3W+ SoVHm8cwnACY7AdSNr4ZmP4NeLhFMWgiZ4MAwSG6IgsbRZKypq+Z+FucH+622LjAWQOy Y+0h5hz8FgI9ksRIFYZTxA41Gfq0dbqUEf+Z5hgwuSIRxtMpd6vkHcMUwbZZkrywy2tU 1DWA== 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=Zf/yoElT6MWQefrSE2xQsbQMfIvzjt/LKHYK3aScOJM=; b=TRxl+Q8aCjF2um44J0UnHlKbuSeLwIwGnpsJ9lSCtHGjbkfuoKUD4HO3mf+BOs35Z4 DKf7kKxJOJ/P1Pf+6vvmUTSISGD4PDDuZJhWWirU8Aqtq7gkaPMQeZQOEE5WtzVRs0fq pFZ5ep50skzVAdyVFx2RKOirMy9i9/LiANvAx/tS13Wv7uN5u+OKEjbvz69o0l4/7nHc RJ1CYpi9piEkCcrgl2JrVj4jkQlfrY1BYHWnZnx1IRaLIT5nRWmXwu4oU1JheHPp3J10 5vdu+qhuofZalgRcE0veZt9aBrpaLpLkFY/6hvpy6QEd6M+cPPTWwmZLsugVbAY5eqcg D/GA== X-Gm-Message-State: AOAM531TGkmN3zuRce+DW3C+SisXhe06/zUv6QRLjIGt+9VAWG8gMVGY otSljxpNkWHXeLQzcba38P+csO5PaMc= X-Google-Smtp-Source: ABdhPJyYfdpUre6tY41EmZT1dbvpc5tGUKQIc1IXMFweHDSlUAtCSuL8cLtNSfzpSXSUoVKQr7gMHg== X-Received: by 2002:a37:63c7:: with SMTP id x190mr16508qkb.277.1609860698479; Tue, 05 Jan 2021 07:31: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 x49sm73409qtx.6.2021.01.05.07.31.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:31: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 105FVamV020886 for ; Tue, 5 Jan 2021 15:31:36 GMT Subject: [PATCH v1 22/42] NFSD: Update the NFSv2 READ argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:31:36 -0500 Message-ID: <160986069683.5532.10097341043519053080.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 The code that sets up rq_vec is refactored so that it is now adjacent to the nfsd_read() call site where it is used. Signed-off-by: Chuck Lever --- fs/nfsd/nfsproc.c | 32 ++++++++++++++++++-------------- fs/nfsd/nfsxdr.c | 36 ++++++++++++------------------------ fs/nfsd/xdr.h | 1 - 3 files changed, 30 insertions(+), 39 deletions(-) diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index b9bc162a5c77..814762793f9c 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -171,32 +171,36 @@ nfsd_proc_read(struct svc_rqst *rqstp) { struct nfsd_readargs *argp = rqstp->rq_argp; struct nfsd_readres *resp = rqstp->rq_resp; + unsigned int len; u32 eof; + int v; dprintk("nfsd: READ %s %d bytes at %d\n", SVCFH_fmt(&argp->fh), argp->count, argp->offset); + argp->count = min_t(u32, argp->count, NFSSVC_MAXBLKSIZE_V2); + + v = 0; + len = argp->count; + while (len > 0) { + struct page *page = *(rqstp->rq_next_page++); + + rqstp->rq_vec[v].iov_base = page_address(page); + rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE); + len -= rqstp->rq_vec[v].iov_len; + v++; + } + /* Obtain buffer pointer for payload. 19 is 1 word for * status, 17 words for fattr, and 1 word for the byte count. */ - - if (NFSSVC_MAXBLKSIZE_V2 < argp->count) { - char buf[RPC_MAX_ADDRBUFLEN]; - printk(KERN_NOTICE - "oversized read request from %s (%d bytes)\n", - svc_print_addr(rqstp, buf, sizeof(buf)), - argp->count); - argp->count = NFSSVC_MAXBLKSIZE_V2; - } svc_reserve_auth(rqstp, (19<<2) + argp->count + 4); resp->count = argp->count; - resp->status = nfsd_read(rqstp, fh_copy(&resp->fh, &argp->fh), - argp->offset, - rqstp->rq_vec, argp->vlen, - &resp->count, - &eof); + fh_copy(&resp->fh, &argp->fh); + resp->status = nfsd_read(rqstp, &resp->fh, argp->offset, + rqstp->rq_vec, v, &resp->count, &eof); if (resp->status == nfs_ok) resp->status = fh_getattr(&resp->fh, &resp->stat); else if (resp->status == nfserr_jukebox) diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index f3189e1be20f..1eacaa2c13a9 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -246,33 +246,21 @@ nfssvc_decode_diropargs(struct svc_rqst *rqstp, __be32 *p) int nfssvc_decode_readargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd_readargs *args = rqstp->rq_argp; - unsigned int len; - int v; - p = decode_fh(p, &args->fh); - if (!p) - return 0; + u32 totalcount; - args->offset = ntohl(*p++); - len = args->count = ntohl(*p++); - p++; /* totalcount - unused */ - - len = min_t(unsigned int, len, NFSSVC_MAXBLKSIZE_V2); + if (!svcxdr_decode_fhandle(xdr, &args->fh)) + return 0; + if (xdr_stream_decode_u32(xdr, &args->offset) < 0) + return 0; + if (xdr_stream_decode_u32(xdr, &args->count) < 0) + return 0; + /* totalcount is ignored */ + if (xdr_stream_decode_u32(xdr, &totalcount) < 0) + return 0; - /* set up somewhere to store response. - * We take pages, put them on reslist and include in iovec - */ - v=0; - while (len > 0) { - struct page *p = *(rqstp->rq_next_page++); - - rqstp->rq_vec[v].iov_base = page_address(p); - rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE); - len -= rqstp->rq_vec[v].iov_len; - v++; - } - args->vlen = v; - return xdr_argsize_check(rqstp, p); + return 1; } int diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h index 84256a6a1ba1..d2ffda96975d 100644 --- a/fs/nfsd/xdr.h +++ b/fs/nfsd/xdr.h @@ -27,7 +27,6 @@ struct nfsd_readargs { struct svc_fh fh; __u32 offset; __u32 count; - int vlen; }; struct nfsd_writeargs { From patchwork Tue Jan 5 15:31:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999287 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 9D079C433E0 for ; Tue, 5 Jan 2021 15:32:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C23C22AAA for ; Tue, 5 Jan 2021 15:32:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726827AbhAEPcA (ORCPT ); Tue, 5 Jan 2021 10:32:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725936AbhAEPcA (ORCPT ); Tue, 5 Jan 2021 10:32:00 -0500 Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8944C061574 for ; Tue, 5 Jan 2021 07:31:44 -0800 (PST) Received: by mail-qv1-xf2b.google.com with SMTP id 4so14823768qvh.1 for ; Tue, 05 Jan 2021 07:31: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=9VW1Ou8LjJrNLzLN8qVcgBlEKXmYO24Pd+5GLIp6BMI=; b=s4yfVLOoLsMk3BIM2bGxMY9eWgbYP3xAUS4ac7s9wF7+p1M3CeoRvpJwLj/Gvb2bJW mRa1GakKpIuOHWQG/zZBBZNVCfRvvYKjRDDjndExI0pSBgMDPDeGilSAGEayrVQ97fOb wHNgZ48Qp0kecT+iwQbJ1fJQu5CdmvsDYSqggreXsGhU3h7JHttJppDqSu/c0fgXlnIB zYsG/yU18I4gWVgJ+y+xGZV7GU2P+0I40eNnhvs+KITVlNWdA25tAPXhvkysMCzNULgU 0zY+ADILH3rZseAW70TRpz1R+c3ED5Vqg/6+/n7ZvxKxos6s7tL87wcIp7Xpx2zwx6Uw /6Gw== 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=9VW1Ou8LjJrNLzLN8qVcgBlEKXmYO24Pd+5GLIp6BMI=; b=TQLwnFK9aH1pBNjpIBgbOuWlvMZJDADZ7+jIc7bX7yv87vrD9xnL+atG7z5qGIDgLd kd5uu5wvqtFYh7a9Iab0PAlWvQFN8YJAcaRFxWSN3YFADUn/Q+EkfqxCT9skNA8ESovE D28ajDNaOYlMHfT/fTLE0V4r6iphwY/fZGqJrQqUvU0E3KEvmGUB4D+uCDqFtYiRLWQc TXvJT0z6zXU98IyNfSv8imT7CbQBATSuXckCVXNWtf2EmNVdxyAOIscgBD2A+4ydR81v FhVV49+hoBUUHhlqXxs5e4eK5oNJshUczvoYYntyx0HQ3t9AAX9cdgK3oqljE1Fgkd5w 7TVQ== X-Gm-Message-State: AOAM532xjxBQoFMiJMZ26/VAbm87uyteMCtdOtlaw2KdD5oqtw/vozBL IkAMU/IMQ0vHo0g/byHHkEH08vLkdMc= X-Google-Smtp-Source: ABdhPJxrPl2l1Q6EuIypnQzjHqM6eKaWE82E9eDI6gAPQ7nh+iZlccTiOIk8tU+utefE771Ze4sBig== X-Received: by 2002:a0c:f1ce:: with SMTP id u14mr80985960qvl.24.1609860703754; Tue, 05 Jan 2021 07:31: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 g28sm19074qtm.91.2021.01.05.07.31.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:31: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 105FVgkE020889 for ; Tue, 5 Jan 2021 15:31:42 GMT Subject: [PATCH v1 23/42] NFSD: Update the NFSv2 WRITE argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:31:42 -0500 Message-ID: <160986070212.5532.1358874372009048952.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfsxdr.c | 52 +++++++++++++++++++++------------------------------- 1 file changed, 21 insertions(+), 31 deletions(-) diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index 1eacaa2c13a9..11d27b219cff 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -266,46 +266,36 @@ nfssvc_decode_readargs(struct svc_rqst *rqstp, __be32 *p) int nfssvc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd_writeargs *args = rqstp->rq_argp; - unsigned int len, hdr, dlen; struct kvec *head = rqstp->rq_arg.head; + struct kvec *tail = rqstp->rq_arg.tail; + u32 beginoffset, totalcount; + size_t remaining; - p = decode_fh(p, &args->fh); - if (!p) + if (!svcxdr_decode_fhandle(xdr, &args->fh)) return 0; - - p++; /* beginoffset */ - args->offset = ntohl(*p++); /* offset */ - p++; /* totalcount */ - len = args->len = ntohl(*p++); - /* - * The protocol specifies a maximum of 8192 bytes. - */ - if (len > NFSSVC_MAXBLKSIZE_V2) + /* beginoffset is ignored */ + if (xdr_stream_decode_u32(xdr, &beginoffset) < 0) return 0; - - /* - * Check to make sure that we got the right number of - * bytes. - */ - hdr = (void*)p - head->iov_base; - if (hdr > head->iov_len) + if (xdr_stream_decode_u32(xdr, &args->offset) < 0) + return 0; + /* totalcount is ignored */ + if (xdr_stream_decode_u32(xdr, &totalcount) < 0) return 0; - dlen = head->iov_len + rqstp->rq_arg.page_len - hdr; - /* - * Round the length of the data which was specified up to - * the next multiple of XDR units and then compare that - * against the length which was actually received. - * Note that when RPCSEC/GSS (for example) is used, the - * data buffer can be padded so dlen might be larger - * than required. It must never be smaller. - */ - if (dlen < XDR_QUADLEN(len)*4) + /* opaque data */ + if (xdr_stream_decode_u32(xdr, &args->len) < 0) + return 0; + if (args->len > NFSSVC_MAXBLKSIZE_V2) + return 0; + remaining = head->iov_len + rqstp->rq_arg.page_len + tail->iov_len; + remaining -= xdr_stream_pos(xdr); + if (remaining < xdr_align_size(args->len)) return 0; + args->first.iov_base = xdr->p; + args->first.iov_len = head->iov_len - xdr_stream_pos(xdr); - args->first.iov_base = (void *)p; - args->first.iov_len = head->iov_len - hdr; return 1; } From patchwork Tue Jan 5 15:31:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999329 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 6C0DFC433E0 for ; Tue, 5 Jan 2021 15:32:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 478EC22B4B for ; Tue, 5 Jan 2021 15:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727608AbhAEPcF (ORCPT ); Tue, 5 Jan 2021 10:32:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727408AbhAEPcF (ORCPT ); Tue, 5 Jan 2021 10:32:05 -0500 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C4B2C061793 for ; Tue, 5 Jan 2021 07:31:50 -0800 (PST) Received: by mail-qk1-x72e.google.com with SMTP id c7so26782647qke.1 for ; Tue, 05 Jan 2021 07:31: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=5MJzPeJJLc2aRCx+IAlBcY2ccSdPvJbsRJJS+pdfcrc=; b=OoreJOF2fuQuCtPV/IdOJgwsXopqYdJhQr+3vg9CFVdUbN71lS7Zic5SvQTMU3JEsp +Rwp5/88Q6V3aaXDxbsN3BIaN3BhZAse8T0ElZs+1WixDaXbru0KFKAS/0Dbgj54s7wq UnipuNoAJdkvbKsl0LGVzmJQFzig43ybNs0cBUFPfxo4lxUReIRouihnSOiXxfCYoDio QBexsdIKthKkQCj13MFtARSABLsZfpIrFUUMV3/2lIeaRFNhD9SWsZ+7RaKdTPIO41+C bbabQu7E6jqMEP365WrluRY+OLQFIgIDAc5Nb1PgBnOkH5Rc3AkEMqEh6S/VcO1HAlH4 nIiA== 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=5MJzPeJJLc2aRCx+IAlBcY2ccSdPvJbsRJJS+pdfcrc=; b=kWIh3qPswsCd3uxOE2jZBQ/3vrmHGwynjgoTUZEvH2L1xlinjO8Fb6VgvSyiWsJZq7 hK9AgxerDe2O7Mw709TAFsXilbNus7Zym3FyVaOPA/sBzAcn1eahLH6myMuaOC2vmvKV Ymav1Ti9dyNXS2UYX7OgBHQtSPk2LrWOW90RlNQRDvze8bNRJa46/G5fhrcid/Zchj25 HvsBL6/pxGIE4RuUQTdh3mGKIp+d0Af18dRpAFcOazUlNa4cR8yRC8uMfbb1wG3PfGLg dumbpSPqawMlO1DY1OEKAmle+npwkJNPtNzP+Zu7NcYuDI/Xf/o5VIZEVU2XZWPqH3DX ndTw== X-Gm-Message-State: AOAM5336B9T7ssnID1pp2GxH0SpI+8BBtLM1tv0JRGlWgzoKflenFE6Y KxJP8AkDTt652z+jn+GFh/aJ8qqhDPw= X-Google-Smtp-Source: ABdhPJz0XfmFB9vsEfRzbBcBxa0cSP5i4+DTmmXGlIXW7jXICLKqKnsX+L2xEgIzxg6Q4hBFea4L0Q== X-Received: by 2002:a37:27d0:: with SMTP id n199mr8286qkn.377.1609860709041; Tue, 05 Jan 2021 07:31: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 n62sm129118qkn.125.2021.01.05.07.31.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:31: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 105FVlQn020892 for ; Tue, 5 Jan 2021 15:31:47 GMT Subject: [PATCH v1 24/42] NFSD: Update the NFSv2 READLINK argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:31:47 -0500 Message-ID: <160986070740.5532.1963940465503958871.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 If the code that sets up the sink buffer for nfsd_readlink() is moved adjacent to the nfsd_readlink() call site that uses it, then the only argument is a file handle, and the fhandle decoder can be used instead. Signed-off-by: Chuck Lever --- fs/nfsd/nfsproc.c | 9 +++++---- fs/nfsd/nfsxdr.c | 13 ------------- fs/nfsd/xdr.h | 6 ------ 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index 814762793f9c..bdb47848f7fd 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -149,14 +149,15 @@ nfsd_proc_lookup(struct svc_rqst *rqstp) static __be32 nfsd_proc_readlink(struct svc_rqst *rqstp) { - struct nfsd_readlinkargs *argp = rqstp->rq_argp; + struct nfsd_fhandle *argp = rqstp->rq_argp; struct nfsd_readlinkres *resp = rqstp->rq_resp; + char *buffer = page_address(*(rqstp->rq_next_page++)); dprintk("nfsd: READLINK %s\n", SVCFH_fmt(&argp->fh)); /* Read the symlink. */ resp->len = NFS_MAXPATHLEN; - resp->status = nfsd_readlink(rqstp, &argp->fh, argp->buffer, &resp->len); + resp->status = nfsd_readlink(rqstp, &argp->fh, buffer, &resp->len); fh_put(&argp->fh); return rpc_success; @@ -674,9 +675,9 @@ static const struct svc_procedure nfsd_procedures2[18] = { }, [NFSPROC_READLINK] = { .pc_func = nfsd_proc_readlink, - .pc_decode = nfssvc_decode_readlinkargs, + .pc_decode = nfssvc_decode_fhandleargs, .pc_encode = nfssvc_encode_readlinkres, - .pc_argsize = sizeof(struct nfsd_readlinkargs), + .pc_argsize = sizeof(struct nfsd_fhandle), .pc_ressize = sizeof(struct nfsd_readlinkres), .pc_cachetype = RC_NOCACHE, .pc_xdrressize = ST+1+NFS_MAXPATHLEN/4, diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index 11d27b219cff..02dd9888d93b 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -326,19 +326,6 @@ nfssvc_decode_renameargs(struct svc_rqst *rqstp, __be32 *p) return xdr_argsize_check(rqstp, p); } -int -nfssvc_decode_readlinkargs(struct svc_rqst *rqstp, __be32 *p) -{ - struct nfsd_readlinkargs *args = rqstp->rq_argp; - - p = decode_fh(p, &args->fh); - if (!p) - return 0; - args->buffer = page_address(*(rqstp->rq_next_page++)); - - return xdr_argsize_check(rqstp, p); -} - int nfssvc_decode_linkargs(struct svc_rqst *rqstp, __be32 *p) { diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h index d2ffda96975d..288c29a999db 100644 --- a/fs/nfsd/xdr.h +++ b/fs/nfsd/xdr.h @@ -52,11 +52,6 @@ struct nfsd_renameargs { unsigned int tlen; }; -struct nfsd_readlinkargs { - struct svc_fh fh; - char * buffer; -}; - struct nfsd_linkargs { struct svc_fh ffh; struct svc_fh tfh; @@ -150,7 +145,6 @@ int nfssvc_decode_readargs(struct svc_rqst *, __be32 *); int nfssvc_decode_writeargs(struct svc_rqst *, __be32 *); int nfssvc_decode_createargs(struct svc_rqst *, __be32 *); int nfssvc_decode_renameargs(struct svc_rqst *, __be32 *); -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 *); From patchwork Tue Jan 5 15:31:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999337 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 690BDC4332B for ; Tue, 5 Jan 2021 15:32:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4138822AAA for ; Tue, 5 Jan 2021 15:32:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728033AbhAEPch (ORCPT ); Tue, 5 Jan 2021 10:32:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727994AbhAEPcg (ORCPT ); Tue, 5 Jan 2021 10:32:36 -0500 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ED16C061798 for ; Tue, 5 Jan 2021 07:31:56 -0800 (PST) Received: by mail-qv1-xf2d.google.com with SMTP id az16so14808724qvb.5 for ; Tue, 05 Jan 2021 07:31: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=qe/aD+xPugXqU3gg0YpNxbsKePZr14mVF6vn3CIw7xE=; b=pSvCIS2er8hCVqNxCMmfoRtwqWn6DpKrzIPC0dKtRhuPSEx4pfwFAtdezSzQmCHxb2 lgIY1aKFFTZ8b4D/VgaQZ4R/hdsTw8ozJTQ7xA1o32grL0GTK8prAlZf+5ZSzQjX73Uh kJlpKdZbUz58QigTMd8mo/dvKyrKJq5evHcKfNbP8TLaCpNWZLTnzXpmxNugvhYaDql/ vsdS2s+5ZOjrxTczkp/5sCf/UGts5mZsIior58Ogbbo7pFfRhUDHpTcfcZe5P3qzpVsJ w/vuUITIvOxZNjA/iax+pY3O0bnUVC05Y4/1l8+pUP36bVAeBU/Ox79+yi9fLPy8XFlt grPA== 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=qe/aD+xPugXqU3gg0YpNxbsKePZr14mVF6vn3CIw7xE=; b=pejSMMcgYTDQE8tjafW9J4+SEpIr0PL+vC5Bd93f2uvWTzdpyc2164i1s8HiLmn8Y4 VT5RMQuBOGRUDIIYV3uI88I2GEAyrKafE+KnnQ2IIIoVwEspevw2gkSDOGgAB4CSnX30 vYpU2Uw4Uza1DtChniQiXXNB8Yb2i2HCE8jpU0DAq9HpxwBHnkvSjOx5uahxvysf7u1l M45QlazFuZBgyZ1kX44mB1erPxEzWnmO+BKXvUQVEzD9N5pkaf1WKkkOfw4hBiHdlj/7 uRxzhzskW2WnzKg0+I1qB0VwOQ2gveI55faPF/VxIadgPcTmFMsB6pzeCwCvRHJdFcxR ArNQ== X-Gm-Message-State: AOAM532sSp/MxuZivAq/d0Bg7ZdUwwtAWjvjOAuge4eZnbzVKSzGQYrn MY5HGKsnfCpNTP1j7RK5NE5kNx7qyj0= X-Google-Smtp-Source: ABdhPJzPH3JO3V1yxgyBk2ZrRhElpz0+w85QJ2oNyZiC6hPq5Ow77afU/ybLyjIOUtihvlE0ENAkDQ== X-Received: by 2002:a05:6214:d4a:: with SMTP id 10mr137904qvr.62.1609860714361; Tue, 05 Jan 2021 07:31: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 z15sm131732qkz.103.2021.01.05.07.31.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:31:53 -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 105FVqfq020895 for ; Tue, 5 Jan 2021 15:31:52 GMT Subject: [PATCH v1 25/42] NFSD: Add helper to set up the pages where the dirlist is encoded From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:31:52 -0500 Message-ID: <160986071268.5532.3436167990107485019.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 Add a helper similar to nfsd3_init_dirlist_pages(). Signed-off-by: Chuck Lever --- fs/nfsd/nfsproc.c | 29 ++++++++++++++++++----------- fs/nfsd/nfsxdr.c | 2 -- fs/nfsd/xdr.h | 1 - 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index bdb47848f7fd..b2f8035f166b 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -553,6 +553,20 @@ nfsd_proc_rmdir(struct svc_rqst *rqstp) return rpc_success; } +static void nfsd_init_dirlist_pages(struct svc_rqst *rqstp, + struct nfsd_readdirres *resp, + int count) +{ + count = min_t(u32, count, PAGE_SIZE); + + /* Convert byte count to number of words (i.e. >> 2), + * and reserve room for the NULL ptr & eof flag (-2 words) */ + resp->buflen = (count >> 2) - 2; + + resp->buffer = page_address(*rqstp->rq_next_page); + rqstp->rq_next_page++; +} + /* * Read a portion of a directory. */ @@ -561,31 +575,24 @@ nfsd_proc_readdir(struct svc_rqst *rqstp) { struct nfsd_readdirargs *argp = rqstp->rq_argp; struct nfsd_readdirres *resp = rqstp->rq_resp; - int count; loff_t offset; + __be32 *buffer; dprintk("nfsd: READDIR %s %d bytes at %d\n", SVCFH_fmt(&argp->fh), argp->count, argp->cookie); - /* Shrink to the client read size */ - count = (argp->count >> 2) - 2; - - /* Make sure we've room for the NULL ptr & eof flag */ - count -= 2; - if (count < 0) - count = 0; + nfsd_init_dirlist_pages(rqstp, resp, argp->count); + buffer = resp->buffer; - resp->buffer = argp->buffer; resp->offset = NULL; - resp->buflen = count; resp->common.err = nfs_ok; /* Read directory and encode entries on the fly */ offset = argp->cookie; resp->status = nfsd_readdir(rqstp, &argp->fh, &offset, &resp->common, nfssvc_encode_entry); - resp->count = resp->buffer - argp->buffer; + resp->count = resp->buffer - buffer; if (resp->offset) *resp->offset = htonl(offset); diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index 02dd9888d93b..3d72334e1673 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -388,8 +388,6 @@ nfssvc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p) return 0; args->cookie = ntohl(*p++); args->count = ntohl(*p++); - args->count = min_t(u32, args->count, PAGE_SIZE); - args->buffer = page_address(*(rqstp->rq_next_page++)); return xdr_argsize_check(rqstp, p); } diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h index 288c29a999db..d700838f6512 100644 --- a/fs/nfsd/xdr.h +++ b/fs/nfsd/xdr.h @@ -73,7 +73,6 @@ struct nfsd_readdirargs { struct svc_fh fh; __u32 cookie; __u32 count; - __be32 * buffer; }; struct nfsd_stat { From patchwork Tue Jan 5 15:31:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999327 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 A21EFC43381 for ; Tue, 5 Jan 2021 15:32:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7A00A22B45 for ; Tue, 5 Jan 2021 15:32:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727747AbhAEPcQ (ORCPT ); Tue, 5 Jan 2021 10:32:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727520AbhAEPcQ (ORCPT ); Tue, 5 Jan 2021 10:32:16 -0500 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC4FBC061574 for ; Tue, 5 Jan 2021 07:32:00 -0800 (PST) Received: by mail-qt1-x833.google.com with SMTP id z9so21066530qtn.4 for ; Tue, 05 Jan 2021 07:32: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=PfR+145Cl/h2AjN8p5PmJphXz5XskRvy/bZry0aSnnc=; b=iC5Sg15kKUejRn4Ji0+7Jxc3aWab+jgS/5LZ92I0kLSCM8BugI11RYPQfHFZw0cKwC 7ZfEOs3z9rABkJZT5LvWMQfO0CjDdoxbe8KWaLI5Iy2mQfwhk5uWNhn2hd8aYbr6Legf k3KIGtFgW8puPYRbrek3fvMHPUBSMvWyFWkR6ZDO0bi9XSte4P2GqxOK6fBWaM9x6WBp DRsKfWcH+epTRm/3M5eCC3jr04SXm4SLCos++IR0YDSNfF8TYgVQzsFcJAc5J5YfGGPs ISudTkdKrzAUGhPAhImrz+Lu/XoBx+0FwrdmaCtoKNe3X19hH147EfTLwWNORIiyaKMb lPxw== 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=PfR+145Cl/h2AjN8p5PmJphXz5XskRvy/bZry0aSnnc=; b=HTostrRU/ZZ+l6p0h0tbqPH92i/8PMlFnOfOCkxAncmjnQzJwwqCofKj+uGyOVq8Tu x5iAL9h87MHbMTRz19lcmo0TRdvU7MYaYG8YveW+TbsV/O5PFpAeOYtYxJfU+W+8Rbzq ipNFZspaeBiphjqPpPZG6Wnn8nopwQrv2RNy3HMx7r5aGocgnRX2l0qaFBrncQUbd1iU I9lp4CvtfRi8ua4TCYDiGzwQkHhewaD4hwrtl9I94xrovbYrEsGnRTEu7drQstR7v1uq IBPRjK6/oDO2NiylEUH0d7Mf8RQT25tF02OGJdX0VN2yeCDPpUuotQ9JynH2lnCHwOZ/ OlZA== X-Gm-Message-State: AOAM532u47dD8uZUX3bH1+fmrR3bq2Eks8ldlyq7aXtT7OG/BPmqhab7 5bjyQPxd4CCLzoZIjS4USYPwLzqeHxY= X-Google-Smtp-Source: ABdhPJyJX4EzhUBIVXmx5vLTMta2Z0/z2YUDoV4jF+6gyQ+dSZbI9PUS796JVbjeDcCMdIQeOQajCw== X-Received: by 2002:ac8:7954:: with SMTP id r20mr83529qtt.78.1609860719868; Tue, 05 Jan 2021 07:31: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 i13sm135812qkk.83.2021.01.05.07.31.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:31: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 105FVvo6020898 for ; Tue, 5 Jan 2021 15:31:57 GMT Subject: [PATCH v1 26/42] NFSD: Update the NFSv2 READDIR argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:31:57 -0500 Message-ID: <160986071797.5532.6943162493512709242.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 As an additional clean up, move code not related to XDR decoding into readdir's .pc_func call out. Signed-off-by: Chuck Lever --- fs/nfsd/nfsxdr.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index 3d72334e1673..7b33093f8d8b 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -381,15 +381,17 @@ nfssvc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p) int nfssvc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd_readdirargs *args = rqstp->rq_argp; - p = decode_fh(p, &args->fh); - if (!p) + if (!svcxdr_decode_fhandle(xdr, &args->fh)) + return 0; + if (xdr_stream_decode_u32(xdr, &args->cookie) < 0) + return 0; + if (xdr_stream_decode_u32(xdr, &args->count) < 0) return 0; - args->cookie = ntohl(*p++); - args->count = ntohl(*p++); - return xdr_argsize_check(rqstp, p); + return 1; } /* From patchwork Tue Jan 5 15:32:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999331 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 9ABE4C433E6 for ; Tue, 5 Jan 2021 15:32:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C26922B45 for ; Tue, 5 Jan 2021 15:32:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728012AbhAEPcW (ORCPT ); Tue, 5 Jan 2021 10:32:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727994AbhAEPcV (ORCPT ); Tue, 5 Jan 2021 10:32:21 -0500 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1074CC061793 for ; Tue, 5 Jan 2021 07:32:06 -0800 (PST) Received: by mail-qv1-xf29.google.com with SMTP id 4so14824370qvh.1 for ; Tue, 05 Jan 2021 07:32: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=53z1wSTIBTrnZn9EQSK0Z4+C/5arTycITmh8o8oOk4k=; b=AQhtisLiwZwwp+gBEIAWJ4VSX0itSGFPcyKowQWzNNIqBA2x6DMF6oYGI2QoUIUv9p zaX4/W+FMyHM/snRH/UZ4sAJsxSe53BoetHPNgAoEOvHP9GK6bYQPchWo4Zeb3aYB8BX veLAh9IcXwJImOSkCsHTGt38y0SILLj4x90qDMneZ0wCFLUUtXtNk1olClbQnwrnxJS2 ltQiVsKTN2yYcy7aR+uYynDxlumDwafr5TJQbSYUWSHnRnd+3c5fncDIyuD0AWoTrrbD Nc5EuhE69IXMGoInhV7U8e6OvtSfBQnUvOIlQ/IPtvZAkiiDkU1vU8mXKqnwqUgDCpHY Mtcg== 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=53z1wSTIBTrnZn9EQSK0Z4+C/5arTycITmh8o8oOk4k=; b=bOLJW2MMLMtqA3fVVJqc6hUSXoo3YziEGY3sYBjoqKFUpppwXsOhEmvjsqxFrp3A9h iEFz/oBYZVf3KIAOEYC3Mv8t1MOjm9yqn+o4BPR7kgzz63+JGXFZNhz+IEGPHb4GudSE PNZmBO9qq2hahH0MkgzSww3tWycA1iimOcsKtyNlBYouDCWrG68WHhgcObsRZMsKMZjy oVNUT8qrB7NtiAbHfma2QgpyVHn8tvjMAdQx/t4bZVbzKtNdI9AdxrOqdfcHfQP3GMWI JEiM4rskE87oRqN471ocMHDrZlANXMsZMEjn6KsYvZpCKnTMMDzM1CpkO97ZgFUlxgYw 6gqw== X-Gm-Message-State: AOAM532gj8hQFWW/RNPSE6sAvsB8d9WLVIxmBKk2B9NvEtILkI/Q1YQw E7wp5WaPJmmrT9J/eZAJwE1cZB8ESj4= X-Google-Smtp-Source: ABdhPJxzq6OiiYglwNuXoQarq3ScHc/SxFYhBj/qsIZTOkzVMB7ZvU2JmJgSvWZ9B+m53TJnBqSZQA== X-Received: by 2002:a0c:fcc5:: with SMTP id i5mr82159734qvq.48.1609860724958; Tue, 05 Jan 2021 07:32: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 c14sm23279qtg.85.2021.01.05.07.32.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:32: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 105FW3g0020901 for ; Tue, 5 Jan 2021 15:32:03 GMT Subject: [PATCH v1 27/42] NFSD: Update NFSv2 diropargs decoding to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:32:03 -0500 Message-ID: <160986072325.5532.3901165670133816464.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfsxdr.c | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index 7b33093f8d8b..00a7db8548eb 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -86,6 +86,38 @@ decode_filename(__be32 *p, char **namp, unsigned int *lenp) return p; } +static bool +svcxdr_decode_filename(struct xdr_stream *xdr, char **name, unsigned int *len) +{ + u32 size, i; + __be32 *p; + char *c; + + if (xdr_stream_decode_u32(xdr, &size) < 0) + return false; + if (size == 0 || size > NFS_MAXNAMLEN) + return false; + p = xdr_inline_decode(xdr, size); + if (!p) + return false; + + *len = size; + *name = (char *)p; + for (i = 0, c = *name; i < size; i++, c++) + if (*c == '\0' || *c == '/') + return false; + + return true; +} + +static bool +svcxdr_decode_diropargs(struct xdr_stream *xdr, struct svc_fh *fhp, + char **name, unsigned int *len) +{ + return svcxdr_decode_fhandle(xdr, fhp) && + svcxdr_decode_filename(xdr, name, len); +} + static __be32 * decode_sattr(__be32 *p, struct iattr *iap, struct user_namespace *userns) { @@ -234,13 +266,10 @@ nfssvc_decode_sattrargs(struct svc_rqst *rqstp, __be32 *p) int nfssvc_decode_diropargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd_diropargs *args = rqstp->rq_argp; - if (!(p = decode_fh(p, &args->fh)) - || !(p = decode_filename(p, &args->name, &args->len))) - return 0; - - return xdr_argsize_check(rqstp, p); + return svcxdr_decode_diropargs(xdr, &args->fh, &args->name, &args->len); } int From patchwork Tue Jan 5 15:32:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999343 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 1F687C433DB for ; Tue, 5 Jan 2021 15:32:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EFAF722AAA for ; Tue, 5 Jan 2021 15:32:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727966AbhAEPcw (ORCPT ); Tue, 5 Jan 2021 10:32:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728041AbhAEPcv (ORCPT ); Tue, 5 Jan 2021 10:32:51 -0500 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C7B5C061796 for ; Tue, 5 Jan 2021 07:32:11 -0800 (PST) Received: by mail-qt1-x829.google.com with SMTP id g24so21035410qtq.12 for ; Tue, 05 Jan 2021 07:32: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=3nFJIYWhVtrrUM/ZdvK/2KGGilj1b7V6qT33oh6eBgI=; b=XdoDGy4Hy12myG2u1CNeqtoAlRLYdbgVO2pt9CFA4I4GYj23fDdnXqO9u0BiVaumu6 Uy29QO7alBAgg5064lOxZLR+oMk2VG4P5Jh3SKG7DvTA9C6nKd2GE35wLoAm+nx2sBst i2S0azXEj3VhylttUQwpK/WI3Kvf+xSOuG9enZIldD/+tAPdmhfWY6v3P8/2BfXFCe+R fzNnAYrUWkZggE9bTJB2wBG8wS8HTOtEjRBqOUhjUBCOU7HC9BFkLSIS2WCFxvhgMIY/ 9NC8wqglIQKBMqnVIMPhArID31AruFAhV3qbCHzW3PwACFq2p3HlZXTaoZrrrlJQfyuG MlTw== 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=3nFJIYWhVtrrUM/ZdvK/2KGGilj1b7V6qT33oh6eBgI=; b=Fm18tjFVDNh8IjXiDfNFdzma8cltwwHxsjdpQzAKOJc0MD0Be6WUObfQsEL19V942w 03zS0rlDY1m7VnL4tFxCvq6HzllsjeP6kUhr3+h5v953hUAt9oppH7ZM+OlVT8l4PeyY L2NxcroodVlSja86HqVsjzxkuX0g2QeeiwKos/eCTbxmmV/+y9xvwEwmiBKO+8pDlm2V FTMkRCP988l+IcTdsNRzfeEvtbJnI/z8r+c6yGEFVR/2yaOQw+nTnF71HHF0b6Lqq9V5 htG7NRLYvisExk2w0ZoS9c3D/zVds4/G0GMEFvL8kC827yxicYBcrmlHGH1FR+ZOmjZ4 2NRQ== X-Gm-Message-State: AOAM533xyRq//dQlerYJc7MCYnApc1lQbCCDp8Jc60JkqwOpId3eVi0g kddwW09od4VM0Zp4hJpnAhJuHr4fkac= X-Google-Smtp-Source: ABdhPJzI2tyGwcAOxBAyWLlSfDDLfFR4wVYwUcH9d1M1M2YATWTpw+Ni/YVcQgtj0BXliGyLv/Ddcg== X-Received: by 2002:ac8:6910:: with SMTP id e16mr8123qtr.329.1609860730292; Tue, 05 Jan 2021 07:32: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 127sm150138qkj.51.2021.01.05.07.32.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:32: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 105FW8Nh020904 for ; Tue, 5 Jan 2021 15:32:08 GMT Subject: [PATCH v1 28/42] NFSD: Update the NFSv2 RENAME argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:32:08 -0500 Message-ID: <160986072853.5532.3411194354875648394.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfsxdr.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index 00a7db8548eb..d4f4729c7b1c 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -344,15 +344,13 @@ nfssvc_decode_createargs(struct svc_rqst *rqstp, __be32 *p) int nfssvc_decode_renameargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd_renameargs *args = rqstp->rq_argp; - if (!(p = decode_fh(p, &args->ffh)) - || !(p = decode_filename(p, &args->fname, &args->flen)) - || !(p = decode_fh(p, &args->tfh)) - || !(p = decode_filename(p, &args->tname, &args->tlen))) - return 0; - - return xdr_argsize_check(rqstp, p); + return svcxdr_decode_diropargs(xdr, &args->ffh, + &args->fname, &args->flen) && + svcxdr_decode_diropargs(xdr, &args->tfh, + &args->tname, &args->tlen); } int From patchwork Tue Jan 5 15:32:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999335 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 E72A2C433DB for ; Tue, 5 Jan 2021 15:32:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C88DD22B4B for ; Tue, 5 Jan 2021 15:32:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728021AbhAEPcc (ORCPT ); Tue, 5 Jan 2021 10:32:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727994AbhAEPcc (ORCPT ); Tue, 5 Jan 2021 10:32:32 -0500 Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6CA2C061574 for ; Tue, 5 Jan 2021 07:32:16 -0800 (PST) Received: by mail-qv1-xf31.google.com with SMTP id s6so14793620qvn.6 for ; Tue, 05 Jan 2021 07:32: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=8YcedvkKRU4HgNJWPJMrwV8wlECAi0EaUoywCMTNO/Q=; b=NCSDSzXXLt4fP3eORk/WINoI93xhnc2ftyRIx80Ofs7klyOtwHs2+OXA8eWwVoEEQQ wRunja3G0HeHx12ag5s7nDnH92H66PxH7Bh4uh4dSf5EjT9ZBBEALTRFMOg/inrPUMAh 6iy2Rij85ZC3vL7/luXQSB1MKUFxvbjPKgy6xNfkm9cC8WsfcGYiev+hyhBZZrqtKXWz IVr9hX+71jKldpdjrYlx1pI6ekHDKQ4094KoOPjjLwvBSBZtCkitMEyIUEnZAcoT4siX uSh7sI5sv97RIjn9Sk9JES2KFLfGPVDASeyDkfxQYoicaV0mMf16ZOt/QIQVrWc7JoU2 35DQ== 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=8YcedvkKRU4HgNJWPJMrwV8wlECAi0EaUoywCMTNO/Q=; b=CUHlW5wa+VUc1JnBS6dd7wySQcEuOGtgqLuQ79dFcJsgOYDwZ9C02P1C96sTmlM7CN 5E0btPrBXfbePL5T+mKD+JP4CunXMcc82khjuEdGn9QvkE/RMVapKdj2F7cTocxYHnok WgrY9MREiEYJ1x/eMXs3ZuiLPPgq7ysj+bNcMPHtg8s8vJP6uIc+VpB0DXGi4hbev48a 9LEJOsz9l+d6WREbeLyjuY2v+Sfm9FheCYqVeCxTsCV3gF9SsvlP58EPV1FWFw9kEtRL t+CknHcnLxiPculsMEfbVO2g+W3yKHLsViTjbg9zm1dJuAMwMjBURpH82JdUoN5wM3Sx 94lQ== X-Gm-Message-State: AOAM531cRlp5Uv+f7PYBxmSsOZO5GTKdF31CDz5oCKGkzMLo4v21NQ6R aVsHlqUvo1qPZ8Pv3ZxTeHsXUtxBAcA= X-Google-Smtp-Source: ABdhPJxzvVAmnwj5uNpVw6s25NYaoK1RlOShls/7kpgs9xBmNwx3iZSxdDWGpySY3BeHmCgKQYTHOg== X-Received: by 2002:ad4:4f41:: with SMTP id eu1mr145275qvb.1.1609860735796; Tue, 05 Jan 2021 07:32: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 o21sm169450qko.9.2021.01.05.07.32.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:32: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 105FWDPQ020907 for ; Tue, 5 Jan 2021 15:32:13 GMT Subject: [PATCH v1 29/42] NFSD: Update the NFSv2 LINK argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:32:13 -0500 Message-ID: <160986073381.5532.4874558814110521694.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfsxdr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index d4f4729c7b1c..3d0fe03a3fb9 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -356,14 +356,12 @@ nfssvc_decode_renameargs(struct svc_rqst *rqstp, __be32 *p) int nfssvc_decode_linkargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd_linkargs *args = rqstp->rq_argp; - if (!(p = decode_fh(p, &args->ffh)) - || !(p = decode_fh(p, &args->tfh)) - || !(p = decode_filename(p, &args->tname, &args->tlen))) - return 0; - - return xdr_argsize_check(rqstp, p); + return svcxdr_decode_fhandle(xdr, &args->ffh) && + svcxdr_decode_diropargs(xdr, &args->tfh, + &args->tname, &args->tlen); } int From patchwork Tue Jan 5 15:32:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999339 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 A55BDC43331 for ; Tue, 5 Jan 2021 15:32:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6C0D822B45 for ; Tue, 5 Jan 2021 15:32:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727994AbhAEPch (ORCPT ); Tue, 5 Jan 2021 10:32:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728032AbhAEPch (ORCPT ); Tue, 5 Jan 2021 10:32:37 -0500 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8A46C061793 for ; Tue, 5 Jan 2021 07:32:21 -0800 (PST) Received: by mail-qk1-x730.google.com with SMTP id 22so26752713qkf.9 for ; Tue, 05 Jan 2021 07:32:21 -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=temuZmKg8BP/QtAx+9SL0bWe9hueqt1h36Kd+rp2CVY=; b=Y4EjMgKiByI36krKwk1qYu3s29E7JMqGY6tWBCk0e7YG84ywtdKlIT/JJmPjZR2jXv yhGFj1NVmbLvdLSu8PwLkX3lzhc4B7OEGAer/15KbO3+dPECAOpma7ZXaLwp8a+h5E7C FzpELJyglTIK+ZQdd7VkwwKCMdFygsqrO4roi0vM+VZWa0Ouxgc4pLU7jkF/U8MTdXZ0 p/9vmW9Ul1pN+w3QdBIrXf/yyg1ME/ygNzr17Vvlil30RKrJe/sKJdlviQk9b45PY6hD T5otWPKTwzAapSiCGfoLWYIgKpEkMJD3ebqSjUemiYYOkU5LPoFMjQHJdE1hh86p/wYQ I4Qg== 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=temuZmKg8BP/QtAx+9SL0bWe9hueqt1h36Kd+rp2CVY=; b=sUwhgyRu/5Z0y6emwdx0pAK+pJ+ZmGAgrhuqMBI72qiJhBtGHUQkLZKMmvmSVZVlGU svfpBpwXpdJTP97lfx7YuJJXp4huYM+PzZiPccAyTvlUSsPDcw3zFfe/Y8muOrev+uZF eYk8IBkrOr2HtVH0ZO+6EZhycYfLSq1sedeOhpU0GDzTg/KM+6wRt/45kb+d3H/H9QfS 7rPvEQ4YolD5W3bBvhr2Ye+Szd7PSc5zuqkwT8uhrrhTIHYGHCfAPB6neHHMv7JcU4FO mC30DqozyMDlPgSnTpGYBn88WnxboBsrkN/CoXdQhxIVrDqYGltjEm2wc68fQaeU1SSA H4uA== X-Gm-Message-State: AOAM531NDd2Xl21MYYPZE6DMiiszLICTOiPUVIee5J0zS7jiWXlkg9FF 7qfR/A6YuRia9wxxitaPyS2TyhZj5wQ= X-Google-Smtp-Source: ABdhPJxaXBQGabZGoJQjRu6SMOutjKK4TVX5cV8bRxlcjPAqehggP17o9YufweSTN+xdKHXyxt2uEA== X-Received: by 2002:a37:4a4e:: with SMTP id x75mr39133qka.89.1609860740756; Tue, 05 Jan 2021 07:32:20 -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 h25sm24149qtp.80.2021.01.05.07.32.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:32: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 105FWJt3020910 for ; Tue, 5 Jan 2021 15:32:19 GMT Subject: [PATCH v1 30/42] NFSD: Update the NFSv2 SETATTR argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:32:19 -0500 Message-ID: <160986073909.5532.13408794874690782313.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfsxdr.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 76 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index 3d0fe03a3fb9..6c87ea8f3876 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -173,6 +173,79 @@ decode_sattr(__be32 *p, struct iattr *iap, struct user_namespace *userns) return p; } +static bool +svcxdr_decode_sattr(struct svc_rqst *rqstp, struct xdr_stream *xdr, + struct iattr *iap) +{ + u32 tmp1, tmp2; + __be32 *p; + + p = xdr_inline_decode(xdr, XDR_UNIT * 8); + if (!p) + return false; + + iap->ia_valid = 0; + + /* + * Some Sun clients put 0xffff in the mode field when they + * mean 0xffffffff. + */ + tmp1 = be32_to_cpup(p++); + if (tmp1 != (u32)-1 && tmp1 != 0xffff) { + iap->ia_valid |= ATTR_MODE; + iap->ia_mode = tmp1; + } + + tmp1 = be32_to_cpup(p++); + if (tmp1 != (u32)-1) { + iap->ia_uid = make_kuid(nfsd_user_namespace(rqstp), tmp1); + if (uid_valid(iap->ia_uid)) + iap->ia_valid |= ATTR_UID; + } + + tmp1 = be32_to_cpup(p++); + if (tmp1 != (u32)-1) { + iap->ia_gid = make_kgid(nfsd_user_namespace(rqstp), tmp1); + if (gid_valid(iap->ia_gid)) + iap->ia_valid |= ATTR_GID; + } + + tmp1 = be32_to_cpup(p++); + if (tmp1 != (u32)-1) { + iap->ia_valid |= ATTR_SIZE; + iap->ia_size = tmp1; + } + + tmp1 = be32_to_cpup(p++); + tmp2 = be32_to_cpup(p++); + if (tmp1 != (u32)-1 && tmp2 != (u32)-1) { + iap->ia_valid |= ATTR_ATIME | ATTR_ATIME_SET; + iap->ia_atime.tv_sec = tmp1; + iap->ia_atime.tv_nsec = tmp2 * NSEC_PER_USEC; + } + + tmp1 = be32_to_cpup(p++); + tmp2 = be32_to_cpup(p++); + if (tmp1 != (u32)-1 && tmp2 != (u32)-1) { + iap->ia_valid |= ATTR_MTIME | ATTR_MTIME_SET; + iap->ia_mtime.tv_sec = tmp1; + iap->ia_mtime.tv_nsec = tmp2 * NSEC_PER_USEC; + /* + * Passing the invalid value useconds=1000000 for mtime + * is a Sun convention for "set both mtime and atime to + * current server time". It's needed to make permissions + * checks for the "touch" program across v2 mounts to + * Solaris and Irix boxes work correctly. See description of + * sattr in section 6.1 of "NFS Illustrated" by + * Brent Callaghan, Addison-Wesley, ISBN 0-201-32750-5 + */ + if (tmp2 == 1000000) + iap->ia_valid &= ~(ATTR_ATIME_SET|ATTR_MTIME_SET); + } + + return true; +} + static __be32 * encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, struct kstat *stat) @@ -253,14 +326,11 @@ nfssvc_decode_fhandleargs(struct svc_rqst *rqstp, __be32 *p) int nfssvc_decode_sattrargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd_sattrargs *args = rqstp->rq_argp; - p = decode_fh(p, &args->fh); - if (!p) - return 0; - p = decode_sattr(p, &args->attrs, nfsd_user_namespace(rqstp)); - - return xdr_argsize_check(rqstp, p); + return svcxdr_decode_fhandle(xdr, &args->fh) && + svcxdr_decode_sattr(rqstp, xdr, &args->attrs); } int From patchwork Tue Jan 5 15:32:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999349 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 5E734C433DB for ; Tue, 5 Jan 2021 15:33:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3598022AAB for ; Tue, 5 Jan 2021 15:33:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727307AbhAEPdI (ORCPT ); Tue, 5 Jan 2021 10:33:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728060AbhAEPdH (ORCPT ); Tue, 5 Jan 2021 10:33:07 -0500 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DFA2BC061795 for ; Tue, 5 Jan 2021 07:32:26 -0800 (PST) Received: by mail-qt1-x832.google.com with SMTP id z20so21056735qtq.3 for ; Tue, 05 Jan 2021 07:32: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=S8lZyaF5q5GnNU8MedRayrJcC/pOoyE3fWkHFZYR7QA=; b=AGV68fj5R91xRVwKOLSobRdbcYOa7CanOh2acQJX1UW9AHuz2RbiLTTFok7JkDPOpl zYLOUaomO6w/tMtVY2PSJvXm+evBWrbkzVJ4fIOM5SauNXYJ73jz9LOSCsN6aNdLLXkr gyVnQsuI/8IHbVbRw3keEFyfrF/ssfLEH7igGqO3OVbRvA4ItWsIgWlmSMWRbADvKMbb 56nG2Tu0d0W6qclHpK3tIjuYFE+1zEvvwVGL+XozBiXhXxaJ3g58vK5OTI8x+T9Tim/s 2KPk0riQl4O85R7l0hj0YmscGHngKyrWp0GdnXKoYlZ6eEBRifLkkGQFSKfvzINZfjaP +pCg== 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=S8lZyaF5q5GnNU8MedRayrJcC/pOoyE3fWkHFZYR7QA=; b=Y1PcIfOnJyElppi4bBg9JRl2nAmcK9KbDIq9op9IBpG6Q0lO3uWa1Q18WtCxtyA3IO tTiil4E6+LD8iv9mTKusp9jyz7nCAUz7qUNZq/t0VUj6yTr4figzsWDXLjsSOtja5E90 v9HvSUzT21eCsPHbnQS8zvqCVgDdqmTmgaNBs4N700Fkj322yn2ckE2YkQcGEDt9N34G ZpCExjt8iFEhsYSRGOjsOOZmOriXkWML3TAC3BF8nX4yyGqaI1hgr1qic+4dZCQ0apaX PWFMpnC2cujMWUODPrDjmxdH+MQNOSPpCxYYQVNzXNKPEkn/NB7ViKwPMbfVOEzJZBaK /iRQ== X-Gm-Message-State: AOAM532P+dt1lZ/S/fNJZ1sGMrzprHhmU2gpz4gHeZK+VRWj0XSrh+vB W3geBsNVlXaZBLbhLMB6h8JpMRa+Zj8= X-Google-Smtp-Source: ABdhPJzhD6fBzxya5VwNxgrxUhygORp/7BhDjhZlm3lIFkxxw99g9qf/ZbIEJgI+H2HtxvIdChiotQ== X-Received: by 2002:ac8:7510:: with SMTP id u16mr32285qtq.139.1609860745916; Tue, 05 Jan 2021 07:32: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 j142sm133879qke.117.2021.01.05.07.32.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:32: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 105FWOlW020913 for ; Tue, 5 Jan 2021 15:32:24 GMT Subject: [PATCH v1 31/42] NFSD: Update the NFSv2 CREATE argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:32:24 -0500 Message-ID: <160986074438.5532.3292569454405268867.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfsxdr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index 6c87ea8f3876..2e2806cbe7b8 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -401,14 +401,12 @@ nfssvc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p) int nfssvc_decode_createargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd_createargs *args = rqstp->rq_argp; - if ( !(p = decode_fh(p, &args->fh)) - || !(p = decode_filename(p, &args->name, &args->len))) - return 0; - p = decode_sattr(p, &args->attrs, nfsd_user_namespace(rqstp)); - - return xdr_argsize_check(rqstp, p); + return svcxdr_decode_diropargs(xdr, &args->fh, + &args->name, &args->len) && + svcxdr_decode_sattr(rqstp, xdr, &args->attrs); } int From patchwork Tue Jan 5 15:32:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999341 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 C7B0CC433DB for ; Tue, 5 Jan 2021 15:32:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8460C22AAA for ; Tue, 5 Jan 2021 15:32:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728032AbhAEPcr (ORCPT ); Tue, 5 Jan 2021 10:32:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727966AbhAEPcr (ORCPT ); Tue, 5 Jan 2021 10:32:47 -0500 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BDD2C06179A for ; Tue, 5 Jan 2021 07:32:32 -0800 (PST) Received: by mail-qk1-x730.google.com with SMTP id d14so26719563qkc.13 for ; Tue, 05 Jan 2021 07:32: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=vXIg3TTAMYA/x3GVdZiabfVYqYiXJclDZ4PP+hmvvdA=; b=NzJ6K8a8YhMLhw3v3fPbZ5P6XQ8EQEHdIGUrXg6zVioYCCy6arPHaxwfLCbgW5Cv7c EasvVTZ5ehsmLNPjfASXZA8R1iDOMoe64+VjBxCnAIz6ollFBVc1EQ98Ot1er6jecIQF dZ+Bk0FrnEzpHMN95H1HHDAnPwB50HbZL45AIl4QXgGbKA7jgH6YDp2feNPN9V/XbtLT K50VIs3nGPBPWXq0WE3JhqDnqVHfjlv0x0CjzuwbffaJO9eCWQX8T8B8IFbdcoR8tIcc Xa9e8RMyz9vrLjqJr5wlaQffHvlT17tkJ7bhDPuMZlvtb16LRUWmLwUk2M2y1tsYsDOL 2rSw== 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=vXIg3TTAMYA/x3GVdZiabfVYqYiXJclDZ4PP+hmvvdA=; b=nyU5iE5oBkUUaPEkxlyWkGJVcmS2udw4CwCclyJ5x9xCvtXHk0ZU+rqoKf8vyYwmey knkPTcIrUppkpPOO2vB9W6it9ri0oG1kdkses5zmQ00e7OAh8di5gSSC4zLIXHaabuy/ qsnEeAl42T/S5uNFVpwW7vxGLXMihsv1kMlgeAigoGEPAuHuF2233v8iEUHU7D3sDi3r VP6U4SQ4uj241XaYmeOETrJAjCuFczxm8wu+Wm8l6pPFnrgu87+ZjFkZpybqOj8kStXg 21aWj1+E4omamMU0kbqL6owTLik4cgS27ciLtRYo7IXFXbfKtHp4/KQXwD7FaPwspR4Y fc+Q== X-Gm-Message-State: AOAM532Xes/iZfRNPQsEOsQPVUGsGizhU23GA6euTVqt+FM/sDNRpI7U UCa6gjBibSR/z0UtxrcFNkgJt0osz6U= X-Google-Smtp-Source: ABdhPJydilAkssyOf3CxSvarmgMFhxsPC9mZWkTG1InBoWVmUU1q+Ud6F9WQsqAdNLBf4eE49SS28A== X-Received: by 2002:ae9:f30c:: with SMTP id p12mr82446qkg.154.1609860751163; Tue, 05 Jan 2021 07:32: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 r6sm125830qkk.127.2021.01.05.07.32.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:32: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 105FWTA8020916 for ; Tue, 5 Jan 2021 15:32:29 GMT Subject: [PATCH v1 32/42] NFSD: Update the NFSv2 SYMLINK argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:32:29 -0500 Message-ID: <160986074948.5532.6358484489073990169.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfsxdr.c | 113 +++++------------------------------------------------- 1 file changed, 10 insertions(+), 103 deletions(-) diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index 2e2806cbe7b8..f2cb4794aeaf 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -66,26 +66,6 @@ encode_fh(__be32 *p, struct svc_fh *fhp) return p + (NFS_FHSIZE>> 2); } -/* - * Decode a file name and make sure that the path contains - * no slashes or null bytes. - */ -static __be32 * -decode_filename(__be32 *p, char **namp, unsigned int *lenp) -{ - char *name; - unsigned int i; - - if ((p = xdr_decode_string_inplace(p, namp, lenp, NFS_MAXNAMLEN)) != NULL) { - for (i = 0, name = *namp; i < *lenp; i++, name++) { - if (*name == '\0' || *name == '/') - return NULL; - } - } - - return p; -} - static bool svcxdr_decode_filename(struct xdr_stream *xdr, char **name, unsigned int *len) { @@ -118,61 +98,6 @@ svcxdr_decode_diropargs(struct xdr_stream *xdr, struct svc_fh *fhp, svcxdr_decode_filename(xdr, name, len); } -static __be32 * -decode_sattr(__be32 *p, struct iattr *iap, struct user_namespace *userns) -{ - u32 tmp, tmp1; - - iap->ia_valid = 0; - - /* Sun client bug compatibility check: some sun clients seem to - * put 0xffff in the mode field when they mean 0xffffffff. - * Quoting the 4.4BSD nfs server code: Nah nah nah nah na nah. - */ - if ((tmp = ntohl(*p++)) != (u32)-1 && tmp != 0xffff) { - iap->ia_valid |= ATTR_MODE; - iap->ia_mode = tmp; - } - if ((tmp = ntohl(*p++)) != (u32)-1) { - iap->ia_uid = make_kuid(userns, tmp); - if (uid_valid(iap->ia_uid)) - iap->ia_valid |= ATTR_UID; - } - if ((tmp = ntohl(*p++)) != (u32)-1) { - iap->ia_gid = make_kgid(userns, tmp); - if (gid_valid(iap->ia_gid)) - iap->ia_valid |= ATTR_GID; - } - if ((tmp = ntohl(*p++)) != (u32)-1) { - iap->ia_valid |= ATTR_SIZE; - iap->ia_size = tmp; - } - tmp = ntohl(*p++); tmp1 = ntohl(*p++); - if (tmp != (u32)-1 && tmp1 != (u32)-1) { - iap->ia_valid |= ATTR_ATIME | ATTR_ATIME_SET; - iap->ia_atime.tv_sec = tmp; - iap->ia_atime.tv_nsec = tmp1 * 1000; - } - tmp = ntohl(*p++); tmp1 = ntohl(*p++); - if (tmp != (u32)-1 && tmp1 != (u32)-1) { - iap->ia_valid |= ATTR_MTIME | ATTR_MTIME_SET; - iap->ia_mtime.tv_sec = tmp; - iap->ia_mtime.tv_nsec = tmp1 * 1000; - /* - * Passing the invalid value useconds=1000000 for mtime - * is a Sun convention for "set both mtime and atime to - * current server time". It's needed to make permissions - * checks for the "touch" program across v2 mounts to - * Solaris and Irix boxes work correctly. See description of - * sattr in section 6.1 of "NFS Illustrated" by - * Brent Callaghan, Addison-Wesley, ISBN 0-201-32750-5 - */ - if (tmp1 == 1000000) - iap->ia_valid &= ~(ATTR_ATIME_SET|ATTR_MTIME_SET); - } - return p; -} - static bool svcxdr_decode_sattr(struct svc_rqst *rqstp, struct xdr_stream *xdr, struct iattr *iap) @@ -435,40 +360,22 @@ nfssvc_decode_linkargs(struct svc_rqst *rqstp, __be32 *p) int nfssvc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd_symlinkargs *args = rqstp->rq_argp; - char *base = (char *)p; - size_t xdrlen; + struct kvec *head = rqstp->rq_arg.head; - if ( !(p = decode_fh(p, &args->ffh)) - || !(p = decode_filename(p, &args->fname, &args->flen))) + if (!svcxdr_decode_diropargs(xdr, &args->ffh, &args->fname, &args->flen)) + return 0; + if (xdr_stream_decode_u32(xdr, &args->tlen) < 0) return 0; - - args->tlen = ntohl(*p++); if (args->tlen == 0) return 0; - args->first.iov_base = p; - args->first.iov_len = rqstp->rq_arg.head[0].iov_len; - args->first.iov_len -= (char *)p - base; - - /* This request is never larger than a page. Therefore, - * transport will deliver either: - * 1. pathname in the pagelist -> sattr is in the tail. - * 2. everything in the head buffer -> sattr is in the head. - */ - if (rqstp->rq_arg.page_len) { - if (args->tlen != rqstp->rq_arg.page_len) - return 0; - p = rqstp->rq_arg.tail[0].iov_base; - } else { - xdrlen = XDR_QUADLEN(args->tlen); - if (xdrlen > args->first.iov_len - (8 * sizeof(__be32))) - return 0; - p += xdrlen; - } - decode_sattr(p, &args->attrs, nfsd_user_namespace(rqstp)); - - return 1; + args->first.iov_len = head->iov_len - xdr_stream_pos(xdr); + args->first.iov_base = xdr_inline_decode(xdr, args->tlen); + if (!args->first.iov_base) + return 0; + return svcxdr_decode_sattr(rqstp, xdr, &args->attrs); } int From patchwork Tue Jan 5 15:32:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999345 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 1B822C433E9 for ; Tue, 5 Jan 2021 15:32:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8C6222AAA for ; Tue, 5 Jan 2021 15:32:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728044AbhAEPcx (ORCPT ); Tue, 5 Jan 2021 10:32:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728041AbhAEPcx (ORCPT ); Tue, 5 Jan 2021 10:32:53 -0500 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8EF7AC061574 for ; Tue, 5 Jan 2021 07:32:37 -0800 (PST) Received: by mail-qk1-x731.google.com with SMTP id h4so26816497qkk.4 for ; Tue, 05 Jan 2021 07:32: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=eBDnHnNtbOsWQF3HME0FnBt2R9L4nyG4xusmfpl9RoY=; b=WnZxgthLsW0fuGljFIef0KGPZe9kRO7pULZDhuwt/4xIwYrlbT9MtcXIzQgkx6EOlx pABa4pqwdrZS4bvHFwAqK9TfFrSbL18xmZK6WiRDOuAiqUv+Rdl9I96w9QXul7c0tABE +NUKZ0zw9uFBUCi9Da6CRE/vLodinfJm1NYles9yfJ8kLfwtRldlr4lyBm3rUPC6A39x PD0/hA2Wdcj/2prAIhdtOCsP53N45qfguQCtEaBJkH9WPSDGf5iviB4mUHU+unLobtIz 6yoRDEZtMSPdxvi23XP9Svh+deXnPrIbMV9PDF+OAROX/9um+gD82zBvUdjcksPeEfvl vXwQ== 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=eBDnHnNtbOsWQF3HME0FnBt2R9L4nyG4xusmfpl9RoY=; b=cs0NQTmExPJqfykC/NPsixubZ0PNizXABV6yn4gnC2tMkkkLX53zcQooKwyvH1d1S1 vvA00N3+Xg7n+LZCf5VlkbUNdZKc6daio5JFLvhEtyXUqHRPD9mBAW6FMve7d83PQ+uL ok0w+eeMLDK+rUgNRWy6AQMNTGhXtxJgJHu9xqVw6TueyDSV1dnVQlda+i/Bvtqvs9YK vn/ljTxp+iQrY0btxQRqz7+0uqHxg15J0xBCXM+zzB9Biw1ltwpMlWfU2nqyHVFHpQzK V9OycsluGth8uwVwMRqkGXSQrsN7UGQd+6GPUuCIYigawPYHNzoWzNRcwODn5894VQC2 K1+A== X-Gm-Message-State: AOAM532k77cZSa+g4tG+7ANB7voPAPi1lD8xXk3sFS0Dx0QKXqH+Dpk2 Rz1YFCmqQyEEALhaSl9WmfAb3dDQumM= X-Google-Smtp-Source: ABdhPJw29jBzdXx/HdINXG1Jt3EwpeoC0owDDpBVtVdpCJe3lUn3eoW/UtLlKyY4au0qRRZTsV0pLQ== X-Received: by 2002:a37:57c7:: with SMTP id l190mr829qkb.487.1609860756532; Tue, 05 Jan 2021 07:32: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 k141sm157032qke.38.2021.01.05.07.32.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:32:35 -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 105FWY9K020919 for ; Tue, 5 Jan 2021 15:32:34 GMT Subject: [PATCH v1 33/42] NFSD: Remove argument length checking in nfsd_dispatch() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:32:34 -0500 Message-ID: <160986075477.5532.874590573395626610.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 the argument decoders for NFSv2 and NFSv3 use the xdr_stream mechanism, the version-specific length checking logic in nfsd_dispatch() is no longer necessary. Signed-off-by: Chuck Lever --- fs/nfsd/nfssvc.c | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index f9c9f4c63cc7..6de406322106 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -955,37 +955,6 @@ nfsd(void *vrqstp) return 0; } -/* - * A write procedure can have a large argument, and a read procedure can - * have a large reply, but no NFSv2 or NFSv3 procedure has argument and - * reply that can both be larger than a page. The xdr code has taken - * advantage of this assumption to be a sloppy about bounds checking in - * some cases. Pending a rewrite of the NFSv2/v3 xdr code to fix that - * problem, we enforce these assumptions here: - */ -static bool nfs_request_too_big(struct svc_rqst *rqstp, - const struct svc_procedure *proc) -{ - /* - * The ACL code has more careful bounds-checking and is not - * susceptible to this problem: - */ - if (rqstp->rq_prog != NFS_PROGRAM) - return false; - /* - * Ditto NFSv4 (which can in theory have argument and reply both - * more than a page): - */ - if (rqstp->rq_vers >= 4) - return false; - /* The reply will be small, we're OK: */ - if (proc->pc_xdrressize > 0 && - proc->pc_xdrressize < XDR_QUADLEN(PAGE_SIZE)) - return false; - - return rqstp->rq_arg.len > PAGE_SIZE; -} - /** * nfsd_dispatch - Process an NFS or NFSACL Request * @rqstp: incoming request @@ -1004,9 +973,6 @@ int nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp) struct kvec *resv = &rqstp->rq_res.head[0]; __be32 *p; - if (nfs_request_too_big(rqstp, proc)) - goto out_decode_err; - /* * Give the xdr decoder a chance to change this if it wants * (necessary in the NFSv4.0 compound case) From patchwork Tue Jan 5 15:32:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999355 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 5143CC433E0 for ; Tue, 5 Jan 2021 15:33:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2827922AAB for ; Tue, 5 Jan 2021 15:33:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728064AbhAEPdX (ORCPT ); Tue, 5 Jan 2021 10:33:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728041AbhAEPdX (ORCPT ); Tue, 5 Jan 2021 10:33:23 -0500 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCD65C061793 for ; Tue, 5 Jan 2021 07:32:42 -0800 (PST) Received: by mail-qk1-x733.google.com with SMTP id v126so26717856qkd.11 for ; Tue, 05 Jan 2021 07:32: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=AEPcFkkW+BzzpizK6dn04qQ1b3yoPd7eaMzroqgeS8Q=; b=uCemquH6w/hD5X4glDeABKzm916gTCYJRHsKa+gfRFCfr9LyP26OaOwcfpWLR508DK oEfPx1AxNqmpvt8xldFXWb4//zvUwbma/fOG/wGdTZNEKqgi08X+turm0gxqVjVHbXMI Qw7ZjAvgfmm0TxCC07DuAXB/9fwTvOB3oHBfxTsEiLkxb7dHhkBvtzyosGww5ymWEj3C b/Qp6rtLLfQgKyXy3vNnZ6J9DK3UNRWRLV4FoyoTALj9gBmn6gtBF+VzJz3AgxUQlzhX GmYKbUnZ9QdnxGldAUoZUpibJ+Oi1K1O00cqDl1LOgOxVkYnkA/L5/oAF0vnAGTSOoG+ TAxg== 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=AEPcFkkW+BzzpizK6dn04qQ1b3yoPd7eaMzroqgeS8Q=; b=fEUO24MyQD6oBZb2fZbqn4V5sI3Ckk3Og6JdrxWNhj4uPbpR9/nM5RxvMqgluCmQ5d oj9hHbogOINRNnHhvQuZTrwBjV8dWG/FSaEFJDpOYfBNufNaMw23kCqsG9meiIGTUwnd 6i/bj9ABhmoBnx1Q+ykkspQX2epavSmuqz2oZlYf/IVQUU3mShaYLFqr5sp8Oesf1iv2 pF/xpkEsKtTAaAC1O9160+hKBVENEf1Uu19DLhc9YeQIu/YkEbjs3v4cc0eOArR/3QJA IE4kfROZjqhOZQvEaXdB+2wLjNhWyNZGRkZEzut9QO4oRX5lezPprflfRkaPdupuFpo2 tPeg== X-Gm-Message-State: AOAM5325p9VexWyLyqnmTtbu/JDBnP3CNXe8kxcjcqTiiid4f6sy7zwb Bos8pwCIoJd4OmtDagWmSt6HCr1YyZU= X-Google-Smtp-Source: ABdhPJz2u3Kv/R1JMloI8+fK/U8hhtkvtSgW19kmj9FnrrUoGSUn34qvjY6nXSxu0YBYOM6OayRn4Q== X-Received: by 2002:a37:a80a:: with SMTP id r10mr2454qke.467.1609860761660; Tue, 05 Jan 2021 07:32:41 -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 w8sm46457qts.50.2021.01.05.07.32.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:32: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 105FWeIR020922 for ; Tue, 5 Jan 2021 15:32:40 GMT Subject: [PATCH v1 34/42] NFSD: Update the NFSv2 GETACL argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:32:40 -0500 Message-ID: <160986076005.5532.6867620081951278716.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs2acl.c | 10 +++++----- fs/nfsd/nfsxdr.c | 11 ++++++++++- fs/nfsd/xdr.h | 1 + fs/nfsd/xdr3.h | 2 +- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c index 899762da23c9..df2e145cfab0 100644 --- a/fs/nfsd/nfs2acl.c +++ b/fs/nfsd/nfs2acl.c @@ -188,17 +188,17 @@ static __be32 nfsacld_proc_access(struct svc_rqst *rqstp) static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_getaclargs *argp = rqstp->rq_argp; - p = nfs2svc_decode_fh(p, &argp->fh); - if (!p) + if (!svcxdr_decode_fhandle(xdr, &argp->fh)) + return 0; + if (xdr_stream_decode_u32(xdr, &argp->mask) < 0) return 0; - argp->mask = ntohl(*p); p++; - return xdr_argsize_check(rqstp, p); + return 1; } - static int nfsaclsvc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p) { struct nfsd3_setaclargs *argp = rqstp->rq_argp; diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index f2cb4794aeaf..5ab9fc14816c 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -38,7 +38,16 @@ decode_fh(__be32 *p, struct svc_fh *fhp) return p + (NFS_FHSIZE >> 2); } -static bool +/** + * svcxdr_decode_fhandle - Decode an NFSv2 file handle + * @xdr: XDR stream positioned at an encoded NFSv2 FH + * @fhp: OUT: filled-in server file handle + * + * Return values: + * %false: The encoded file handle was not valid + * %true: @fhp has been initialized + */ +bool svcxdr_decode_fhandle(struct xdr_stream *xdr, struct svc_fh *fhp) { __be32 *p; diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h index d700838f6512..035c99c7b384 100644 --- a/fs/nfsd/xdr.h +++ b/fs/nfsd/xdr.h @@ -165,5 +165,6 @@ void nfssvc_release_readres(struct svc_rqst *rqstp); /* Helper functions for NFSv2 ACL code */ __be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, struct kstat *stat); __be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp); +bool svcxdr_decode_fhandle(struct xdr_stream *xdr, struct svc_fh *fhp); #endif /* LINUX_NFSD_H */ diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h index 64af5b01c5d7..43db4206cd25 100644 --- a/fs/nfsd/xdr3.h +++ b/fs/nfsd/xdr3.h @@ -102,7 +102,7 @@ struct nfsd3_commitargs { struct nfsd3_getaclargs { struct svc_fh fh; - int mask; + __u32 mask; }; struct posix_acl; From patchwork Tue Jan 5 15:32:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999347 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 A15A4C433DB for ; Tue, 5 Jan 2021 15:33:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78F0922AAB for ; Tue, 5 Jan 2021 15:33:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728056AbhAEPdD (ORCPT ); Tue, 5 Jan 2021 10:33:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727906AbhAEPdD (ORCPT ); Tue, 5 Jan 2021 10:33:03 -0500 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10906C061798 for ; Tue, 5 Jan 2021 07:32:48 -0800 (PST) Received: by mail-qk1-x72a.google.com with SMTP id f26so26835123qka.0 for ; Tue, 05 Jan 2021 07:32: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=Qx5XLzqsdqZoy2l1sbxft7U1zWtg0T+upqt17SH16Xs=; b=a1TCMQvSJP5dRuIjQyJWEbTstogXr+mO7kpckdpd5Loa4C/v3Qnck5sxetjzRJwfLk 30dWVjf4s5JODCrf9MbVR7ybJ58syzcGW4JlU4WNYEopSOTZ+d4Wp2SOT0mQfFZtGfOq A54xiuxzL/XsZygnLH3BVQof9IJnbx8pbCDA+B2sNnOVrZfYeH5rRJOiuhwweb2yYcI7 V1EBFIAx5s2+j7O9In0XwIDVe7c10L7Owo2xT2eGoJ+WM60ntMQDZs24WyKVabW3RqEx 5we0qUN82MIqiR/Xv1b0W6pVcCA/3Z+1XfR0F7+WDDyTgSKLh/t4CXkSYqFTQhZFHeNW yxVA== 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=Qx5XLzqsdqZoy2l1sbxft7U1zWtg0T+upqt17SH16Xs=; b=HEwDKxURsUwPFe74ZqtGoaC8g+lMScVCuNOPMRyUUN8zLYf/51+Qj1ZCfy2hMAIlNh v+8JIQBiCPWvtlRkVbapoPF32qPLFwTzH5XTZ1k5imCFbDt/dNP+i6HDWmWmP0Q8tD+q q8do4cFTle4QFS1FJESsrgS4yzF34qU/gK2o+I2z2DJ6Z3to+ODS5AEy6G0z8fZHrV6b wxu6/4o5OfSkR4o9gDd9sOCtsQiMPgZkHhvOjZ6+hIDAhClX/8yp9y6cL6bX19bt8uwp mQ5LzHyzHDQA6ZdH8u3cMKtM95OTZKmML8zqTz7xcPVudU08Wnu6JINDlfsgWL63Dp0R Cktg== X-Gm-Message-State: AOAM533/G0PHhMkTMi46HcvKkCN21BzBpHg99n4iiLYeg4pprtuCNeBq +f3qQ4Yz4g/U213//OTNj0oRy4LVGgc= X-Google-Smtp-Source: ABdhPJy1RNTxv14vtQ4LGS33xcTujlnmBn6n1skQN4M8SuyaYQehLxeFzvpJMxoulebOnWCKabalYw== X-Received: by 2002:a37:a8a:: with SMTP id 132mr15832qkk.327.1609860766997; Tue, 05 Jan 2021 07:32: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 e10sm19389qtr.92.2021.01.05.07.32.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:32: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 105FWjkY020925 for ; Tue, 5 Jan 2021 15:32:45 GMT Subject: [PATCH v1 35/42] NFSD: Add an xdr_stream-based decoder for NFSv2/3 ACLs From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:32:45 -0500 Message-ID: <160986076534.5532.16229382857405416474.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs_common/nfsacl.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/nfsacl.h | 3 +++ 2 files changed, 55 insertions(+) diff --git a/fs/nfs_common/nfsacl.c b/fs/nfs_common/nfsacl.c index d056ad2fdefd..79c563c1a5e8 100644 --- a/fs/nfs_common/nfsacl.c +++ b/fs/nfs_common/nfsacl.c @@ -295,3 +295,55 @@ int nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt, nfsacl_desc.desc.array_len; } EXPORT_SYMBOL_GPL(nfsacl_decode); + +/** + * nfs_stream_decode_acl - Decode an NFSv3 ACL + * + * @xdr: an xdr_stream positioned at an encoded ACL + * @aclcnt: OUT: count of ACEs in decoded posix_acl + * @pacl: OUT: a dynamically-allocated buffer containing the decoded posix_acl + * + * Return values: + * %false: The encoded ACL is not valid + * %true: @pacl contains a decoded ACL, and @xdr is advanced + * + * On a successful return, caller must release *pacl using posix_acl_release(). + */ +bool nfs_stream_decode_acl(struct xdr_stream *xdr, unsigned int *aclcnt, + struct posix_acl **pacl) +{ + const size_t elem_size = XDR_UNIT * 3; + struct nfsacl_decode_desc nfsacl_desc = { + .desc = { + .elem_size = elem_size, + .xcode = pacl ? xdr_nfsace_decode : NULL, + }, + }; + unsigned int base; + u32 entries; + + if (xdr_stream_decode_u32(xdr, &entries) < 0) + return false; + if (entries > NFS_ACL_MAX_ENTRIES) + return false; + + base = xdr_stream_pos(xdr); + if (!xdr_inline_decode(xdr, XDR_UNIT + elem_size * entries)) + return false; + nfsacl_desc.desc.array_maxlen = entries; + if (xdr_decode_array2(xdr->buf, base, &nfsacl_desc.desc)) + return false; + + if (pacl) { + if (entries != nfsacl_desc.desc.array_len || + posix_acl_from_nfsacl(nfsacl_desc.acl) != 0) { + posix_acl_release(nfsacl_desc.acl); + return false; + } + *pacl = nfsacl_desc.acl; + } + if (aclcnt) + *aclcnt = entries; + return true; +} +EXPORT_SYMBOL_GPL(nfs_stream_decode_acl); diff --git a/include/linux/nfsacl.h b/include/linux/nfsacl.h index 103d44695323..0ba99c513649 100644 --- a/include/linux/nfsacl.h +++ b/include/linux/nfsacl.h @@ -38,5 +38,8 @@ nfsacl_encode(struct xdr_buf *buf, unsigned int base, struct inode *inode, extern int nfsacl_decode(struct xdr_buf *buf, unsigned int base, unsigned int *aclcnt, struct posix_acl **pacl); +extern bool +nfs_stream_decode_acl(struct xdr_stream *xdr, unsigned int *aclcnt, + struct posix_acl **pacl); #endif /* __LINUX_NFSACL_H */ From patchwork Tue Jan 5 15:32:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999351 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 7C6B6C433E0 for ; Tue, 5 Jan 2021 15:33:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56A7422AAB for ; Tue, 5 Jan 2021 15:33:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727906AbhAEPdJ (ORCPT ); Tue, 5 Jan 2021 10:33:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728060AbhAEPdI (ORCPT ); Tue, 5 Jan 2021 10:33:08 -0500 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AE73C061574 for ; Tue, 5 Jan 2021 07:32:53 -0800 (PST) Received: by mail-qk1-x72c.google.com with SMTP id h4so26817368qkk.4 for ; Tue, 05 Jan 2021 07:32: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=NO77RhHtUedYp4qFpiBBG4Tv5P6/osz6EYRha2NhNhk=; b=LBH1OY977QFEYCShgeKGpDgu3FDfHV05KkXE9b+UwIqHtyvPMiXk4UbO3jmRAellJb ZEpGVIsOtk0vyI8bkf4sDmCPY+lV2mV9pOWj0JlBF9k2arnMchAYv5BCl4K/0elMr7rk 6NSwp9thWx7TFtBhpyZxP3GQ+IyP+TUcs9TgHEoxz7abONTcsKoTod2tkD2VF0S4NhqC S7cgp1rCkkwpXiTzIpOIk6ReSUTAp71DEtVYGcTUuqkxbV2de9ALP1qemwy9ZgZImI82 FoL63rgerMxbXHz7gMDZMSD4MYyiT8+kjTmH5hAWlOsNZmHTte6ZSBE7nnX6KLBgX6UL mkfg== 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=NO77RhHtUedYp4qFpiBBG4Tv5P6/osz6EYRha2NhNhk=; b=S9GtNyVw6ytbQJvrGb5cJjslytqDXK/8pqRYBNKMnrSBW52mTnZ9osZkgrmdg/DLOO V6uucmhuIsLpTKZKxoviN0HGRrB/tsGr53462KtOnO0LlH/eNn2eJPRK6grsosmtIIFx Qaq7LZ1DRutWnwR3L423vdQNUR6i7m67UrRHz5C2c/fzGuQ5p8+0y5EXYkrLPsO/QrPy 1Vp/7J0oBOnO20NlBuNkHvqglEYa0gGSFDJ/u/HsIHKQGhm/I35RX+rKhKbXMZ1IoVQ/ wa+syRde6NbrwGX8pRAlCqYSYzDsdWW4PgfHozj6uUwmcIbrJu3JcHPNWZuyomroZFQX VxrQ== X-Gm-Message-State: AOAM533cKjbBEgb7mGZZ4JUqcJq2QioBVg2D7yer8ZWT2Y4QESgVeGK2 zTRm4JwUMI2xbmfVpUdvrb8CQHSIRSU= X-Google-Smtp-Source: ABdhPJw3E3IXEEUyfgTlyT2GRgiR1Lg7VJY9blwvgZYSQs9bzUF3EMrsXiTPrUbCgULnwpAmTENwDg== X-Received: by 2002:a37:2dc5:: with SMTP id t188mr48503qkh.5.1609860772287; Tue, 05 Jan 2021 07:32: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 x28sm62386qtv.8.2021.01.05.07.32.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:32: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 105FWoll020928 for ; Tue, 5 Jan 2021 15:32:50 GMT Subject: [PATCH v1 36/42] NFSD: Update the NFSv2 SETACL argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:32:50 -0500 Message-ID: <160986077062.5532.1683255539753503273.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs2acl.c | 29 ++++++++++++----------------- fs/nfsd/xdr3.h | 2 +- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c index df2e145cfab0..123820ec79d3 100644 --- a/fs/nfsd/nfs2acl.c +++ b/fs/nfsd/nfs2acl.c @@ -201,28 +201,23 @@ static int nfsaclsvc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p) static int nfsaclsvc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_setaclargs *argp = rqstp->rq_argp; - struct kvec *head = rqstp->rq_arg.head; - unsigned int base; - int n; - p = nfs2svc_decode_fh(p, &argp->fh); - if (!p) + if (!svcxdr_decode_fhandle(xdr, &argp->fh)) + return 0; + if (xdr_stream_decode_u32(xdr, &argp->mask) < 0) + return 0; + if (argp->mask & ~NFS_ACL_MASK) return 0; - argp->mask = ntohl(*p++); - if (argp->mask & ~NFS_ACL_MASK || - !xdr_argsize_check(rqstp, p)) + if (!nfs_stream_decode_acl(xdr, NULL, (argp->mask & NFS_ACL) ? + &argp->acl_access : NULL)) + return 0; + if (!nfs_stream_decode_acl(xdr, NULL, (argp->mask & NFS_DFACL) ? + &argp->acl_default : NULL)) return 0; - base = (char *)p - (char *)head->iov_base; - n = nfsacl_decode(&rqstp->rq_arg, base, NULL, - (argp->mask & NFS_ACL) ? - &argp->acl_access : NULL); - if (n > 0) - n = nfsacl_decode(&rqstp->rq_arg, base + n, NULL, - (argp->mask & NFS_DFACL) ? - &argp->acl_default : NULL); - return (n > 0); + return 1; } static int nfsaclsvc_decode_fhandleargs(struct svc_rqst *rqstp, __be32 *p) diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h index 43db4206cd25..5afb3ce4f062 100644 --- a/fs/nfsd/xdr3.h +++ b/fs/nfsd/xdr3.h @@ -108,7 +108,7 @@ struct nfsd3_getaclargs { struct posix_acl; struct nfsd3_setaclargs { struct svc_fh fh; - int mask; + __u32 mask; struct posix_acl *acl_access; struct posix_acl *acl_default; }; From patchwork Tue Jan 5 15:32:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999359 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 03016C433DB for ; Tue, 5 Jan 2021 15:33:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CADA922AAB for ; Tue, 5 Jan 2021 15:33:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728088AbhAEPdj (ORCPT ); Tue, 5 Jan 2021 10:33:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725838AbhAEPdi (ORCPT ); Tue, 5 Jan 2021 10:33:38 -0500 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76DDEC061796 for ; Tue, 5 Jan 2021 07:32:58 -0800 (PST) Received: by mail-qk1-x730.google.com with SMTP id c7so26786301qke.1 for ; Tue, 05 Jan 2021 07:32: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=cxW0R+i2awO1nEIk/owL25UAcFkZS5u1R3IElRZBeEY=; b=H42cFXUi7DGaNNN3yPQdczQPwDuA2J6wvjMPPQ1O3u94NwytvJY8AfYaRujqR/VbbR l5LWMTjG7dHZsBQEQJsi3hwxrF2OemXy6YTgbfH65xCW0oI21qVqLU9+oCqTOs6eaSJt ld3rgXQgj4fHimsoSqa66hO1JqKDRS3tHyWZU4iyk/ySTUbAOmVzHxjkpHkPHWI8so+5 QOeXRZIuxArLGsYAz9UvhZJyQYavbVZ0HobqNDhISkYAS9VLxfxLx5110aztUOk2zKWQ wCH4j7/T/OqdkZbc6otbjDvzwMlmZMOGfK33J1dvmU7/piPqW7uHzxI9O8am67yuOHeB SDkQ== 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=cxW0R+i2awO1nEIk/owL25UAcFkZS5u1R3IElRZBeEY=; b=f/Wchu4CGPlATiFjAoJE/qnaGkjSGhTBktIf/mPDM1E8XfgesMoQdwzxO2lLIBUN4p QcS9ySTKmtljvnobR/knFnS02a1jnSIsKu0gRXWFjEd/X10rEpk/qyXfp1llVaOf6K5I plXfy17c4AspOiQDeoEcjanYe9ZUjNO+cl85XokI+Fd7+aa5JAG0OM7s5wocCux88HTc 2q1vhMlBRjLI+HidfrHnddTSp2s2RtviYLyxaH5iu7WGB+9zkqN+yo7IYx8V6jUsXxnO 4NZUNptmE5foscN3Bu1dqlAJ9rim5Ynpy0dKTuxYMmb1jxlvV4tEmxoTEKGySFnT/q/U eWpA== X-Gm-Message-State: AOAM5305TGhWv5AYC5iltTi8vn3NfZcrU82RRilh4M5arClcsUPez/Pf zRNggcsiUnYG4XGeaKwK288+v7ZJmZE= X-Google-Smtp-Source: ABdhPJxZgvy/2SqWKUSB5hLkZKu7onK10uqD21oTbF3cDswHH6/AmHw6l1J3oW7X+u271GYXxI3LCw== X-Received: by 2002:a05:620a:983:: with SMTP id x3mr27317qkx.231.1609860777465; Tue, 05 Jan 2021 07:32: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 m64sm145269qkb.90.2021.01.05.07.32.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:32:56 -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 105FWt5u020931 for ; Tue, 5 Jan 2021 15:32:55 GMT Subject: [PATCH v1 37/42] NFSD: Update the NFSv2 ACL GETATTR argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:32:55 -0500 Message-ID: <160986077591.5532.8940844074097535914.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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 Since the ACL GETATTR procedure is the same as the normal GETATTR procedure, simply re-use nfssvc_decode_fhandleargs. Signed-off-by: Chuck Lever --- fs/nfsd/nfs2acl.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c index 123820ec79d3..0274348f6679 100644 --- a/fs/nfsd/nfs2acl.c +++ b/fs/nfsd/nfs2acl.c @@ -220,16 +220,6 @@ static int nfsaclsvc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p) return 1; } -static int nfsaclsvc_decode_fhandleargs(struct svc_rqst *rqstp, __be32 *p) -{ - struct nfsd_fhandle *argp = rqstp->rq_argp; - - p = nfs2svc_decode_fh(p, &argp->fh); - if (!p) - return 0; - return xdr_argsize_check(rqstp, p); -} - static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p) { struct nfsd3_accessargs *argp = rqstp->rq_argp; @@ -392,7 +382,7 @@ static const struct svc_procedure nfsd_acl_procedures2[5] = { }, [ACLPROC2_GETATTR] = { .pc_func = nfsacld_proc_getattr, - .pc_decode = nfsaclsvc_decode_fhandleargs, + .pc_decode = nfssvc_decode_fhandleargs, .pc_encode = nfsaclsvc_encode_attrstatres, .pc_release = nfsaclsvc_release_attrstat, .pc_argsize = sizeof(struct nfsd_fhandle), From patchwork Tue Jan 5 15:33:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999353 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 1E5C9C433DB for ; Tue, 5 Jan 2021 15:33:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EE7EB22AAB for ; Tue, 5 Jan 2021 15:33:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728060AbhAEPdT (ORCPT ); Tue, 5 Jan 2021 10:33:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727946AbhAEPdS (ORCPT ); Tue, 5 Jan 2021 10:33:18 -0500 Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB537C06179A for ; Tue, 5 Jan 2021 07:33:03 -0800 (PST) Received: by mail-qk1-x731.google.com with SMTP id v126so26719051qkd.11 for ; Tue, 05 Jan 2021 07:33: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=KK5pH2d4/hYCVjeFLoyzSReEdz7WVJMLxtkHihiCNeY=; b=dHqbEkaksRDyrnk1LOw8cQHNpD8eR/LKM7frsi/5XlJ2VDyFtrVgaJlnEhQMq/cMRY fUr8kml1ehp0BWqpRFCue5GcW6651QBvkP8cmQiHZxiO40ixzH/2fv+S5sDiG30xw1u/ l6boQncYE/uJcE3M6/OGAR+xrG5S8i568TenGerxI9XYQ6RNZytVee4HSrXCRHtxAMmM Fa5TfwVRhs+KvVpGFtFTLfk6RP3lh5IY1k78TVZ514T8AVc2L3WAeLkEKR2c+gcFuoKP q0m6qPYVGHDzuxiWga+ZM5uZ2+XIHScLChe6ur1qKuydlKMhdZDR+2To5XRAjLgjcWuA m5Cg== 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=KK5pH2d4/hYCVjeFLoyzSReEdz7WVJMLxtkHihiCNeY=; b=KWvquvFjKUju/Qwf7ApKtCQ8nToE6/1/zeHtwkG4hvryDn6RN4+RCJI8oWS5x4oOjh FqT13uunTo2CboHjc7WEm4jFbaE59rjY9+xPlucmtMjeOlBGF8E17TROf4GxeED93O/H SURijrxHJN/9xL1vjh7NZrzBjXJ481Hir/GLokvCv7It+lPwYUo653QQunISkKpV9fXa m6xLTeCbOUqRTDq+qGC9s7WWRjcfU01o320Cr0Ge0PYjO5izsganNfEL+R0jP00efBbA Toc3uHP6v0X6FTyI8kRUb81NbJb1fYlz7xbcE/pthO4dZX3NJmF8k3qbiOW39luy9Sn2 mBQw== X-Gm-Message-State: AOAM533A2Ic4XoNWLCj+L9YfYxo060NJrmwZFf4rHXALntC3Tp6Fd9FX Bi1KJDz6qLB8jvXR4YaXdLTMICis45g= X-Google-Smtp-Source: ABdhPJz06VrfWmqm2TnQ0IAAlBSuLajal6JH40VbV2ST/mkdVP/x76oRJ53qIW7KvS1M+N0GvBvkfw== X-Received: by 2002:a37:9d14:: with SMTP id g20mr76612qke.260.1609860782707; Tue, 05 Jan 2021 07:33: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 n62sm131565qkn.125.2021.01.05.07.33.01 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:33: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 105FX0WC020934 for ; Tue, 5 Jan 2021 15:33:00 GMT Subject: [PATCH v1 38/42] NFSD: Update the NFSv2 ACL ACCESS argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:33:00 -0500 Message-ID: <160986078097.5532.12225653251775677522.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs2acl.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs2acl.c b/fs/nfsd/nfs2acl.c index 0274348f6679..7eeac5b81c20 100644 --- a/fs/nfsd/nfs2acl.c +++ b/fs/nfsd/nfs2acl.c @@ -222,14 +222,15 @@ static int nfsaclsvc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p) static int nfsaclsvc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p) { - struct nfsd3_accessargs *argp = rqstp->rq_argp; + struct xdr_stream *xdr = &rqstp->rq_arg_stream; + struct nfsd3_accessargs *args = rqstp->rq_argp; - p = nfs2svc_decode_fh(p, &argp->fh); - if (!p) + if (!svcxdr_decode_fhandle(xdr, &args->fh)) + return 0; + if (xdr_stream_decode_u32(xdr, &args->access) < 0) return 0; - argp->access = ntohl(*p++); - return xdr_argsize_check(rqstp, p); + return 1; } /* From patchwork Tue Jan 5 15:33:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999363 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 B72EAC433DB for ; Tue, 5 Jan 2021 15:33:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8FA8D22AAB for ; Tue, 5 Jan 2021 15:33:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728131AbhAEPdt (ORCPT ); Tue, 5 Jan 2021 10:33:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728118AbhAEPdt (ORCPT ); Tue, 5 Jan 2021 10:33:49 -0500 Received: from mail-qt1-x832.google.com (mail-qt1-x832.google.com [IPv6:2607:f8b0:4864:20::832]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3484CC061574 for ; Tue, 5 Jan 2021 07:33:09 -0800 (PST) Received: by mail-qt1-x832.google.com with SMTP id a6so21088291qtw.6 for ; Tue, 05 Jan 2021 07:33: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=HbmW3W/7YjSYXC44ifqVRuh7T/TD+bsWwBPo6LaheKI=; b=RX6bFiuI2MyCmmDq0xzpUk7tsSraoXfU0+/yKnHM0zX7Di5S93b41QYdOml6Xpq8ne 5MJPRgN2g7KK0Ilp9AMdIFfHpHtlruHjA/a4HFdqI4LbkcnM5PN60f3cOJdoK34hwvHA vHaYrCd3eDBxh+1BdFOuDvLho4DNNLGZ5nHB1RCL8AwohdNu160h7bi3LDPS1VPLOWz7 ZEhHumimfxpXKAkyfxQg0X4FPzFVghNbhYo/inzFZ7XHE1DVDRiPNqFnng8vdHEEg8oQ udiRniNTZUdwvY6y2N1I/rxQuHZayOYlaXbp6PACOYLB2fgUU9SEuc+KfgH/61qc5KLY lLKw== 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=HbmW3W/7YjSYXC44ifqVRuh7T/TD+bsWwBPo6LaheKI=; b=GUC6FaHN9XTpclIcVVhM2aP1djf9/nFsZ89CJWXmiz4BBeMNedB7muM+7a1nxCqLm9 gdCOIyApierN/2WdGMazuW8duGm9/kbyJijAKQrIQUn2TMmUh5AElx+/R2/dFtQ29Bmo VdR14qXcPIA1Ps1a8e3QCnq3OZ0cqi7pDj9n/gSHfyVw1l4RFXCIHfT9G3t8KHMK1qCw hMUpBxrLZS0iEr7lqBwlRkz7daEp6aKJGxf8yuOxlajYxR7FD124/g5lVH/cHZv/JXY/ cyWC7ZH+K71n2Rn1LQaKll3Dz2LZ9j9iGrAIzZgBXiEvpkeSYgkNVLffe8KKvI3CK9Yx GyGA== X-Gm-Message-State: AOAM531XjUlpKaT0IrMQoZ6R4JgDaTHqQE7+WB/J/KGiQgHdivZiHlTs wNa/gm3eNV6NmOH5lIko/vQAYSul468= X-Google-Smtp-Source: ABdhPJx68rZaoXqBqI6tBf7idF/dfaVYKdDEFaN/UiBvhy+naVXIwiL32whmQBJ+QEzQR+lgG1GAWA== X-Received: by 2002:aed:208f:: with SMTP id 15mr63327qtb.290.1609860788120; Tue, 05 Jan 2021 07:33: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 y10sm135101qkb.115.2021.01.05.07.33.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:33: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 105FX6xa020937 for ; Tue, 5 Jan 2021 15:33:06 GMT Subject: [PATCH v1 39/42] NFSD: Clean up after updating NFSv2 ACL decoders From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:33:06 -0500 Message-ID: <160986078631.5532.3261748463317557658.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfsxdr.c | 18 ------------------ fs/nfsd/xdr.h | 1 - 2 files changed, 19 deletions(-) diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index 5ab9fc14816c..5d79ef6a0c7f 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -26,18 +26,6 @@ static u32 nfs_ftypes[] = { * Basic NFSv2 data types (RFC 1094 Section 2.3) */ -static __be32 * -decode_fh(__be32 *p, struct svc_fh *fhp) -{ - fh_init(fhp, NFS_FHSIZE); - memcpy(&fhp->fh_handle.fh_base, p, NFS_FHSIZE); - fhp->fh_handle.fh_size = NFS_FHSIZE; - - /* FIXME: Look up export pointer here and verify - * Sun Secure RPC if requested */ - return p + (NFS_FHSIZE >> 2); -} - /** * svcxdr_decode_fhandle - Decode an NFSv2 file handle * @xdr: XDR stream positioned at an encoded NFSv2 FH @@ -62,12 +50,6 @@ svcxdr_decode_fhandle(struct xdr_stream *xdr, struct svc_fh *fhp) return true; } -/* Helper function for NFSv2 ACL code */ -__be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp) -{ - return decode_fh(p, fhp); -} - static __be32 * encode_fh(__be32 *p, struct svc_fh *fhp) { diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h index 035c99c7b384..3018b52b6d5e 100644 --- a/fs/nfsd/xdr.h +++ b/fs/nfsd/xdr.h @@ -164,7 +164,6 @@ void nfssvc_release_readres(struct svc_rqst *rqstp); /* Helper functions for NFSv2 ACL code */ __be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, struct kstat *stat); -__be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp); bool svcxdr_decode_fhandle(struct xdr_stream *xdr, struct svc_fh *fhp); #endif /* LINUX_NFSD_H */ From patchwork Tue Jan 5 15:33:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999365 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 E5263C433DB for ; Tue, 5 Jan 2021 15:33:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE6B722AAB for ; Tue, 5 Jan 2021 15:33:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728116AbhAEPdz (ORCPT ); Tue, 5 Jan 2021 10:33:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727887AbhAEPdy (ORCPT ); Tue, 5 Jan 2021 10:33:54 -0500 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B613C061798 for ; Tue, 5 Jan 2021 07:33:14 -0800 (PST) Received: by mail-qt1-x834.google.com with SMTP id u21so21035064qtw.11 for ; Tue, 05 Jan 2021 07:33: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=WO97NFUa0HrLEcjhuOBR1FhOyRH1V+18yT7ZttUzK1Q=; b=vQ1xOGaF12zsG/lf9qwwsr/bYnZ49ROeNAaiPjokXztLLy9MVsjxrKIVtNzVgAmsAX Y+7mSuZuDC+19WhLe+BsQ6Qji0lzODKuyRyySZDZCEqd5V0HTUd7ppn5UAshkwRH65Bf lP2HwvtcK2N5g+SJeSqhIxq2OLN4Wb2WIrisorEVZ+c+545yunbpmwerbwzpT9cQ6Kt6 RmFzSOR2wisncFeZ+4OeRKOf5l26fltOzwjDl1wGWulGd9VM1PTW6iqln8X7Z9/s+z40 Rz2gI3t6Q8ebT7+2APOmZCEGHKXFqImiI/MrVpntt/fRLpzLrmchs4ppVNE/Nzuj5Fv9 zpJQ== 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=WO97NFUa0HrLEcjhuOBR1FhOyRH1V+18yT7ZttUzK1Q=; b=UeUsEMjodI61V6aD1M6KNK8u/VnfcNVoHUzeBIPYMETwxkwlUpO0nbGBxJ/GQSy4kx lSzjxUIX9UExp9mAEdLPzdTsj/7plG8GTlxUnT8w3uzI1Q4hDFqPEINEjZJWzQa7sfpH /UAzaozYla04YctaKHOS+OYcCRu22a0fw8bNsfKE9+UhNojqb0QrMDBXZwOsdrMG2RFe ToJ99OZCBwcVMcxfUz4+D3xcGoNmgv5lI3WXF4FEc3A/POHUpVbXeE4JYutMRophRApw emP1FLT3rDJFNwTIEwLmrXu502jdLS9mu55WiHQtDfmEctHulCMrU7JetJEMbRahOIr/ i6Kw== X-Gm-Message-State: AOAM530ILDzdYqFXvmcLkB+uzKZWTrL/eXAN0OKDru9sCqIMfCb+A8pV nA6LCVBaJOQInUH7lFz6iEgx2MCawec= X-Google-Smtp-Source: ABdhPJwus3JWFanImEw3ArqXht0GoelY7bcZRZxh1BnRMdAi2CNg2jdt2NANgIJtfycMkWSE5mO36Q== X-Received: by 2002:a05:622a:14e:: with SMTP id v14mr63030qtw.298.1609860793368; Tue, 05 Jan 2021 07:33: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 q20sm156054qkj.49.2021.01.05.07.33.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:33: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 105FXBG9020940 for ; Tue, 5 Jan 2021 15:33:11 GMT Subject: [PATCH v1 40/42] NFSD: Update the NFSv3 GETACL argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:33:11 -0500 Message-ID: <160986079166.5532.16277092571503242339.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs3acl.c | 11 ++++++----- fs/nfsd/nfs3xdr.c | 11 ++++++++++- fs/nfsd/xdr3.h | 1 + 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c index 9e1a92fb9771..addb0d7d5500 100644 --- a/fs/nfsd/nfs3acl.c +++ b/fs/nfsd/nfs3acl.c @@ -124,19 +124,20 @@ static __be32 nfsd3_proc_setacl(struct svc_rqst *rqstp) /* * XDR decode functions */ + static int nfs3svc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p) { + struct xdr_stream *xdr = &rqstp->rq_arg_stream; struct nfsd3_getaclargs *args = rqstp->rq_argp; - p = nfs3svc_decode_fh(p, &args->fh); - if (!p) + if (!svcxdr_decode_nfs_fh3(xdr, &args->fh)) + return 0; + if (xdr_stream_decode_u32(xdr, &args->mask) < 0) return 0; - args->mask = ntohl(*p); p++; - return xdr_argsize_check(rqstp, p); + return 1; } - static int nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p) { struct nfsd3_setaclargs *args = rqstp->rq_argp; diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 5fb7e8a599c4..4be38599f331 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -53,7 +53,16 @@ svcxdr_decode_nfstime3(struct xdr_stream *xdr, struct timespec64 *timep) return true; } -static bool +/** + * svcxdr_decode_nfs_fh3 - Decode an NFSv3 file handle + * @xdr: XDR stream positioned at an undecoded NFSv3 FH + * @fhp: OUT: filled-in server file handle + * + * Return values: + * %false: The encoded file handle was not valid + * %true: @fhp has been initialized + */ +bool svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp) { __be32 *p; diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h index 5afb3ce4f062..7456aee74f3d 100644 --- a/fs/nfsd/xdr3.h +++ b/fs/nfsd/xdr3.h @@ -308,6 +308,7 @@ int nfs3svc_encode_entry_plus(void *, const char *name, __be32 *nfs3svc_encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp); __be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp); +bool svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp); #endif /* _LINUX_NFSD_XDR3_H */ From patchwork Tue Jan 5 15:33:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999357 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 5B718C433DB for ; Tue, 5 Jan 2021 15:33:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26C6B22AAB for ; Tue, 5 Jan 2021 15:33:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728083AbhAEPdf (ORCPT ); Tue, 5 Jan 2021 10:33:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725838AbhAEPdf (ORCPT ); Tue, 5 Jan 2021 10:33:35 -0500 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC1D7C06179A for ; Tue, 5 Jan 2021 07:33:19 -0800 (PST) Received: by mail-qk1-x735.google.com with SMTP id c7so26787483qke.1 for ; Tue, 05 Jan 2021 07:33: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=jGfOYjWuHpLahZsNYViQB8eHdJGH5wEjc/CCta9CnfY=; b=BilD+gQRTnjPxJuEbzmnzQ4wg6EaCTPNzWd9Y+/A9f4Rzs9WFBcy5tg2i3/T7L1ReL LFgOSuQAu0zmjAqQo+30dQxrOPrFwgXc9YeFNuNn76z8i6zpRT7/e851PxT1J8ajILTT b7fHNUpEI91WtwsmN4NOryBfIifJtO+O5ag1GNdjojunYo8WQq8+IPE3koWCrmRdbBBV MvXd80MJzm7t101ye4/YMzZ5bsIu6U9qlsQr8dXlmBzYN8xl2LCfWQ5aS3ZWLqQpXvYY fwMhe4CXkebZ+ROFLnEpVPGC9feC3LrM1B9c1UG69zhkIEaNpHgqHFwxBKYiB2eSLVY7 XIDw== 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=jGfOYjWuHpLahZsNYViQB8eHdJGH5wEjc/CCta9CnfY=; b=UfKig4MpM+acq/yxoH9s7ObZK2zB0JRbiN0GIKGE/1hpwcNY3DhOXWKIYyv4YGwVp6 TiTefS3aKSaTBAeIfhjpK5KREfCnW4NhJn4Gjysr2QyFqgW5AaJEd02ZNK4DowU9iJZZ VLwq74SjOTduJhk5HObc4fTy6N94SkGQO7JftQBvWe2sW7RcG6aRFAnVUWCKumuBttIC untMYO4pUee64mScOFd7sF7L2K2/6OanLDDxMzWmomGHojXIiz4HJcx/KFj6Pd3sAfF3 2kCWJfchN38NCHcWFKdJJvk/vAjKWVO5Qf/FGaBxSF1WJhKUK0QfAGaghxCSN00wy11W Q67Q== X-Gm-Message-State: AOAM532Rl25Cu2b9+lpxknQR6kVzYKpS/mhCZlYXco27c72n+g9BNDG/ grOdCiWcjSwuASbBOM0Adpx4qQaGlOo= X-Google-Smtp-Source: ABdhPJzrsB4JWc2ekNKzEDFXO51jnqgDzY186wqCKbhZ7bi630ux85KJTEkN/BzK4NAcFz5glgAjUQ== X-Received: by 2002:a37:a50c:: with SMTP id o12mr99510qke.98.1609860798755; Tue, 05 Jan 2021 07:33: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 a203sm172206qkb.31.2021.01.05.07.33.17 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:33: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 105FXHdQ020943 for ; Tue, 5 Jan 2021 15:33:17 GMT Subject: [PATCH v1 41/42] NFSD: Update the NFSv2 SETACL argument decoder to use struct xdr_stream From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:33:17 -0500 Message-ID: <160986079701.5532.7699961428525697515.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs3acl.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/fs/nfsd/nfs3acl.c b/fs/nfsd/nfs3acl.c index addb0d7d5500..a568b842e9eb 100644 --- a/fs/nfsd/nfs3acl.c +++ b/fs/nfsd/nfs3acl.c @@ -140,28 +140,23 @@ static int nfs3svc_decode_getaclargs(struct svc_rqst *rqstp, __be32 *p) static int nfs3svc_decode_setaclargs(struct svc_rqst *rqstp, __be32 *p) { - struct nfsd3_setaclargs *args = rqstp->rq_argp; - struct kvec *head = rqstp->rq_arg.head; - unsigned int base; - int n; + struct xdr_stream *xdr = &rqstp->rq_arg_stream; + struct nfsd3_setaclargs *argp = rqstp->rq_argp; - p = nfs3svc_decode_fh(p, &args->fh); - if (!p) + if (!svcxdr_decode_nfs_fh3(xdr, &argp->fh)) + return 0; + if (xdr_stream_decode_u32(xdr, &argp->mask) < 0) return 0; - args->mask = ntohl(*p++); - if (args->mask & ~NFS_ACL_MASK || - !xdr_argsize_check(rqstp, p)) + if (argp->mask & ~NFS_ACL_MASK) + return 0; + if (!nfs_stream_decode_acl(xdr, NULL, (argp->mask & NFS_ACL) ? + &argp->acl_access : NULL)) + return 0; + if (!nfs_stream_decode_acl(xdr, NULL, (argp->mask & NFS_DFACL) ? + &argp->acl_default : NULL)) return 0; - base = (char *)p - (char *)head->iov_base; - n = nfsacl_decode(&rqstp->rq_arg, base, NULL, - (args->mask & NFS_ACL) ? - &args->acl_access : NULL); - if (n > 0) - n = nfsacl_decode(&rqstp->rq_arg, base + n, NULL, - (args->mask & NFS_DFACL) ? - &args->acl_default : NULL); - return (n > 0); + return 1; } /* From patchwork Tue Jan 5 15:33:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever III X-Patchwork-Id: 11999361 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 A13F1C433DB for ; Tue, 5 Jan 2021 15:33:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DF2D22AAB for ; Tue, 5 Jan 2021 15:33:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728094AbhAEPdk (ORCPT ); Tue, 5 Jan 2021 10:33:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725838AbhAEPdk (ORCPT ); Tue, 5 Jan 2021 10:33:40 -0500 Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3156CC061793 for ; Tue, 5 Jan 2021 07:33:25 -0800 (PST) Received: by mail-qv1-xf35.google.com with SMTP id a4so14788462qvd.12 for ; Tue, 05 Jan 2021 07:33: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=jFDcHPeUzcjs9y3sBQWD0TZmsBPaSp+m+XjxZ668Eqk=; b=uwFYw0W0zqTTFZGW2D2h5uLr41fETfWJvTX3WKZIiv2LTTilKhoX7FSqA83uklLKsE 38TDCj6f6AoH802dOmR8koK5kf0iQ1Dh6I5zFZimRipyRChHu68zK2yuxv8WZXc/umx9 FC0mHx9rFrg6GPL8L5ihUVYXyFkVOEYCS6X6nCXlRbSZ4zuXwt4+PBhlHry+bjkpcwc2 DZh4oTheXGUz+l04HaxXO8DtQ7tCuE80YgZnZej7Myeo0pFE5l7IQIco7SbtkWB8RNz6 /n17xZjoLlNEGuUlZaN/irTbC1gfLRvl9kekdJgbIHJXuK1Mf5KyoXERdLeubzmCinc2 n5tw== 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=jFDcHPeUzcjs9y3sBQWD0TZmsBPaSp+m+XjxZ668Eqk=; b=NYwe0ZLKA08vxdSnqwfv3NmIcMi7dsMfUXhUkcYa9vqxiqFA4ymivMcoNHM1BnGdqO kHatVzSnIB3bTc6/cGH0W35yiPP1f8zJ1lZfzwhWQQok1kLhpqYJlDmYinXV/RIQ2Ir6 EstXLpfpS/UGYyBMN1yTWTd84rAOFpmLg25Z6k4sgvgthAjuY7UNjbCJNLfL+8kw9a5l COTgNFP//UlWGLaEygx2tqD9giZ+UedOuky8D0WuErwVRpjqSDtK3cOzNg1JPg+Zkzdc uBX6YfMon+WRJJqEr8xhP+WahbmDUGs1z4+3uLYZ9dyqM8/llkNVa24EQ2GRWqjqqL8+ mmbw== X-Gm-Message-State: AOAM531TXZsFVeq9VbLhyAOeLEXlCDjJ2z3p20LePHtrP2P6fqWD0gsS mJLUSDddSI3PmkJCuDhD1hUNEtazb/o= X-Google-Smtp-Source: ABdhPJx66FLOnr7hRBbNf5TbQ/LvagUsMUGY34egnsy8uHFykPYJV6N8OBG11RMjyHKeXK5fsZh5Dg== X-Received: by 2002:a0c:b797:: with SMTP id l23mr65169qve.42.1609860804128; Tue, 05 Jan 2021 07:33: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 u5sm135575qkb.120.2021.01.05.07.33.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jan 2021 07:33: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 105FXMxY020946 for ; Tue, 5 Jan 2021 15:33:22 GMT Subject: [PATCH v1 42/42] NFSD: Clean up after updating NFSv3 ACL decoders From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 05 Jan 2021 10:33:22 -0500 Message-ID: <160986080235.5532.572599583334345770.stgit@klimt.1015granger.net> In-Reply-To: <160986050640.5532.16498408936966394862.stgit@klimt.1015granger.net> References: <160986050640.5532.16498408936966394862.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/nfs3xdr.c | 20 -------------------- fs/nfsd/xdr3.h | 2 -- 2 files changed, 22 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 4be38599f331..023f310ba488 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -82,26 +82,6 @@ svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp) return true; } -static __be32 * -decode_fh(__be32 *p, struct svc_fh *fhp) -{ - unsigned int size; - fh_init(fhp, NFS3_FHSIZE); - size = ntohl(*p++); - if (size > NFS3_FHSIZE) - return NULL; - - memcpy(&fhp->fh_handle.fh_base, p, size); - fhp->fh_handle.fh_size = size; - return p + XDR_QUADLEN(size); -} - -/* Helper function for NFSv3 ACL code */ -__be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp) -{ - return decode_fh(p, fhp); -} - static __be32 * encode_fh(__be32 *p, struct svc_fh *fhp) { diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h index 7456aee74f3d..3e1578953f54 100644 --- a/fs/nfsd/xdr3.h +++ b/fs/nfsd/xdr3.h @@ -307,8 +307,6 @@ int nfs3svc_encode_entry_plus(void *, const char *name, /* Helper functions for NFSv3 ACL code */ __be32 *nfs3svc_encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp); -__be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp); bool svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp); - #endif /* _LINUX_NFSD_XDR3_H */