Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp5784248rwn; Mon, 12 Sep 2022 14:25:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR5wnUAuJ4FGoCsx7XB2v07/GmuG0z+KYN33fBIAa0TUtDWO5s+VOkzw0TnI4ay1KJwFQMK0 X-Received: by 2002:a17:90b:2250:b0:202:adf7:dd6d with SMTP id hk16-20020a17090b225000b00202adf7dd6dmr358959pjb.208.1663017929216; Mon, 12 Sep 2022 14:25:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663017929; cv=none; d=google.com; s=arc-20160816; b=VVDiyLuybNp3cf8nL3KgFtSzqnKaswA05QvjlpFXcCpMvxCdvA2HvsTjpDHh+z01j4 TFCSe4SPCKsC804ekx5rGyYlKr0dqvK35EhJtWc/PdZ0j2ty2VU+nk6kYFxQcOz5aA1z uSdzss2YClfRDl4u08lsWTPKdBbd8tasLCk3b3iLOCLqhAzqASoL+F1vERGcgx0ijLtT pqCjF6XsQyEfTX84pCrCOLNhlb4qDmUoWu4/PIaDgh+KMCUNr/IQfAdz0pmZyWaYRwYT aWy/q7gG0KxKw6lSulRoxmL98pHro1ILh3GecoOt9+TmOg9Q1QzUKh7usBxTYeGwt4PI KPtA== 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=nDrjCfhQtpO7Cg6n/d8K7Bgx8V9R0JWtBBxPdvPSO8s=; b=tILNgXD5iuDYlSCk/D1jroe2NE3Ows811p7fI1y0cehjnhX1NS2KrDtDctz6JHnobF g94ze85w09yeio+kQ/HyisJVvFOfdsPlaKi69ArwIRi+ZsKn8UIgs8EsrI9uxFXSKqmQ QoS3+Fk+0kKq3V2pAvH+Nwljn6Q6rtwJfHLqHtrnCaapI9G7MQB+Jgs9MzkxVZgy+R71 VPbPshIlk0+o45x5X8X7kIsA+sLmnrVLrKcWUW5F1cg+lvKGFhE5cswvRL71c4Vbw8Jg KrrVBy0ncZOh3e5n5f8wvkejgyErOqkx2SLx6wDgGl52J0h5CVxDXZCK8rlrOrN2DmNg kgug== 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 m13-20020a170902f64d00b00172d54cccddsi8605185plg.428.2022.09.12.14.25.16; Mon, 12 Sep 2022 14:25:29 -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 S229696AbiILVXH (ORCPT + 99 others); Mon, 12 Sep 2022 17:23:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229698AbiILVXG (ORCPT ); Mon, 12 Sep 2022 17:23:06 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54CAF4055B for ; Mon, 12 Sep 2022 14:23:05 -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 16B08B80C9E for ; Mon, 12 Sep 2022 21:23:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBA06C433D7 for ; Mon, 12 Sep 2022 21:23:02 +0000 (UTC) Subject: [PATCH v1 06/12] NFSD: Use xdr_inline_decode() to decode NFSv3 symlinks From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 12 Sep 2022 17:23:02 -0400 Message-ID: <166301778198.89884.1973943063854884679.stgit@oracle-102.nfsv4.dev> In-Reply-To: <166301759113.89884.7985359396842428444.stgit@oracle-102.nfsv4.dev> References: <166301759113.89884.7985359396842428444.stgit@oracle-102.nfsv4.dev> User-Agent: StGit/1.5 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. Reviewed-by: Jeff Layton 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