Skip to content

Commit 401bc1f

Browse files
committed
NFSD: Protect against send buffer overflow in NFSv2 READ
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>
1 parent 640f87c commit 401bc1f

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

fs/nfsd/nfsproc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ nfsd_proc_read(struct svc_rqst *rqstp)
185185
argp->count, argp->offset);
186186

187187
argp->count = min_t(u32, argp->count, NFSSVC_MAXBLKSIZE_V2);
188+
argp->count = min_t(u32, argp->count, rqstp->rq_res.buflen);
188189

189190
v = 0;
190191
len = argp->count;

0 commit comments

Comments
 (0)