aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJeff Layton <jlayton@redhat.com>2012-05-04 11:44:12 -0400
committerJ. Bruce Fields <bfields@redhat.com>2012-05-31 20:29:41 -0400
commit91c427ac3a61ccabae0fdef53563edf40394b6c9 (patch)
tree66f5aaf373ebef288ed561def0f188f1ac5700d5 /net
parent786185b5f8abefa6a8a16695bb4a59c164d5a071 (diff)
sunrpc: do array overrun check in svc_recv before allocating pages
There's little point in waiting until after we allocate all of the pages to see if we're going to overrun the array. In the event that this calculation is really off we could end up scribbling over a bunch of memory and make it tougher to debug. Signed-off-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/svc_xprt.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 4bda09d7e1a4..8195c6acba12 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -601,6 +601,7 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
601 601
602 /* now allocate needed pages. If we get a failure, sleep briefly */ 602 /* now allocate needed pages. If we get a failure, sleep briefly */
603 pages = (serv->sv_max_mesg + PAGE_SIZE) / PAGE_SIZE; 603 pages = (serv->sv_max_mesg + PAGE_SIZE) / PAGE_SIZE;
604 BUG_ON(pages >= RPCSVC_MAXPAGES);
604 for (i = 0; i < pages ; i++) 605 for (i = 0; i < pages ; i++)
605 while (rqstp->rq_pages[i] == NULL) { 606 while (rqstp->rq_pages[i] == NULL) {
606 struct page *p = alloc_page(GFP_KERNEL); 607 struct page *p = alloc_page(GFP_KERNEL);
@@ -615,7 +616,6 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
615 rqstp->rq_pages[i] = p; 616 rqstp->rq_pages[i] = p;
616 } 617 }
617 rqstp->rq_pages[i++] = NULL; /* this might be seen in nfs_read_actor */ 618 rqstp->rq_pages[i++] = NULL; /* this might be seen in nfs_read_actor */
618 BUG_ON(pages >= RPCSVC_MAXPAGES);
619 619
620 /* Make arg->head point to first page and arg->pages point to rest */ 620 /* Make arg->head point to first page and arg->pages point to rest */
621 arg = &rqstp->rq_arg; 621 arg = &rqstp->rq_arg;