[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20260108032609.1585-1-qikeyu2017@gmail.com>
Date: Thu, 8 Jan 2026 11:26:09 +0800
From: Kery Qi <qikeyu2017@...il.com>
To: daniel@...earbox.net
Cc: linux-kernel@...r.kernel.org,
Kery Qi <qikeyu2017@...il.com>
Subject: [PATCH] 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 <qikeyu2017@...il.com>
---
tools/testing/selftests/bpf/prog_tests/wq.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/wq.c b/tools/testing/selftests/bpf/prog_tests/wq.c
index 15c67d23128b..1dcdeda84853 100644
--- a/tools/testing/selftests/bpf/prog_tests/wq.c
+++ b/tools/testing/selftests/bpf/prog_tests/wq.c
@@ -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)
--
2.34.1
Powered by blists - more mailing lists