From nobody Fri Dec 19 18:53:17 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB7E8FA3752 for ; Mon, 24 Oct 2022 16:55:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235891AbiJXQzS (ORCPT ); Mon, 24 Oct 2022 12:55:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235647AbiJXQuB (ORCPT ); Mon, 24 Oct 2022 12:50:01 -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 7951333372; Mon, 24 Oct 2022 08:33:23 -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 0620CB818F0; Mon, 24 Oct 2022 12:39:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B14DC433C1; Mon, 24 Oct 2022 12:39:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615169; bh=QOSvvtDm2rCO1YO8iMoqViJjCHPUZLII/l1hg2+iGOI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ieP6Z9ubbl6jJ4rfWR6LaCX9qyou5WGkQ1Mpl9NkLenb7Byr4AC1+qLDS9pHY2ca0 zXd4yUfnsJiRUvgC+IpmbE8pahHbEm69aqILMv9CfevJz9kXFHSbBraqHM8MPpnEf0 J3hTj7UqwDd6zIB87rv5YIvXi3AaUsr5IpQ9n/D0= 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.15 148/530] SUNRPC: Fix svcxdr_init_encodes buflen calculation Date: Mon, 24 Oct 2022 13:28:12 +0200 Message-Id: <20221024113051.767139056@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 6be55d0e73fd..045f34add206 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -609,7 +609,7 @@ static inline void svcxdr_init_encode(struct svc_rqst *= rqstp) xdr->end =3D resv->iov_base + PAGE_SIZE - rqstp->rq_auth_slack; buf->len =3D resv->iov_len; xdr->page_ptr =3D buf->pages - 1; - buf->buflen =3D PAGE_SIZE * (1 + rqstp->rq_page_end - buf->pages); + buf->buflen =3D PAGE_SIZE * (rqstp->rq_page_end - buf->pages); buf->buflen -=3D rqstp->rq_auth_slack; xdr->rqst =3D NULL; } --=20 2.35.1