[PATCH bpf v2 15/15] selftests/bpf: Don't override SIGSEGV handler with ASAN

Ihor Solodrai posted 15 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH bpf v2 15/15] selftests/bpf: Don't override SIGSEGV handler with ASAN
Posted by Ihor Solodrai 1 month, 2 weeks ago
test_progs has custom SIGSEGV handler, which interferes with the
address sanitizer [1]. Add an #ifndef to avoid this.

[1] https://lore.kernel.org/bpf/73d832948b01dbc0ebc60d85574bdf8537f3a810.camel@gmail.com/

Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
---
 tools/testing/selftests/bpf/test_progs.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index 02a85dda30e6..b533cede933d 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -1944,13 +1944,15 @@ int main(int argc, char **argv)
 		.parser = parse_arg,
 		.doc = argp_program_doc,
 	};
+	int err, i;
+
+#ifndef __SANITIZE_ADDRESS__
 	struct sigaction sigact = {
 		.sa_handler = crash_handler,
 		.sa_flags = SA_RESETHAND,
-		};
-	int err, i;
-
+	};
 	sigaction(SIGSEGV, &sigact, NULL);
+#endif
 
 	env.stdout_saved = stdout;
 	env.stderr_saved = stderr;
-- 
2.53.0
Re: [PATCH bpf v2 15/15] selftests/bpf: Don't override SIGSEGV handler with ASAN
Posted by Mykyta Yatsenko 1 month, 1 week ago
On 2/18/26 00:30, Ihor Solodrai wrote:
> test_progs has custom SIGSEGV handler, which interferes with the
> address sanitizer [1]. Add an #ifndef to avoid this.
>
> [1] https://lore.kernel.org/bpf/73d832948b01dbc0ebc60d85574bdf8537f3a810.camel@gmail.com/
>
> Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
> ---
>   tools/testing/selftests/bpf/test_progs.c | 8 +++++---
>   1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> index 02a85dda30e6..b533cede933d 100644
> --- a/tools/testing/selftests/bpf/test_progs.c
> +++ b/tools/testing/selftests/bpf/test_progs.c
> @@ -1944,13 +1944,15 @@ int main(int argc, char **argv)
>   		.parser = parse_arg,
>   		.doc = argp_program_doc,
>   	};
> +	int err, i;
> +
> +#ifndef __SANITIZE_ADDRESS__
>   	struct sigaction sigact = {
>   		.sa_handler = crash_handler,
>   		.sa_flags = SA_RESETHAND,
> -		};
> -	int err, i;
> -
> +	};
>   	sigaction(SIGSEGV, &sigact, NULL);
> +#endif
>   
>   	env.stdout_saved = stdout;
>   	env.stderr_saved = stderr;
I think this is reasonable for the use case. We may try dumping logs
in |__asan_on_error(), if that proves useful.
Acked-by: Mykyta Yatsenko <yatsenko@meta.com>|
Re: [PATCH bpf v2 15/15] selftests/bpf: Don't override SIGSEGV handler with ASAN
Posted by Eduard Zingerman 1 month, 1 week ago
On Wed, 2026-02-18 at 15:12 +0000, Mykyta Yatsenko wrote:
> On 2/18/26 00:30, Ihor Solodrai wrote:
> > test_progs has custom SIGSEGV handler, which interferes with the
> > address sanitizer [1]. Add an #ifndef to avoid this.
> > 
> > [1] https://lore.kernel.org/bpf/73d832948b01dbc0ebc60d85574bdf8537f3a810.camel@gmail.com/
> > 
> > Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev>
> > ---
> >   tools/testing/selftests/bpf/test_progs.c | 8 +++++---
> >   1 file changed, 5 insertions(+), 3 deletions(-)
> > 
> > diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> > index 02a85dda30e6..b533cede933d 100644
> > --- a/tools/testing/selftests/bpf/test_progs.c
> > +++ b/tools/testing/selftests/bpf/test_progs.c
> > @@ -1944,13 +1944,15 @@ int main(int argc, char **argv)
> >   		.parser = parse_arg,
> >   		.doc = argp_program_doc,
> >   	};
> > +	int err, i;
> > +
> > +#ifndef __SANITIZE_ADDRESS__
> >   	struct sigaction sigact = {
> >   		.sa_handler = crash_handler,
> >   		.sa_flags = SA_RESETHAND,
> > -		};
> > -	int err, i;
> > -
> > +	};
> >   	sigaction(SIGSEGV, &sigact, NULL);
> > +#endif
> >   
> >   	env.stdout_saved = stdout;
> >   	env.stderr_saved = stderr;
> I think this is reasonable for the use case. We may try dumping logs
> in |__asan_on_error(), if that proves useful.
> Acked-by: Mykyta Yatsenko <yatsenko@meta.com>|

Agree with Mykyta, crash_handler() can be split in two parts and
__asan_on_error() can be defined, calling the part doing
dump_test_log().