]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
skbuff: re-add check for NULL skb->head in kfree_skb path
authorFlorian Westphal <fw@strlen.de>
Sun, 23 Jul 2017 17:54:47 +0000 (19:54 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Jul 2017 23:27:08 +0000 (16:27 -0700)
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.

Reported-by: kernel test robot <fengguang.wu@intel.com>
Fixes: 06dc75ab06943 ("net: Revert "net: add function to allocate sk_buff head without data area")
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/skbuff.c

index 84bdfa229b0d428504170bcfc836b12fc6a2057f..c27da51d14e4903937b34efe839999cfca2e049e 100644 (file)
@@ -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);
 }
 
 /**