Skip to contentSkip to conversation

xen/netback: Reset nr_frags before freeing skb

PATCH In review Ross Lagerwall 2 participants 2 messages Aug 5, 2019 – Aug 9, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/netback: Reset nr_frags before freeing skb

At this point nr_frags has been incremented but the frag does not yet have a page assigned so freeing the skb results in a crash. Reset nr_frags before freeing the skb to prevent this.

---
 drivers/net/xen-netback/netback.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/xen-netback/netback.c +2 -0
index 1d9940d4e8c7..c9262ffeefe4 100644
@@ -925,6 +925,7 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue,
 			skb_shinfo(skb)->nr_frags = MAX_SKB_FRAGS;
 			nskb = xenvif_alloc_skb(0);
 			if (unlikely(nskb == NULL)) {
+				skb_shinfo(skb)->nr_frags = 0;
 				kfree_skb(skb);
 				xenvif_tx_err(queue, &txreq, extra_count, idx);
 				if (net_ratelimit())
@@ -940,6 +941,7 @@ static void xenvif_tx_build_gops(struct xenvif_queue *queue,
 
 			if (xenvif_set_skb_gso(queue->vif, skb, gso)) {
 				/* Failure in xenvif_set_skb_gso is fatal. */
+				skb_shinfo(skb)->nr_frags = 0;
 				kfree_skb(skb);
 				kfree_skb(nskb);
 				break;
Signature · 7 lines
2.17.2


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
maintainer
#1 lore raw

From: Ross Lagerwall <[email protected]>
Date: Mon, 5 Aug 2019 16:34:34 +0100

Quoted 5 lines

At this point nr_frags has been incremented but the frag does not yet have a page assigned so freeing the skb results in a crash. Reset nr_frags before freeing the skb to prevent this.

Applied and queued up for -stable.