On Wed, 17 Apr 2024, Jakub Jelinek wrote: > Hi! > > .ABNORMAL_DISPATCHER is currently the only internal function with > ECF_NORETURN, and asan likes to instrument ECF_NORETURN calls by adding > some builtin call before them, which breaks the .ABNORMAL_DISPATCHER > discovery added in gsi_safe_*. > > The following patch fixes asan not to instrument .ABNORMAL_DISPATCHER > calls, like it doesn't instrument a couple of specific builtin calls > as well. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK > 2024-04-17 Jakub Jelinek <ja...@redhat.com> > > PR sanitizer/114743 > * asan.cc (maybe_instrument_call): Don't instrument calls to > .ABNORMAL_DISPATCHER. > > * gcc.dg/asan/pr112709-2.c (freddy): New function from > gcc.dg/ubsan/pr112709-2.c version of the test. > > --- gcc/asan.cc.jj 2024-04-11 11:12:03.756191961 +0200 > +++ gcc/asan.cc 2024-04-16 17:32:14.304098386 +0200 > @@ -3030,6 +3030,9 @@ maybe_instrument_call (gimple_stmt_itera > break; > } > } > + if (gimple_call_internal_p (stmt, IFN_ABNORMAL_DISPATCHER)) > + /* Don't instrument this. */ > + return false; > /* If a function does not return, then we must handle clearing up the > shadow stack accordingly. For ASAN we can simply set the entire stack > to "valid" for accesses by setting the shadow space to 0 and all > --- gcc/testsuite/gcc.dg/asan/pr112709-2.c.jj 2024-03-13 09:18:58.000925135 > +0100 > +++ gcc/testsuite/gcc.dg/asan/pr112709-2.c 2024-04-16 17:34:26.084301656 > +0200 > @@ -48,3 +48,15 @@ l3: > if (x < 4) > goto *q[x & 3]; > } > + > +void > +freddy (int x, int *y, struct S *p) > +{ > + bar (*p); > + ++p; > + if (x == 25) > + x = foo (2); > + else if (x == 42) > + x = foo (foo (3)); > + *y = bar (*p); > +} > > Jakub > > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)