Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: fix skb leak in __skb_tstamp_tx()

Commit 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with
TX timestamp.") added a call to skb_orphan_frags_rx() to fix leaks with
zerocopy skbs. But it ended up adding a leak of its own. When
skb_orphan_frags_rx() fails, the function just returns, leaking the skb
it just cloned. Free it before returning.

This bug was discovered and resolved using Coverity Static Analysis
Security Testing (SAST) by Synopsys, Inc.

Fixes: 50749f2dd685 ("tcp/udp: Fix memleaks of sk and zerocopy skbs with TX timestamp.")
Signed-off-by: Pratyush Yadav <ptyadav@amazon.de>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/20230522153020.32422-1-ptyadav@amazon.de
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Pratyush Yadav and committed by
Jakub Kicinski
8a02fb71 d6c36cbc

+3 -1
+3 -1
net/core/skbuff.c
··· 5224 5224 } else { 5225 5225 skb = skb_clone(orig_skb, GFP_ATOMIC); 5226 5226 5227 - if (skb_orphan_frags_rx(skb, GFP_ATOMIC)) 5227 + if (skb_orphan_frags_rx(skb, GFP_ATOMIC)) { 5228 + kfree_skb(skb); 5228 5229 return; 5230 + } 5229 5231 } 5230 5232 if (!skb) 5231 5233 return;