All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch bpf] udp: fix a memory leak in udp_read_sock()
@ 2021-05-17  2:23 Cong Wang
  2021-05-17 16:22 ` Song Liu
  2021-05-18  5:36 ` John Fastabend
  0 siblings, 2 replies; 14+ messages in thread
From: Cong Wang @ 2021-05-17  2:23 UTC (permalink / raw)
  To: netdev
  Cc: bpf, Cong Wang, John Fastabend, Daniel Borkmann, Jakub Sitnicki,
	Lorenz Bauer

From: Cong Wang <cong.wang@bytedance.com>

sk_psock_verdict_recv() clones the skb and uses the clone
afterward, so udp_read_sock() should free the original skb after
done using it.

Fixes: d7f571188ecf ("udp: Implement ->read_sock() for sockmap")
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Jakub Sitnicki <jakub@cloudflare.com>
Cc: Lorenz Bauer <lmb@cloudflare.com>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
---
 net/ipv4/udp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 15f5504adf5b..e31d67fd5183 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1798,11 +1798,13 @@ int udp_read_sock(struct sock *sk, read_descriptor_t *desc,
 		if (used <= 0) {
 			if (!copied)
 				copied = used;
+			kfree_skb(skb);
 			break;
 		} else if (used <= skb->len) {
 			copied += used;
 		}
 
+		kfree_skb(skb);
 		if (!desc->count)
 			break;
 	}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-05-21 23:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17  2:23 [Patch bpf] udp: fix a memory leak in udp_read_sock() Cong Wang
2021-05-17 16:22 ` Song Liu
2021-05-18  5:36 ` John Fastabend
2021-05-18 16:54   ` Cong Wang
2021-05-18 19:56     ` John Fastabend
2021-05-18 21:21       ` Cong Wang
2021-05-19 19:06         ` John Fastabend
2021-05-19 20:17           ` Cong Wang
2021-05-19 21:54             ` John Fastabend
2021-05-19 23:26               ` Cong Wang
2021-05-20 17:42                 ` John Fastabend
2021-05-20 20:14                   ` Cong Wang
2021-05-21 22:09                     ` John Fastabend
2021-05-21 23:39                       ` Cong Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.