selftests/bpf: wq: destroy skeleton on failure paths
Subsystems (3)
PATCH 1/1 selftests/bpf: wq: destroy skeleton on failure paths
serial_test_wq() opens and loads a wq skeleton and then attaches it. If wq__attach() fails, the test returns early and skips wq__destroy(), leaking the skeleton resources.
Fix by routing error exits through a common cleanup path and always destroying the skeleton when it was created.
This is the same class of bug as the earlier skeleton leak fix (CVE-2022-3532), but in tools/testing/selftests/bpf/prog_tests/wq.c.
Signed-off-by Kery Qi <[email protected]>
--- tools/testing/selftests/bpf/prog_tests/wq.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
tools/testing/selftests/bpf/prog_tests/wq.c +5 -2
@@ -21,7 +21,7 @@ void serial_test_wq(void) err =wq__attach (wq_skel);if (!ASSERT_OK (err,"wq_attach" )) -return ; + goto clean_up prog_fd =bpf_program__fd (wq_skel->progs.test_syscall_array_sleepable); err =bpf_prog_test_run_opts (prog_fd, &topts);
@@ -31,7 +31,10 @@ void serial_test_wq(void)usleep (50 );/* 10 usecs should be enough, but give it extra */ ASSERT_EQ (wq_skel->bss->ok_sleepable, (1 <<1 ),"ok_sleepable" ); -wq__destroy (wq_skel); + +clean_up: +if (wq_skel) +wq__destroy (wq_skel); }void serial_test_failures_wq (void )
Signature · 1 line
2.34.1