Skip to content

Commit c953093

Browse files
pvts-matPlaidCat
authored andcommitted
NFSD: Protect against send buffer overflow in NFSv3 READ
jira VULN-155649 cve CVE-2022-50410 commit-author Chuck Lever <chuck.lever@oracle.com> commit fa6be9c upstream-diff LTS 8.6 version of the function `nfsd3_proc_read()' misses changes from 0cb4d23, cc9bcda and be63bd2. Preserved the logic of what is assigned to `resp->count' despite the missing changes. 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> (cherry picked from commit fa6be9c) Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>
1 parent 57d3d17 commit c953093

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

fs/nfsd/nfs3proc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ nfsd3_proc_read(struct svc_rqst *rqstp)
146146
struct nfsd3_readres *resp = rqstp->rq_resp;
147147
u32 max_blocksize = svc_max_payload(rqstp);
148148
unsigned long cnt = min(argp->count, max_blocksize);
149+
cnt = min(cnt, (unsigned long)rqstp->rq_res.buflen);
149150

150151
dprintk("nfsd: READ(3) %s %lu bytes at %Lu\n",
151152
SVCFH_fmt(&argp->fh),

0 commit comments

Comments
 (0)