mirror of
https://github.com/torvalds/linux.git
synced 2026-11-30 10:32:24 +00:00
udp: Fix a memory leak in udp_read_sock()
sk_psock_verdict_recv() clones the skb and uses the clone
afterward, so udp_read_sock() should free the skb after using
it, regardless of error or not.
This fixes a real kmemleak.
Fixes: d7f571188e ("udp: Implement ->read_sock() for sockmap")
Signed-off-by: Cong Wang <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: John Fastabend <[email protected]>
Acked-by: Jakub Sitnicki <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
This commit is contained in:
committed by
Daniel Borkmann
parent
a7e65fe7d8
commit
e00a5c331b
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user