Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2466771rwe; Sun, 28 Aug 2022 12:17:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR7hXkW0enP2Vgsw16GTQGbbNFu9UeL58W5yVY9JqCsZnA/13HYsdt/z8/OH5dvIsO1TXhCX X-Received: by 2002:a17:906:2245:b0:715:7c81:e39d with SMTP id 5-20020a170906224500b007157c81e39dmr11856877ejr.262.1661714251238; Sun, 28 Aug 2022 12:17:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661714251; cv=none; d=google.com; s=arc-20160816; b=hY15IsPC/x8j4BZ4iwNdSf+6pWY/zeOv9GlqwCHnBY5VUQhYZIgoL4N9eRU4JQ7o0K MB458ET0Vz3JLSOn3fRaiHvaxTyy27lmS5bbhWZaa1dUE52Tad6eHKeg8kaGx5hZSWE+ 4Zv2lverxThnS0uPZYw/Y01I62M9FZsiEzJutHBfGSe3HWnQ69MQ1fVNuRaxk2pO3AR5 m4Up11rmaaIL4VKALVyw7TsofFCnRCr2j05r693aaX4XxP/Uq0SRsPK1xy/DQgC9opDi SlrZCBWuawvf/LRUaz7PX96cvcnR/PCqbSBlVLCbSYdRDZpKtAYqECAtJyLDWpAPD96B +uhg== 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=FSnzJenjk+gIz3Fit8DsbyMiZVMWF95LjHj0CG4ugHuXYSCMryNqpSRffbrCJqEIFY pONuSEO+AtLH7AceqsTQ3pUBQEmjtN+G9a9ZYV0C1ZD2eWp4Xw9ZlzGtKOshmX3TN8F/ vmjSLX+XkAOxAC6PMZxdqJIa+RofrJDi8P3fCJEo/uBYV1vxtmPvulmm2k5goSnF5Ymj eOGq/sCk8hvzMaKdapKblYkIdwWhNwM/0aC2s+Z6YxgjRCYb9vYc9sYAnTh1i6Wuyrpq EYwpGm44Ark9ufcj1YBhSCFo1VJY43t48icmvqx15akU+O1bBfPuvJj7hw7Kmrk4PnMx MirQ== 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 l8-20020a056402254800b0043a9bb390d3si6315380edb.278.2022.08.28.12.17.05; Sun, 28 Aug 2022 12:17:31 -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 S230002AbiH1Suq (ORCPT + 99 others); Sun, 28 Aug 2022 14:50:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbiH1Sup (ORCPT ); Sun, 28 Aug 2022 14:50:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6CBAB7EB for ; Sun, 28 Aug 2022 11:50:44 -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 ams.source.kernel.org (Postfix) with ESMTPS id 905EFB80B95 for ; Sun, 28 Aug 2022 18:50:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16A5CC433C1; Sun, 28 Aug 2022 18:50:42 +0000 (UTC) Subject: [PATCH v2 4/7] NFSD: Use xdr_inline_decode() to decode NFSv3 symlinks From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Sun, 28 Aug 2022 14:50:41 -0400 Message-ID: <166171264105.21449.17586756015319208200.stgit@manet.1015granger.net> In-Reply-To: <166171174172.21449.5036120183381273656.stgit@manet.1015granger.net> References: <166171174172.21449.5036120183381273656.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