Skip to content

Commit 7638e0b

Browse files
chuckleverTrond Myklebust
authored andcommitted
SUNRPC: Move fault injection call sites
I've hit some crashes that occur in the xprt_rdma_inject_disconnect path. It appears that, for some provides, rdma_disconnect() can take so long that the transport can disconnect and release its hardware resources while rdma_disconnect() is still running, resulting in a UAF in the provider. The transport's fault injection method may depend on the stability of transport data structures. That means it needs to be invoked only from contexts that hold the transport write lock. Fixes: 4a06825 ("SUNRPC: Transport fault injection") Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 73f5c88 commit 7638e0b

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎net/sunrpc/clnt.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1799,7 +1799,6 @@ call_allocate(struct rpc_task *task)
17991799

18001800
status = xprt->ops->buf_alloc(task);
18011801
trace_rpc_buf_alloc(task, status);
1802-
xprt_inject_disconnect(xprt);
18031802
if (status == 0)
18041803
return;
18051804
if (status != -ENOMEM) {

‎net/sunrpc/xprt.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1485,7 +1485,10 @@ bool xprt_prepare_transmit(struct rpc_task *task)
14851485

14861486
void xprt_end_transmit(struct rpc_task *task)
14871487
{
1488-
xprt_release_write(task->tk_rqstp->rq_xprt, task);
1488+
struct rpc_xprt *xprt = task->tk_rqstp->rq_xprt;
1489+
1490+
xprt_inject_disconnect(xprt);
1491+
xprt_release_write(xprt, task);
14891492
}
14901493

14911494
/**
@@ -1887,7 +1890,6 @@ void xprt_release(struct rpc_task *task)
18871890
spin_unlock(&xprt->transport_lock);
18881891
if (req->rq_buffer)
18891892
xprt->ops->buf_free(task);
1890-
xprt_inject_disconnect(xprt);
18911893
xdr_free_bvec(&req->rq_rcv_buf);
18921894
xdr_free_bvec(&req->rq_snd_buf);
18931895
if (req->rq_cred != NULL)

‎net/sunrpc/xprtrdma/transport.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,10 @@ xprt_rdma_connect_worker(struct work_struct *work)
262262
* xprt_rdma_inject_disconnect - inject a connection fault
263263
* @xprt: transport context
264264
*
265-
* If @xprt is connected, disconnect it to simulate spurious connection
266-
* loss.
265+
* If @xprt is connected, disconnect it to simulate spurious
266+
* connection loss. Caller must hold @xprt's send lock to
267+
* ensure that data structures and hardware resources are
268+
* stable during the rdma_disconnect() call.
267269
*/
268270
static void
269271
xprt_rdma_inject_disconnect(struct rpc_xprt *xprt)

0 commit comments

Comments
 (0)