Skip to content

Commit e7ec96f

Browse files
Bob Pearsonjgunthorpe
authored andcommitted
RDMA/rxe: Fix skb lifetime in rxe_rcv_mcast_pkt()
The changes referenced below replaced sbk_clone)_ by taking additional references, passing the skb along and then freeing the skb. This deleted the packets before they could be processed and additionally passed bad data in each packet. Since pkt is stored in skb->cb changing pkt->qp changed it for all the packets. Replace skb_get() by sbk_clone() in rxe_rcv_mcast_pkt() for cases where multiple QPs are receiving multicast packets on the same address. Delete kfree_skb() because the packets need to live until they have been processed by each QP. They are freed later. Fixes: 86af617 ("IB/rxe: remove unnecessary skb_clone") Fixes: fe896ce ("IB/rxe: replace refcount_inc with skb_get") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bob Pearson <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 1858d98 commit e7ec96f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

drivers/infiniband/sw/rxe/rxe_recv.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)
233233
struct rxe_mc_elem *mce;
234234
struct rxe_qp *qp;
235235
union ib_gid dgid;
236+
struct sk_buff *per_qp_skb;
237+
struct rxe_pkt_info *per_qp_pkt;
236238
int err;
237239

238240
if (skb->protocol == htons(ETH_P_IP))
@@ -261,21 +263,26 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb)
261263
if (err)
262264
continue;
263265

264-
/* if *not* the last qp in the list
265-
* increase the users of the skb then post to the next qp
266+
/* for all but the last qp create a new clone of the
267+
* skb and pass to the qp.
266268
*/
267269
if (mce->qp_list.next != &mcg->qp_list)
268-
skb_get(skb);
270+
per_qp_skb = skb_clone(skb, GFP_ATOMIC);
271+
else
272+
per_qp_skb = skb;
269273

270-
pkt->qp = qp;
274+
per_qp_pkt = SKB_TO_PKT(per_qp_skb);
275+
per_qp_pkt->qp = qp;
271276
rxe_add_ref(qp);
272-
rxe_rcv_pkt(pkt, skb);
277+
rxe_rcv_pkt(per_qp_pkt, per_qp_skb);
273278
}
274279

275280
spin_unlock_bh(&mcg->mcg_lock);
276281

277282
rxe_drop_ref(mcg); /* drop ref from rxe_pool_get_key. */
278283

284+
return;
285+
279286
err1:
280287
kfree_skb(skb);
281288
}

0 commit comments

Comments
 (0)