
From: Chuck Lever <chuck.lever@oracle.com> mainline inclusion from mainline-v6.1-rc1 commit 401bc1f90874280a80b93f23be33a0e7e2d1f912 category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/ICYQPE CVE: CVE-2022-50410 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i... -------------------------------- Since before the git era, NFSD has conserved the number of pages held by each nfsd thread by combining the RPC receive and send buffers into a single array of pages. This works because there are no cases where an operation needs a large RPC Call message and a large RPC Reply at the same time. Once an RPC Call has been received, svc_process() updates svc_rqst::rq_res to describe the part of rq_pages that can be used for constructing the Reply. This means that the send buffer (rq_res) shrinks when the received RPC record containing the RPC Call is large. A client can force this shrinkage on TCP by sending a correctly- formed RPC Call header contained in an RPC record that is excessively large. The full maximum payload size cannot be constructed in that case. Cc: <stable@vger.kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Conflicts: fs/nfsd/nfsproc.c [Commit 8c293ef993c8 ("NFSD: Update the NFSv2 READ argument decoder to use struct xdr_stream") change the way to limit argp->count.] Signed-off-by: Li Lingfeng <lilingfeng3@huawei.com> --- fs/nfsd/nfsproc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/nfsd/nfsproc.c b/fs/nfsd/nfsproc.c index 7b6a5f78f556..e375ede4f887 100644 --- a/fs/nfsd/nfsproc.c +++ b/fs/nfsd/nfsproc.c @@ -189,6 +189,7 @@ nfsd_proc_read(struct svc_rqst *rqstp) argp->count); argp->count = NFSSVC_MAXBLKSIZE_V2; } + argp->count = min_t(u32, argp->count, rqstp->rq_res.buflen); svc_reserve_auth(rqstp, (19<<2) + argp->count + 4); resp->count = argp->count; -- 2.46.1