From patchwork Wed Oct 19 08:25:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp214269wrs; Wed, 19 Oct 2022 02:12:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6bKdehW2xtNMQPc/SfUFuQnW3P1QAT6NzKoa6ozNdAn+3xQ5P+9dIwJ+bAy9qZ5IV5bL5Y X-Received: by 2002:a05:6402:14ce:b0:45c:2c81:e144 with SMTP id f14-20020a05640214ce00b0045c2c81e144mr6399076edx.90.1666170741224; Wed, 19 Oct 2022 02:12:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170741; cv=none; d=google.com; s=arc-20160816; b=00ZJUKvG0Emin+7rzIYInZsdAcGQ8nu+XcTiN51fTewWxLIXUVgHWTsSW8R09LyG8H euYyWRa9fPuIT5YBf2SGWDHWZI71x9YA2L4aPEYuIPKFYzN9nKwSqtoE2rcdv/wWb0lT Y/8agE6Lj7JyUx70rWkjpT/HXZW2Me30WF5I62tpI2KWZfTGH99svAOARENlxOL8A84I QlrONigxZEzZuUXRNAe8ggFB/y8rVixpQB1MC1N39OTI3bNNypGcL/TUVG8sF5TbvxND ooFPqdQJ874GFwEOEEn/HlybQ3PMSxJd8W2XmBsLRlXwm47dT2CsUd90IeG9yNdsNlmx 5HEA== 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=L2bxhRGzYmXwuZrjocpAZkAKizQ04PhJzM0l24IHJpe/caVoTI9ORS885tpHEcKRhc wF+dm8d8PW172MBxz1qJOFrDgqWP2F3FgT5mtrbZryJ2pRuCS0aw6Tcw61ChdOJ8ZcsX g9VX1hPvwSh35hZxwcNSQPTWEEAJ6TzF9yp0mQQyz6BPAY8Uu19MPExvrC+dL/0lM2JX nWwQwQd7XHXdR9UOiGkQ5A2MqmEL0jld/owIuIjUQBBQDWcTLSBHQ5bArYdTjOYUggE9 lhVw5EQFKoAvVpkD9qcyKqsCIewCHAY6r8ZAh2Y5FuxCVybF9YaXwb2anoHLuLJZ1E4d ePYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HHx2YRrh; 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 v10-20020a056402348a00b0045901aa2468si16282118edc.333.2022.10.19.02.11.56; Wed, 19 Oct 2022 02:12:21 -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=HHx2YRrh; 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 S232670AbiJSJIb (ORCPT + 99 others); Wed, 19 Oct 2022 05:08:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232367AbiJSJFt (ORCPT ); Wed, 19 Oct 2022 05:05:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CD56559D; Wed, 19 Oct 2022 01:59: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 dfw.source.kernel.org (Postfix) with ESMTPS id F3ACF61830; Wed, 19 Oct 2022 08:48:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1338BC433D7; Wed, 19 Oct 2022 08:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169294; bh=qVYDYelSXhkHfR0AgcNhAsoBtqPipV6eiUkZlAcvI5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HHx2YRrhaJ0sA/pz5Myz4yV257qDFjZ8K23rnDucjk6zIogdyouVF1406vFfJzh9L 8nJVdwMskHQ682ymeAj+luTBXmoUi0tH0YRk2T5C7YkRmATrCD54JhjIhdaZ8/nGAs UOj33h7gZ/ZbdS+j7++MwOLF+UK1rvK9T3JQ2ypo= 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 6.0 223/862] SUNRPC: Fix svcxdr_init_encodes buflen calculation Date: Wed, 19 Oct 2022 10:25:10 +0200 Message-Id: <20221019083259.890877538@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747106650769036124?= X-GMAIL-MSGID: =?utf-8?q?1747106650769036124?= 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; }