bpf: Fix socket leaks around connect(AF_UNSPEC)+listen() - #8594
bpf: Fix socket leaks around connect(AF_UNSPEC)+listen()#8594kernel-patches-daemon-bpf-rc[bot] wants to merge 2 commits into
Conversation
|
Upstream branch: e5fd3f5 |
c953291 to
47219af
Compare
|
Upstream branch: 7cd8645 |
e245c00 to
cc33f3b
Compare
|
Upstream branch: 7cd8645 |
cc33f3b to
15c71a1
Compare
|
Upstream branch: 31a420a |
15c71a1 to
7787b2b
Compare
6d62329 to
ab5db42
Compare
|
Upstream branch: 31a420a |
7787b2b to
21034fe
Compare
ab5db42 to
bef3f93
Compare
|
Upstream branch: 7a3c028 |
21034fe to
dadc39c
Compare
bef3f93 to
0e8ddea
Compare
__bpf_sk_lookup() and bpf_sk_lookup() duplicate the same sk_to_full_sk() reqsk-to-listener upgrade. Extract it into a helper. Leave the currently unreachable WARN_ONCE as a defensive assert. No functional change. Signed-off-by: Michal Luczaj <mhal@rbox.co> Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com> Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Lookup helpers gate whether to acquire a socket reference on sk_is_refcounted(), a check re-evaluated at release. An established socket refcounted at acquire time can gain SOCK_RCU_FREE via connect(AF_UNSPEC)+listen() before release runs; the release-side re-check then reads sk_is_refcounted() == false and skips the put. The reference leaks. Make acquire and release unconditional and symmetric: always take a reference, always put it. Adapt sk_select_reuseport(). Fixes: 6acc9b4 ("bpf: Add helper to retrieve socket in BPF") Fixes: 64d8529 ("bpf: Allow bpf_map_lookup_elem for SOCKMAP and SOCKHASH") Reported-by: Sashiko <sashiko-bot@kernel.org> Closes: https://lore.kernel.org/bpf/20260701235552.2B0AA1F00A3F@smtp.kernel.org/ Signed-off-by: Michal Luczaj <mhal@rbox.co> Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
|
Upstream branch: a13307e |
dadc39c to
4c23290
Compare
Pull request for series with
subject: bpf: Fix socket leaks around connect(AF_UNSPEC)+listen()
version: 2
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1139204