Skip to content

Commit 6dc7a0b

Browse files
jtdoranakryiko
authored andcommitted
selftests/bpf: Fix rare segfault in sock_fields prog test
test_sock_fields__detach() got called with a null pointer here when one of the CHECKs or ASSERTs up to the test_sock_fields__open_and_load() call resulted in a jump to the "done" label. A skeletons *__detach() is not safe to call with a null pointer, though. This led to a segfault. Go the easy route and only call test_sock_fields__destroy() which is null-pointer safe and includes detaching. Came across this while looking[1] to introduce the usage of bpf_tcp_helpers.h (included in progs/test_sock_fields.c) together with vmlinux.h. [1] https://lore.kernel.org/bpf/629bc069dd807d7ac646f836e9dca28bbc1108e2.camel@mailbox.tu-berlin.de/ Fixes: 8f50f16 ("selftests/bpf: Extend verifier and bpf_sock tests for dst_port loads") Signed-off-by: Jörn-Thorben Hinz <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Reviewed-by: Jakub Sitnicki <[email protected]> Reviewed-by: Martin KaFai Lau <[email protected]> Acked-by: John Fastabend <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent bb7a425 commit 6dc7a0b

File tree

1 file changed

+0
-1
lines changed

1 file changed

+0
-1
lines changed

tools/testing/selftests/bpf/prog_tests/sock_fields.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ void serial_test_sock_fields(void)
394394
test();
395395

396396
done:
397-
test_sock_fields__detach(skel);
398397
test_sock_fields__destroy(skel);
399398
if (child_cg_fd >= 0)
400399
close(child_cg_fd);

0 commit comments

Comments
 (0)