Skip to content

Commit bdb2ce8

Browse files
chuckleveramschuma-ntap
authored andcommitted
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: ab03eff ("xprtrdma: Add trace points in RPC Call transmit paths") Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 58bd665 commit bdb2ce8

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

include/trace/events/rpcrdma.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -692,11 +692,10 @@ TRACE_EVENT(xprtrdma_prepsend_failed,
692692

693693
TRACE_EVENT(xprtrdma_post_send,
694694
TP_PROTO(
695-
const struct rpcrdma_req *req,
696-
int status
695+
const struct rpcrdma_req *req
697696
),
698697

699-
TP_ARGS(req, status),
698+
TP_ARGS(req),
700699

701700
TP_STRUCT__entry(
702701
__field(const void *, req)
@@ -705,7 +704,6 @@ TRACE_EVENT(xprtrdma_post_send,
705704
__field(unsigned int, client_id)
706705
__field(int, num_sge)
707706
__field(int, signaled)
708-
__field(int, status)
709707
),
710708

711709
TP_fast_assign(
@@ -718,15 +716,13 @@ TRACE_EVENT(xprtrdma_post_send,
718716
__entry->sc = req->rl_sendctx;
719717
__entry->num_sge = req->rl_wr.num_sge;
720718
__entry->signaled = req->rl_wr.send_flags & IB_SEND_SIGNALED;
721-
__entry->status = status;
722719
),
723720

724-
TP_printk("task:%u@%u req=%p sc=%p (%d SGE%s) %sstatus=%d",
721+
TP_printk("task:%u@%u req=%p sc=%p (%d SGE%s) %s",
725722
__entry->task_id, __entry->client_id,
726723
__entry->req, __entry->sc, __entry->num_sge,
727724
(__entry->num_sge == 1 ? "" : "s"),
728-
(__entry->signaled ? "signaled " : ""),
729-
__entry->status
725+
(__entry->signaled ? "signaled" : "")
730726
)
731727
);
732728

net/sunrpc/xprtrdma/verbs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1356,8 +1356,8 @@ int rpcrdma_post_sends(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req)
13561356
--ep->re_send_count;
13571357
}
13581358

1359+
trace_xprtrdma_post_send(req);
13591360
rc = frwr_send(r_xprt, req);
1360-
trace_xprtrdma_post_send(req, rc);
13611361
if (rc)
13621362
return -ENOTCONN;
13631363
return 0;

0 commit comments

Comments
 (0)