From patchwork Sat Oct 22 07:21:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7233 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1090733wrr; Sat, 22 Oct 2022 00:48:15 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7a/j1Th9N2XWyuXdy1A7FiDOEth8y3LH9Mzqoez6u6eKJeTFasdCRNpdymynTBvTw1ggIe X-Received: by 2002:a63:186:0:b0:442:ee11:48a5 with SMTP id 128-20020a630186000000b00442ee1148a5mr19377732pgb.284.1666424895110; Sat, 22 Oct 2022 00:48:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424895; cv=none; d=google.com; s=arc-20160816; b=Fj7jnPvB7RCSZtH3dU/IZ0Em0o9WSH7C3qX5zIspp7EkMrIBVXijOmmyq9Ff5Jsd4J VEZcq8WWIPnAauIJrleili2TN6bd1UW5NtsXaARIlQoGS6gXXZ8arN/0D5hWJ9StHzDp otKi92BrAlY9ogUtnEYgCpwtl2VKnAhVt17l5/g3RQo/s4LJGH4ePVZ9dtmH42v7Hspa VlTxiFOzYPPyj1Mi1y/ZsenhZRjfH43gOme89GTm7gcKKKB43h9RKI4DnnOe1PxjDpf5 secbki5wN7+fpwY/aOfn3T6yIRg45EuD53OaW5OVti8f997MblOX2GP6FMaG+BHrhCJL LZvQ== 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:subject:cc:to :from:dkim-signature; bh=980rDNROEUjrgeyQd3XrtA9QDEC+IRMBBoyMetLnbVY=; b=JsbrsEd3isn9LC1X2Ce/mhn6IaCvRJ14XSooPIb6Yg0dpwj+5KgXovL3YP1bIHWucI IZPY2E9Fd/tip488845+lTbOlWgAp33WNtiw6SMYBJaCQeMsdt/z2IBxYyS8+zdm+g5t LxkRlBWePU8tvcQXQS2+8W2OlDbN4RiRwREBx1oDumrxD4T94G993oUG/OgkO57MgW4I bFQpL9M+9TBdX4L3KUhavOfKSC4ostR1Wu2n6KwxxISmu42wwI5FFFZqP/HKS+66f+F0 3LVjxu9F0lsN3bE0Hmxv2QbUC8j5GOn8Q8s0JRP9tRXOBurUzbTJ8hbyQZ0c08QkLOn/ 77vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mcKOlYUY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s9-20020a170902b18900b0017f8d9b7e5fsi26038065plr.133.2022.10.22.00.48.02; Sat, 22 Oct 2022 00:48:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mcKOlYUY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231529AbiJVHri (ORCPT + 99 others); Sat, 22 Oct 2022 03:47:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231144AbiJVHq7 (ORCPT ); Sat, 22 Oct 2022 03:46:59 -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 266091EB54F; Sat, 22 Oct 2022 00:44:09 -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 97ED8B82E1D; Sat, 22 Oct 2022 07:43:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DDF5AC433D6; Sat, 22 Oct 2022 07:43:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424592; bh=qVYDYelSXhkHfR0AgcNhAsoBtqPipV6eiUkZlAcvI5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mcKOlYUY9YfFcxA+xpJEeazfq65BeEKlTNFPGt5/TlUPQeEtH1DB51L5U+rxaiScH 42tSIPgknmE9uNVlwv3q7AHlikGm/eXzc50qR2eK0xHP5WNQvMMBuEfXmd7pomPRee yYHG+SxejkSTcVjoKTCPzvbSAY3jJDzyu/wCcBak= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeff Layton , Chuck Lever , Sasha Levin Subject: [PATCH 5.19 196/717] SUNRPC: Fix svcxdr_init_encodes buflen calculation Date: Sat, 22 Oct 2022 09:21:15 +0200 Message-Id: <20221022072450.180958596@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747373150690868077?= X-GMAIL-MSGID: =?utf-8?q?1747373150690868077?= From: Chuck Lever [ Upstream commit 1242a87da0d8cd2a428e96ca68e7ea899b0f4624 ] 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") Reviewed-by: Jeff Layton Signed-off-by: Chuck Lever Signed-off-by: Sasha Levin --- 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; }