* [PATCH bpf-next] selftests/bpf: Clean up child when task_work__open() fails
@ 2026-09-18 2:43 Yun Lu
2026-09-18 13:24 ` Mykyta Yatsenko
2026-09-21 21:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Yun Lu @ 2026-09-18 2:43 UTC (permalink / raw)
To: andrii, eddyz87, ihor.solodrai, ast, daniel, memxor, martin.lau,
song, yonghong.song, jolsa, emil
Cc: bpf, linux-kselftest
From: Yun Lu <luyun@kylinos.cn>
task_work_run() forks a child that blocks reading a pipe until the
parent wakes it. If task_work__open() fails afterwards, the parent
returns without closing either pipe fd or waiting for the child.
Because the parent retains the write end, the child remains blocked in
read() until test_progs exits.
Route this failure through the common cleanup path. At this point
cleanup is safe: pe_fd is -1, link is NULL, task_work__destroy() accepts
NULL, and the pid > 0 branch closes the read end, wakes the child,
closes the write end and waits for it.
This is the last early return after a successful fork. The fork failure
path already closes both pipe fds after commit 5730dacb3f17
("selftests/bpf: Task_work selftest cleanup fixes").
Fixes: 39fd74dfd5d2 ("selftests/bpf: BPF task work scheduling tests")
Signed-off-by: Yun Lu <luyun@kylinos.cn>
---
Resent as a standalone patch against bpf-next as requested during
review; the content is unchanged from patch 2/2 of the previous
series.
tools/testing/selftests/bpf/prog_tests/test_task_work.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/test_task_work.c b/tools/testing/selftests/bpf/prog_tests/test_task_work.c
index 774b31a5f6ca..fe0cb1702eaa 100644
--- a/tools/testing/selftests/bpf/prog_tests/test_task_work.c
+++ b/tools/testing/selftests/bpf/prog_tests/test_task_work.c
@@ -85,7 +85,7 @@ static void task_work_run(const char *prog_name, const char *map_name)
skel = task_work__open();
if (!ASSERT_OK_PTR(skel, "task_work__open"))
- return;
+ goto cleanup;
bpf_object__for_each_program(prog, skel->obj) {
bpf_program__set_autoload(prog, false);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next] selftests/bpf: Clean up child when task_work__open() fails
2026-09-18 2:43 [PATCH bpf-next] selftests/bpf: Clean up child when task_work__open() fails Yun Lu
@ 2026-09-18 13:24 ` Mykyta Yatsenko
2026-09-21 21:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Mykyta Yatsenko @ 2026-09-18 13:24 UTC (permalink / raw)
To: Yun Lu, andrii, eddyz87, ihor.solodrai, ast, daniel, memxor,
martin.lau, song, yonghong.song, jolsa, emil
Cc: bpf, linux-kselftest
On 9/18/26 3:43 AM, Yun Lu wrote:
> From: Yun Lu <luyun@kylinos.cn>
>
> task_work_run() forks a child that blocks reading a pipe until the
> parent wakes it. If task_work__open() fails afterwards, the parent
> returns without closing either pipe fd or waiting for the child.
> Because the parent retains the write end, the child remains blocked in
> read() until test_progs exits.
>
> Route this failure through the common cleanup path. At this point
> cleanup is safe: pe_fd is -1, link is NULL, task_work__destroy() accepts
> NULL, and the pid > 0 branch closes the read end, wakes the child,
> closes the write end and waits for it.
>
> This is the last early return after a successful fork. The fork failure
> path already closes both pipe fds after commit 5730dacb3f17
> ("selftests/bpf: Task_work selftest cleanup fixes").
>
> Fixes: 39fd74dfd5d2 ("selftests/bpf: BPF task work scheduling tests")
> Signed-off-by: Yun Lu <luyun@kylinos.cn>
>
> ---
Looks correct, thanks for the patch.
Acked-by: Mykyta Yatsenko <yatsenko@meta.com>
> Resent as a standalone patch against bpf-next as requested during
> review; the content is unchanged from patch 2/2 of the previous
> series.
>
> tools/testing/selftests/bpf/prog_tests/test_task_work.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/test_task_work.c b/tools/testing/selftests/bpf/prog_tests/test_task_work.c
> index 774b31a5f6ca..fe0cb1702eaa 100644
> --- a/tools/testing/selftests/bpf/prog_tests/test_task_work.c
> +++ b/tools/testing/selftests/bpf/prog_tests/test_task_work.c
> @@ -85,7 +85,7 @@ static void task_work_run(const char *prog_name, const char *map_name)
>
> skel = task_work__open();
> if (!ASSERT_OK_PTR(skel, "task_work__open"))
> - return;
> + goto cleanup;
>
> bpf_object__for_each_program(prog, skel->obj) {
> bpf_program__set_autoload(prog, false);
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH bpf-next] selftests/bpf: Clean up child when task_work__open() fails
2026-09-18 2:43 [PATCH bpf-next] selftests/bpf: Clean up child when task_work__open() fails Yun Lu
2026-09-18 13:24 ` Mykyta Yatsenko
@ 2026-09-21 21:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-21 21:30 UTC (permalink / raw)
To: luyun
Cc: andrii, eddyz87, ihor.solodrai, ast, daniel, memxor, martin.lau,
song, yonghong.song, jolsa, emil, bpf, linux-kselftest
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Fri, 18 Sep 2026 10:43:00 +0800 you wrote:
> From: Yun Lu <luyun@kylinos.cn>
>
> task_work_run() forks a child that blocks reading a pipe until the
> parent wakes it. If task_work__open() fails afterwards, the parent
> returns without closing either pipe fd or waiting for the child.
> Because the parent retains the write end, the child remains blocked in
> read() until test_progs exits.
>
> [...]
Here is the summary with links:
- [bpf-next] selftests/bpf: Clean up child when task_work__open() fails
https://git.kernel.org/bpf/bpf-next/c/8715b13c1a80
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-09-21 22:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-18 2:43 [PATCH bpf-next] selftests/bpf: Clean up child when task_work__open() fails Yun Lu
2026-09-18 13:24 ` Mykyta Yatsenko
2026-09-21 21:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).