[PATCH] net: pktgen: fix null ptr deref in skb allocation

Subsystems: networking [general], the rest

STALE3870d

3 messages, 2 authors, 2016-01-12 · open the first message on its own page

[PATCH] net: pktgen: fix null ptr deref in skb allocation

From: John Fastabend <john.fastabend@gmail.com>
Date: 2016-01-11 05:38:59

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")
Signed-off-by: John Fastabend <redacted>
---
 net/core/pktgen.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index de8d5cc..4da4d51 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -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;
 }

Re: [PATCH] net: pktgen: fix null ptr deref in skb allocation

From: David Miller <davem@davemloft.net>
Date: 2016-01-11 22:40:32

From: John Fastabend <john.fastabend@gmail.com>
Date: Sun, 10 Jan 2016 21:38:44 -0800
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")
Signed-off-by: John Fastabend <redacted>
I don't know how I missed that during review :-/

Applied and queued up for -stable, thanks!

Re: [PATCH] net: pktgen: fix null ptr deref in skb allocation

From: John Fastabend <john.fastabend@gmail.com>
Date: 2016-01-12 17:32:55

On 16-01-11 02:40 PM, David Miller wrote:
From: John Fastabend <john.fastabend@gmail.com>
Date: Sun, 10 Jan 2016 21:38:44 -0800
quoted
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")
Signed-off-by: John Fastabend <redacted>
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 :)
Applied and queued up for -stable, thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help