Skip to content

Commit 7573ee6

Browse files
Mikhail Malygingregkh
authored andcommitted
RDMA/rxe: Prevent access to wr->next ptr afrer wr is posted to send queue
[ Upstream commit 5f0b2a6 ] rxe_post_send_kernel() iterates over linked list of wr's, until the wr->next ptr is NULL. However if we've got an interrupt after last wr is posted, control may be returned to the code after send completion callback is executed and wr memory is freed. As a result, wr->next pointer may contain incorrect value leading to panic. Store the wr->next on the stack before posting it. Fixes: 8700e3e ("Soft RoCE driver") Link: https://lore.kernel.org/r/20200716190340.23453-1-m.malygin@yadro.com Signed-off-by: Mikhail Malygin <m.malygin@yadro.com> Signed-off-by: Sergey Kojushev <s.kojushev@yadro.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 3383a99 commit 7573ee6

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/infiniband/sw/rxe/rxe_verbs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,7 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, const struct ib_send_wr *wr,
733733
unsigned int mask;
734734
unsigned int length = 0;
735735
int i;
736+
struct ib_send_wr *next;
736737

737738
while (wr) {
738739
mask = wr_opcode_mask(wr->opcode, qp);
@@ -749,6 +750,8 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, const struct ib_send_wr *wr,
749750
break;
750751
}
751752

753+
next = wr->next;
754+
752755
length = 0;
753756
for (i = 0; i < wr->num_sge; i++)
754757
length += wr->sg_list[i].length;
@@ -759,7 +762,7 @@ static int rxe_post_send_kernel(struct rxe_qp *qp, const struct ib_send_wr *wr,
759762
*bad_wr = wr;
760763
break;
761764
}
762-
wr = wr->next;
765+
wr = next;
763766
}
764767

765768
rxe_run_task(&qp->req.task, 1);

0 commit comments

Comments
 (0)