Message ID | f559f925-0835-b19c-40f6-571b31a6cee4@suse.cz |
---|---|
State | New |
Headers | show |
Series | Do not put gimple stmt on an abnormal edge (PR sanitizer/82545). | expand |
On Mon, Oct 16, 2017 at 10:15:04PM +0200, Martin Liška wrote: > Hi. > > As discussed with Jakub on IRC, we should not put ASAN reporting function > on critical edges. Can that potentially lead to a missed use-after-scope, > but I guess it's very rare. > > Patch can bootstrap on ppc64le-redhat-linux and survives regression tests. > > Thanks, > Martin > > gcc/ChangeLog: > > 2017-10-16 Martin Liska <mliska@suse.cz> > > PR sanitizer/82545 > * asan.c (asan_expand_poison_ifn): Do not put gimple stmt > on an abnormal edge. > > gcc/testsuite/ChangeLog: > > 2017-10-16 Martin Liska <mliska@suse.cz> > > PR sanitizer/82545 > * gcc.dg/asan/pr82545.c: New test. Ok, with a nit: > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/asan/pr82545.c > @@ -0,0 +1,15 @@ > +/* PR sanitizer/82545. */ > +/* { dg-do compile } */ > + > +extern void c(int); > +extern void d(void); > + > +void a(void) { > + { > + int b; > + &b; > + __builtin_setjmp(0); Please call __builtin_setjmp with a valid argument in a global var, like: void *buf[5]; ... __builtin_setjmp(buf); > + c(b); > + } > + d(); > +} > Jakub
diff --git a/gcc/asan.c b/gcc/asan.c index 2aa0a795af2..99958ecc330 100644 --- a/gcc/asan.c +++ b/gcc/asan.c @@ -3400,6 +3400,10 @@ asan_expand_poison_ifn (gimple_stmt_iterator *iter, { edge e = gimple_phi_arg_edge (phi, i); + /* Do not insert on an edge we can't split. */ + if (e->flags & EDGE_ABNORMAL) + continue; + if (call_to_insert == NULL) call_to_insert = gimple_copy (call); diff --git a/gcc/testsuite/gcc.dg/asan/pr82545.c b/gcc/testsuite/gcc.dg/asan/pr82545.c new file mode 100644 index 00000000000..a0e1edc53d4 --- /dev/null +++ b/gcc/testsuite/gcc.dg/asan/pr82545.c @@ -0,0 +1,15 @@ +/* PR sanitizer/82545. */ +/* { dg-do compile } */ + +extern void c(int); +extern void d(void); + +void a(void) { + { + int b; + &b; + __builtin_setjmp(0); + c(b); + } + d(); +}