Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3d861f66 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

net: fix secpath kmemleak



Mike Kazantsev found 3.5 kernels and beyond were leaking memory,
and tracked the faulty commit to a1c7fff7 ("net:
netdev_alloc_skb() use build_skb()")

While this commit seems fine, it uncovered a bug introduced
in commit bad43ca8 ("net: introduce skb_try_coalesce()), in function
kfree_skb_partial()"):

If head is stolen, we free the sk_buff,
without removing references on secpath (skb->sp).

So IPsec + IP defrag/reassembly (using skb coalescing), or
TCP coalescing could leak secpath objects.

Fix this bug by calling skb_release_head_state(skb) to properly
release all possible references to linked objects.

Reported-by: default avatarMike Kazantsev <mk.fraggod@gmail.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Bisected-by: default avatarMike Kazantsev <mk.fraggod@gmail.com>
Tested-by: default avatarMike Kazantsev <mk.fraggod@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8a6e29d6
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -3379,11 +3379,13 @@ EXPORT_SYMBOL(__skb_warn_lro_forwarding);

void kfree_skb_partial(struct sk_buff *skb, bool head_stolen)
{
	if (head_stolen)
	if (head_stolen) {
		skb_release_head_state(skb);
		kmem_cache_free(skbuff_head_cache, skb);
	else
	} else {
		__kfree_skb(skb);
	}
}
EXPORT_SYMBOL(kfree_skb_partial);

/**