summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorPratyush Yadav <ptyadav@amazon.de>2023-05-22 17:30:20 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-05-30 12:57:58 +0100
commita594382ec6d0cc8cff5a8bc7e61b54e3858fb243 (patch)
treed5d9e570d76d71bf4b81ff159253abe6a37f6968 /net
parent8a30dce9d7f70f8438956f6a01142b926c301334 (diff)
downloadlinux-a594382ec6d0cc8cff5a8bc7e61b54e3858fb243.tar.gz
linux-a594382ec6d0cc8cff5a8bc7e61b54e3858fb243.tar.bz2
linux-a594382ec6d0cc8cff5a8bc7e61b54e3858fb243.zip
net: fix skb leak in __skb_tstamp_tx()
commit 8a02fb71d7192ff1a9a47c9d937624966c6e09af upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/core/skbuff.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index fb6b3f2ae192..e203172b9b9e 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4751,8 +4751,10 @@ void __skb_tstamp_tx(struct sk_buff *orig_skb,
} else {
skb = skb_clone(orig_skb, GFP_ATOMIC);
- if (skb_orphan_frags_rx(skb, GFP_ATOMIC))
+ if (skb_orphan_frags_rx(skb, GFP_ATOMIC)) {
+ kfree_skb(skb);
return;
+ }
}
if (!skb)
return;