From patchwork Wed Jun 26 18:27:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13713273 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96E4F190670; Wed, 26 Jun 2024 18:28:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719426488; cv=none; b=p9oZz30H0GrLsP7VUU0itZQdxAp1JKKPFPvfpj7/dWF2lBqL5A+EC4FMibaJ7Lw3ITbM2jY+mLOCILrW579JQ/MszeRgHlRRmO+jpzJhVVDiOmB9blMK5biaFxMU6d8wFwDWHD9mT+5dBMyTcoviRXj6smk67tGsL4Mki5mHSAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719426488; c=relaxed/simple; bh=75dKJKIcfqVCCpuSxkTGFgX7Iozwogg8rV3YwmWJHAc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZyyJLuXLZstCW00fM4dRu5QjDRVzZmvwg2eQ/U9rfbyWhU4loEZfBW4MpL/rMhCrPrKNkoBMtcgiCGa2hfuWvnLspxmts97L5Nm+BVMpyFN5iKUCGXu89xtB/LxQ6MdNfBslDUS7EgbZJMQo/NaEqrqcpWGiE40uYUk9tqICI+I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b0+wl2me; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="b0+wl2me" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD1D7C4AF07; Wed, 26 Jun 2024 18:28:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719426488; bh=75dKJKIcfqVCCpuSxkTGFgX7Iozwogg8rV3YwmWJHAc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b0+wl2meRTcMRhseuzuzrZBhICDE271fPETk6UD3RWLETmFNK9kepoOh//vL/F5No BTHy9v3ub+Mno67cJDIw6oIWRbnHlZsXbLciPBJq735d/4iO5zYSF0mj0AH3lRr1k/ x62dhnkf84GeFEj2njwbnTs6broIBVWdWKT+9NsPKGdZdMLtECG/+0yaGwwJOf7siy igJUO00MSf38kblDJoigrjpCg9ov9Tfjk/oTlWlqbNiiAcfrokQeCj+57Lk1g1UoZ9 Zgvnt2WIGj0e3Fy/wD3Cpp1YMJPa6OUmJ19Jhljhi3fyIK1e1arblcBeXjj2I8R9hq t6v6DlgX6QdnA== From: cel@kernel.org To: Greg Kroah-Hartman , Sasha Levin Cc: , , Chuck Lever , Jeff Layton Subject: [PATCH 5.10 4/5] SUNRPC: Fix svcxdr_init_encode's buflen calculation Date: Wed, 26 Jun 2024 14:27:44 -0400 Message-ID: <20240626182745.288665-5-cel@kernel.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240626182745.288665-1-cel@kernel.org> References: <20240626182745.288665-1-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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 f0e09427070c..00303c636a89 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -579,7 +579,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; }