Skip to contentSkip to conversation

net: pktgen: fix null ptr deref in skb allocation

PATCH In review John Fastabend 2 participants 3 messages Jan 11, 2016 – Jan 12, 2016

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

PATCH 1/1 net: pktgen: fix null ptr deref in skb allocation

Fix possible null pointer dereference that may occur when calling skb_reserve() on a null skb.

Fixes 879c7220e82 ("net: pktgen: Observe needed_headroom of the device")
---
 net/core/pktgen.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/pktgen.c +3 -1
index de8d5cc..4da4d51 100644
@@ -2787,7 +2787,9 @@ static struct sk_buff *pktgen_alloc_skb(struct net_device *dev,
 	} else {
 		 skb = __netdev_alloc_skb(dev, size, GFP_NOWAIT);
 	}
-	skb_reserve(skb, LL_RESERVED_SPACE(dev));
+
+	if (likely(skb))
+		skb_reserve(skb, LL_RESERVED_SPACE(dev));
 
 	return skb;
 }
maintainer
#1 lore raw

From: John Fastabend <[email protected]>
Date: Sun, 10 Jan 2016 21:38:44 -0800

Quoted 5 lines

Fix possible null pointer dereference that may occur when calling skb_reserve() on a null skb.

Fixes 879c7220e82 ("net: pktgen: Observe needed_headroom of the device")

I don't know how I missed that during review :-/

Applied and queued up for -stable, thanks!

#2 lore raw
Quoted 10 lines · David Miller

From: John Fastabend <[email protected]>
Date: Sun, 10 Jan 2016 21:38:44 -0800

Quoted 5 lines

Fix possible null pointer dereference that may occur when calling skb_reserve() on a null skb.

Fixes 879c7220e82 ("net: pktgen: Observe needed_headroom of the device")

I don't know how I missed that during review :-/

Well once you get pktgen running fast enough to get allocation failures the occasional system halts are pretty hard to miss :)

Quoted 3 lines

Applied and queued up for -stable, thanks!