From nobody Fri Dec 19 16:02:04 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 A4B22C433FE for ; Sat, 22 Oct 2022 07:47:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231567AbiJVHrj (ORCPT ); Sat, 22 Oct 2022 03:47:39 -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 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 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 =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