linux/net/bpf
Josef Bacik 6aff0129f3
bpf: Use the socket of a sk_lookup test run under RCU
bpf_sk_lookup_assign() accepts only sockets which are freed by RCU, and
takes no reference. bpf_prog_test_run_sk_lookup() looks at sk_reuseport of
the selected socket and generates its cookie, which is a write, behind
bpf_test_timer_leave(), that is outside of the RCU read side critical
section in which the program ran. If the socket is closed in the meantime
it may be gone.

Do both before the section ends.

Fixes: 7c32e8f8bc ("bpf: Add PROG_TEST_RUN support for sk_lookup programs")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261017230950.802052-7-alexei.starovoitov@gmail.com
2026-10-18 00:36:43 +00:00
..
bpf_dummy_struct_ops.c bpf: Add struct bpf_tramp_node object 2026-06-07 10:03:01 -07:00
Makefile bpf: Add dummy BPF STRUCT_OPS for test purpose 2021-11-01 14:10:00 -07:00
test_run.c bpf: Use the socket of a sk_lookup test run under RCU 2026-10-18 00:36:43 +00:00