Skip to contentSkip to conversation

skbuff: re-add check for NULL skb->head in kfree_skb path

PATCH Applied Florian Westphal 2 participants 2 messages Jul 23, 2017 – Jul 24, 2017

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

PATCH 1/1 skbuff: re-add check for NULL skb->head in kfree_skb path

A null check is needed after all. netlink skbs can have skb->head be backed by vmalloc. The netlink destructor vfree()s head, then sets it to NULL. We then panic in skb_release_data with a NULL dereference.

Re-add such a test.

Alternative would be to switch to kvfree to free skb->head memory and remove the special handling in netlink destructor.

Fixes 06dc75ab06943 ("net: Revert "net: add function to allocate sk_buff head without data area")
---
 net/core/skbuff.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/core/skbuff.c +2 -1
index 84bdfa2..c27da51 100644
@@ -638,7 +638,8 @@ void skb_release_head_state(struct sk_buff *skb)
 static void skb_release_all(struct sk_buff *skb)
 {
 	skb_release_head_state(skb);
-	skb_release_data(skb);
+	if (likely(skb->head))
+		skb_release_data(skb);
 }
 
 /**
Signature · 1 line
1.8.3.1
maintainer Applied
#1 lore raw

From: Florian Westphal <[email protected]>
Date: Sun, 23 Jul 2017 19:54:47 +0200

Quoted 4 lines

A null check is needed after all. netlink skbs can have skb->head be backed by vmalloc. The netlink destructor vfree()s head, then sets it to NULL. We then panic in skb_release_data with a NULL dereference.

Quoted 8 lines

Re-add such a test.

Alternative would be to switch to kvfree to free skb->head memory and remove the special handling in netlink destructor.

Fixes 06dc75ab06943 ("net: Revert "net: add function to allocate sk_buff head without data area")

Ok, back it goes.

Applied, thanks.