Skip to content

Commit 65567e4

Browse files
KAGA-KOKOdledford
authored andcommitted
RDMA/rxe: Fix a race condition in rxe_requester()
The rxe driver works as follows: * The send queue, receive queue and completion queues are implemented as circular buffers. * ib_post_send() and ib_post_recv() calls are serialized through a spinlock. * Removing elements from various queues happens from tasklet context. Tasklets are guaranteed to run on at most one CPU. This serializes access to these queues. See also rxe_completer(), rxe_requester() and rxe_responder(). * rxe_completer() processes the skbs queued onto qp->resp_pkts. * rxe_requester() handles the send queue (qp->sq.queue). * rxe_responder() processes the skbs queued onto qp->req_pkts. Since rxe_drain_req_pkts() processes qp->req_pkts, calling rxe_drain_req_pkts() from rxe_requester() is racy. Hence this patch. Reported-by: Moni Shoua <monis@mellanox.com> Signed-off-by: Bart Van Assche <bart.vanassche@wdc.com> Cc: stable@vger.kernel.org Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 37cb11a commit 65567e4

3 files changed

Lines changed: 2 additions & 10 deletions

File tree

‎drivers/infiniband/sw/rxe/rxe_loc.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,6 @@ int rxe_srq_from_attr(struct rxe_dev *rxe, struct rxe_srq *srq,
237237

238238
void rxe_release(struct kref *kref);
239239

240-
void rxe_drain_req_pkts(struct rxe_qp *qp, bool notify);
241240
int rxe_completer(void *arg);
242241
int rxe_requester(void *arg);
243242
int rxe_responder(void *arg);

‎drivers/infiniband/sw/rxe/rxe_req.c‎

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -594,15 +594,8 @@ int rxe_requester(void *arg)
594594
rxe_add_ref(qp);
595595

596596
next_wqe:
597-
if (unlikely(!qp->valid)) {
598-
rxe_drain_req_pkts(qp, true);
597+
if (unlikely(!qp->valid || qp->req.state == QP_STATE_ERROR))
599598
goto exit;
600-
}
601-
602-
if (unlikely(qp->req.state == QP_STATE_ERROR)) {
603-
rxe_drain_req_pkts(qp, true);
604-
goto exit;
605-
}
606599

607600
if (unlikely(qp->req.state == QP_STATE_RESET)) {
608601
qp->req.wqe_index = consumer_index(qp->sq.queue);

‎drivers/infiniband/sw/rxe/rxe_resp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ static enum resp_states do_class_d1e_error(struct rxe_qp *qp)
12091209
}
12101210
}
12111211

1212-
void rxe_drain_req_pkts(struct rxe_qp *qp, bool notify)
1212+
static void rxe_drain_req_pkts(struct rxe_qp *qp, bool notify)
12131213
{
12141214
struct sk_buff *skb;
12151215

0 commit comments

Comments
 (0)