Skip to content

Commit

Permalink
svcrdma: backchannel cannot share a page for send and rcv buffers
Browse files Browse the repository at this point in the history
The underlying transport releases the page pointed to by rq_buffer
during xprt_rdma_bc_send_request. When the backchannel reply arrives,
rq_rbuffer then points to freed memory.

Fixes: 6877894 ('SUNRPC: Separate buffer pointers for RPC ...')
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Cc: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
Chuck Lever authored and J. Bruce Fields committed Nov 1, 2016
1 parent 18e601d commit 8d42629
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions net/sunrpc/xprtrdma/svc_rdma_backchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,26 @@ xprt_rdma_bc_allocate(struct rpc_task *task)
return -EINVAL;
}

/* svc_rdma_sendto releases this page */
page = alloc_page(RPCRDMA_DEF_GFP);
if (!page)
return -ENOMEM;

rqst->rq_buffer = page_address(page);
rqst->rq_rbuffer = (char *)rqst->rq_buffer + rqst->rq_callsize;

rqst->rq_rbuffer = kmalloc(rqst->rq_rcvsize, RPCRDMA_DEF_GFP);
if (!rqst->rq_rbuffer) {
put_page(page);
return -ENOMEM;
}
return 0;
}

static void
xprt_rdma_bc_free(struct rpc_task *task)
{
/* No-op: ctxt and page have already been freed. */
struct rpc_rqst *rqst = task->tk_rqstp;

kfree(rqst->rq_rbuffer);
}

static int
Expand Down

0 comments on commit 8d42629

Please sign in to comment.