Commit bdb2ce82 authored by Chuck Lever's avatar Chuck Lever Committed by Anna Schumaker

xprtrdma: Fix trace point use-after-free race

It's not safe to use resources pointed to by the @send_wr of
ib_post_send() _after_ that function returns. Those resources are
typically freed by the Send completion handler, which can run before
ib_post_send() returns.

Thus the trace points currently around ib_post_send() in the
client's RPC/RDMA transport are a hazard, even when they are
disabled. Rearrange them so that they touch the Work Request only
_before_ ib_post_send() is invoked.

Fixes: ab03eff5 ("xprtrdma: Add trace points in RPC Call transmit paths")
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent 58bd6656
...@@ -692,11 +692,10 @@ TRACE_EVENT(xprtrdma_prepsend_failed, ...@@ -692,11 +692,10 @@ TRACE_EVENT(xprtrdma_prepsend_failed,
TRACE_EVENT(xprtrdma_post_send, TRACE_EVENT(xprtrdma_post_send,
TP_PROTO( TP_PROTO(
const struct rpcrdma_req *req, const struct rpcrdma_req *req
int status
), ),
TP_ARGS(req, status), TP_ARGS(req),
TP_STRUCT__entry( TP_STRUCT__entry(
__field(const void *, req) __field(const void *, req)
...@@ -705,7 +704,6 @@ TRACE_EVENT(xprtrdma_post_send, ...@@ -705,7 +704,6 @@ TRACE_EVENT(xprtrdma_post_send,
__field(unsigned int, client_id) __field(unsigned int, client_id)
__field(int, num_sge) __field(int, num_sge)
__field(int, signaled) __field(int, signaled)
__field(int, status)
), ),
TP_fast_assign( TP_fast_assign(
...@@ -718,15 +716,13 @@ TRACE_EVENT(xprtrdma_post_send, ...@@ -718,15 +716,13 @@ TRACE_EVENT(xprtrdma_post_send,
__entry->sc = req->rl_sendctx; __entry->sc = req->rl_sendctx;
__entry->num_sge = req->rl_wr.num_sge; __entry->num_sge = req->rl_wr.num_sge;
__entry->signaled = req->rl_wr.send_flags & IB_SEND_SIGNALED; __entry->signaled = req->rl_wr.send_flags & IB_SEND_SIGNALED;
__entry->status = status;
), ),
TP_printk("task:%u@%u req=%p sc=%p (%d SGE%s) %sstatus=%d", TP_printk("task:%u@%u req=%p sc=%p (%d SGE%s) %s",
__entry->task_id, __entry->client_id, __entry->task_id, __entry->client_id,
__entry->req, __entry->sc, __entry->num_sge, __entry->req, __entry->sc, __entry->num_sge,
(__entry->num_sge == 1 ? "" : "s"), (__entry->num_sge == 1 ? "" : "s"),
(__entry->signaled ? "signaled " : ""), (__entry->signaled ? "signaled" : "")
__entry->status
) )
); );
......
...@@ -1356,8 +1356,8 @@ int rpcrdma_post_sends(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req) ...@@ -1356,8 +1356,8 @@ int rpcrdma_post_sends(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
--ep->re_send_count; --ep->re_send_count;
} }
trace_xprtrdma_post_send(req);
rc = frwr_send(r_xprt, req); rc = frwr_send(r_xprt, req);
trace_xprtrdma_post_send(req, rc);
if (rc) if (rc)
return -ENOTCONN; return -ENOTCONN;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment