Commit 68b8bea1 authored by Ihor Solodrai's avatar Ihor Solodrai Committed by Alexei Starovoitov
Browse files

selftests/bpf: Fix double thread join in uprobe_multi_test



ASAN reported a "joining already joined thread" error. The
release_child() may be called multiple times for the same struct
child.

Fix by resetting child->thread to 0 after pthread_join.

Also memset(0) static child variable in test_attach_api().

Acked-by: default avatarMykyta Yatsenko <yatsenko@meta.com>
Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
Signed-off-by: default avatarIhor Solodrai <ihor.solodrai@linux.dev>
Link: https://lore.kernel.org/r/20260223190736.649171-15-ihor.solodrai@linux.dev


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent f7ac552b
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -62,8 +62,10 @@ static void release_child(struct child *child)
		return;
	close(child->go[1]);
	close(child->go[0]);
	if (child->thread)
	if (child->thread) {
		pthread_join(child->thread, NULL);
		child->thread = 0;
	}
	close(child->c2p[0]);
	close(child->c2p[1]);
	if (child->pid > 0)
@@ -331,6 +333,8 @@ test_attach_api(const char *binary, const char *pattern, struct bpf_uprobe_multi
{
	static struct child child;

	memset(&child, 0, sizeof(child));

	/* no pid filter */
	__test_attach_api(binary, pattern, opts, NULL);