Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3993735rwa; Tue, 23 Aug 2022 14:07:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Zdr/FuM6hBhHkI/jPXvTMNfbvNUrPgi6drEIuDzHoc6joOTwaZUyNzldHe2Bz7ZEWQhDb X-Received: by 2002:a05:6402:4407:b0:447:1026:7537 with SMTP id y7-20020a056402440700b0044710267537mr4773541eda.312.1661288830761; Tue, 23 Aug 2022 14:07:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661288830; cv=none; d=google.com; s=arc-20160816; b=hOszB8DHSKfsEGUKc8P33at9YmKSa4exvPRKPryoKTrn+ukXnbai+RTGLrIi2EVFoj IWCaK9XkEa+n3xpz91OxSPsmjSKqdFYCbtouS8n75sGy7SemOUo2KJ56+t+qWJ86eUdc 2xqvyzrR8MFAhE4TXABUVVkr7bICJnagfYpFXz7mJkxUZ7n5ODTsCNwK1S+/6B513i80 P5evtqSBcmXWGnOqJPUwwlUTeUMf3olXacrObpn3kolzsIiAAcS4lPGcCEy1Ozk8YJn3 XECgcDpVo/8CjVP0OP7m/V7PXYYtGfyN/ihbrftZCGcRycACPqDZ73vKxzCYCMoG9vIB t6+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject; bh=6OvWLuMzzGEJnqYF/nINwYuxf110fRCBMBPQ3P/CH0Y=; b=DplzzZA/goJQiZw+5pVhCgSu9nR1ZUE7Ksl64M/eZ7CgNH8G8RePn5L0n+kTi/fzS3 nHiyrRTCkO3MIPV062998fN1ECPuYosddxqFZ8sUyyWUsVlj84rEnKuCgVvGOL996rpS lieDnwuC5p3eLtHdxKKRGXTvM8Q9z2MWsaM/5UahrPl9s9J8oaqywRU5wdw1crTGznqZ eUXBQJ+baJ8YDZdbjfYsIE6EGhUx8jUGRqxZfd0LtV/QNkW66TElkwB6ODmgzxjIVmpY sH5+Mch9xmVrBTRsk2zm3ICQUbq6sKD/T9twvbaszHgA45zFpn0dZuKYJiRVws3QPgqm O1OA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a056402270d00b004461b801769si3118845edd.390.2022.08.23.14.06.45; Tue, 23 Aug 2022 14:07:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbiHWVFb (ORCPT + 99 others); Tue, 23 Aug 2022 17:05:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230425AbiHWVAT (ORCPT ); Tue, 23 Aug 2022 17:00:19 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FA5D786D7 for ; Tue, 23 Aug 2022 14:00:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 7FE61CE1FE7 for ; Tue, 23 Aug 2022 21:00:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D60EEC433D6; Tue, 23 Aug 2022 21:00:14 +0000 (UTC) Subject: [PATCH v1 2/7] NFSD: Use xdr_inline_decode() to decode NFSv3 symlinks From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Tue, 23 Aug 2022 17:00:13 -0400 Message-ID: <166128841388.2788.9568755346644827020.stgit@manet.1015granger.net> In-Reply-To: <166128840714.2788.7887913547062461761.stgit@manet.1015granger.net> References: <166128840714.2788.7887913547062461761.stgit@manet.1015granger.net> User-Agent: StGit/1.5.dev2+g9ce680a5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Replace the check for buffer over/underflow with a helper that is commonly used for this purpose. The helper also sets xdr->nwords correctly after successfully linearizing the symlink argument into the stream's scratch buffer. Signed-off-by: Chuck Lever --- fs/nfsd/nfs3xdr.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c index 0293b8d65f10..71e32cf28885 100644 --- a/fs/nfsd/nfs3xdr.c +++ b/fs/nfsd/nfs3xdr.c @@ -616,8 +616,6 @@ nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr) { struct nfsd3_symlinkargs *args = rqstp->rq_argp; struct kvec *head = rqstp->rq_arg.head; - struct kvec *tail = rqstp->rq_arg.tail; - size_t remaining; if (!svcxdr_decode_diropargs3(xdr, &args->ffh, &args->fname, &args->flen)) return false; @@ -626,16 +624,10 @@ nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr) if (xdr_stream_decode_u32(xdr, &args->tlen) < 0) return false; - /* 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 false; - - args->first.iov_base = xdr->p; + /* symlink_data */ args->first.iov_len = head->iov_len - xdr_stream_pos(xdr); - - return true; + args->first.iov_base = xdr_inline_decode(xdr, args->tlen); + return args->first.iov_base != NULL; } bool