Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2469296rwe; Sun, 28 Aug 2022 12:22:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR7kJ6bA6GpS4E45f0m4vzhijPebZX/5jhAIiiGoxm9I6VrDKmAHi2QZ2v/s3XTWU8iXrOS4 X-Received: by 2002:a17:90b:4f90:b0:1fd:7ced:894f with SMTP id qe16-20020a17090b4f9000b001fd7ced894fmr10206498pjb.20.1661714547041; Sun, 28 Aug 2022 12:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661714547; cv=none; d=google.com; s=arc-20160816; b=QpiVyvS9rY+k6hjQfOKFgbyRemjVZD+gzzLQQN/SlpmMuncAweE//sW6ehGo5Sjw7l 4Rzu3XqvmaLA+u+r3Dw4RD296XAd4VDOJUoJwQcGyBj6hE3IeZbQ3Qay0NKMEENAeDSd vBS19Lvt3vZLCS/eWj2QQl0Ex+nxrGbjEh7/XakkpuOkce8Q7iY9AL2TRtv+wb5MYfs1 /aWFyEUOyZk1b5uIvDZ2bh1TGs81s9O8DMVYmeTkGESgJFH5Q7T1e775vv+nZYE8hfYI KZZERe0voQUmGk28bIASbM9gm5bTf8TMQLWizzaDSBl6Pf9HxGrlObKBp+M6JADg3v3Q 4K9w== 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=Od++dBpRDKcbc5g+3TuR7aQuNQ4eKs8cTRlrpxc2M5s=; b=RYYVm7A6XrCdVq5xtGi5ugYcuYYR764ns51sUspOljM8fj1fumt4b5OynVOEND00mB YtNb8l4lm8y/A3lvnbYrb7dqszQO7D/Lfi+3bdI0jH7E96Aq6QsJjrVspbLfFgQBRatX T+JT9NkZzuaBFNnwLs1cr6PfWoqn+vTscFYRO46ewRUNYEeYmDSC/htOG+58syGEy/h4 GNWnGnuWClwlTnkQjbG1h4GHOoCrY7DiErTLViCy5ReGpbyiKEiETPPJQokn7W4fT7UQ qUk3jG9eB57VN/+FgINDZOKBHmn74frMlgU/wpajSZTGiA11n9EgTkqH4YkqhP/K6sSb yj2g== 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 l186-20020a6391c3000000b0042b74cac350si7280355pge.156.2022.08.28.12.22.14; Sun, 28 Aug 2022 12:22:27 -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 S229729AbiH1Sud (ORCPT + 99 others); Sun, 28 Aug 2022 14:50:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229547AbiH1Sud (ORCPT ); Sun, 28 Aug 2022 14:50:33 -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 D9F78B7E7 for ; Sun, 28 Aug 2022 11:50:31 -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 9BF56B80B87 for ; Sun, 28 Aug 2022 18:50:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42D09C433D6; Sun, 28 Aug 2022 18:50:29 +0000 (UTC) Subject: [PATCH v2 2/7] SUNRPC: Fix svcxdr_init_encode's buflen calculation From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Sun, 28 Aug 2022 14:50:28 -0400 Message-ID: <166171262829.21449.4256057697517661592.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 Commit 2825a7f90753 ("nfsd4: allow encoding across page boundaries") added an explicit computation of the remaining length in the rq_res XDR buffer. The computation appears to suffer from an "off-by-one" bug. Because buflen is too large by one page, XDR encoding can run off the end of the send buffer by eventually trying to use the struct page address in rq_page_end, which always contains NULL. Fixes: bddfdbcddbe2 ("NFSD: Extract the svcxdr_init_encode() helper") Signed-off-by: Chuck Lever --- include/linux/sunrpc/svc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 5a830b66f059..0ca8a8ffb47e 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -587,7 +587,7 @@ static inline void svcxdr_init_encode(struct svc_rqst *rqstp) xdr->end = resv->iov_base + PAGE_SIZE - rqstp->rq_auth_slack; buf->len = resv->iov_len; xdr->page_ptr = buf->pages - 1; - buf->buflen = PAGE_SIZE * (1 + rqstp->rq_page_end - buf->pages); + buf->buflen = PAGE_SIZE * (rqstp->rq_page_end - buf->pages); buf->buflen -= rqstp->rq_auth_slack; xdr->rqst = NULL; }