Re: [PATCH] tree-optimization/111736 - avoid address sanitizing of __seg_gs
On Thu, 21 Mar 2024, Jakub Jelinek wrote: > On Thu, Mar 21, 2024 at 10:50:04AM +0100, Richard Biener wrote: > > Fixed and pushed. I suppose for address-spaces nested within the > > generic address space we could instrument the address converted to > > the generic address space value. > > Unlike TLS, we don't know if address-spaces are nested within the generic > address space and how to map the as address to a generic as address. In theory there's hooks for this (TARGET_ADDR_SPACE_SUBSET_P) and ADDR_SPACE_CONVERT_EXPR to do the conversion. But hardly worth it I guess. Richard.
Re: [PATCH] tree-optimization/111736 - avoid address sanitizing of __seg_gs
On Thu, Mar 21, 2024 at 10:50:04AM +0100, Richard Biener wrote: > Fixed and pushed. I suppose for address-spaces nested within the > generic address space we could instrument the address converted to > the generic address space value. Unlike TLS, we don't know if address-spaces are nested within the generic address space and how to map the as address to a generic as address. Jakub
Re: [PATCH] tree-optimization/111736 - avoid address sanitizing of __seg_gs
On Thu, 21 Mar 2024, Jakub Jelinek wrote: > On Thu, Mar 21, 2024 at 10:25:24AM +0100, Richard Biener wrote: > > The following more thoroughly avoids address sanitizing accesses > > to non-generic address-spaces. > > > > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > > > OK? > > > > Thanks, > > Richard. > > > > PR tree-optimization/111736 > > * asan.cc (instrument_derefs): Do not instrument accesses > > to non-generic address-spaces. > > > > * gcc.target/i386/pr111736.c: New testcase. > > --- > > gcc/asan.cc | 4 > > gcc/testsuite/gcc.target/i386/pr111736.c | 23 +++ > > 2 files changed, 27 insertions(+) > > create mode 100644 gcc/testsuite/gcc.target/i386/pr111736.c > > > > diff --git a/gcc/asan.cc b/gcc/asan.cc > > index cfe83106460..04caf8802e2 100644 > > --- a/gcc/asan.cc > > +++ b/gcc/asan.cc > > @@ -2755,6 +2755,10 @@ instrument_derefs (gimple_stmt_iterator *iter, tree > > t, > >if (VAR_P (inner) && DECL_HARD_REGISTER (inner)) > > return; > > > > + /* Accesses to non-generic address-spaces are not handled. */ > > I'd say s/are not handled/should not be instrumented/ Fixed and pushed. I suppose for address-spaces nested within the generic address space we could instrument the address converted to the generic address space value. Richard. > > + if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (inner > > +return; > > + > > Otherwise LGTM. > > >poly_int64 decl_size; > >if ((VAR_P (inner) > > || (TREE_CODE (inner) == RESULT_DECL > > diff --git a/gcc/testsuite/gcc.target/i386/pr111736.c > > b/gcc/testsuite/gcc.target/i386/pr111736.c > > new file mode 100644 > > index 000..231fdd07e80 > > --- /dev/null > > +++ b/gcc/testsuite/gcc.target/i386/pr111736.c > > @@ -0,0 +1,23 @@ > > +/* { dg-do compile } */ > > +/* { dg-options "-O2 -fsanitize=address" } */ > > + > > +int __seg_gs m; > > + > > +int foo (void) > > +{ > > + return m; > > +} > > + > > +extern int __seg_gs n; > > + > > +int bar (void) > > +{ > > + return n; > > +} > > + > > +int baz (int __seg_gs *o) > > +{ > > + return *o; > > +} > > + > > +/* { dg-final { scan-assembler-not "asan_report_load" } } */ > > -- > > 2.35.3 > > Jakub > > -- Richard Biener SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)
Re: [PATCH] tree-optimization/111736 - avoid address sanitizing of __seg_gs
On Thu, Mar 21, 2024 at 10:25:24AM +0100, Richard Biener wrote: > The following more thoroughly avoids address sanitizing accesses > to non-generic address-spaces. > > Bootstrapped and tested on x86_64-unknown-linux-gnu. > > OK? > > Thanks, > Richard. > > PR tree-optimization/111736 > * asan.cc (instrument_derefs): Do not instrument accesses > to non-generic address-spaces. > > * gcc.target/i386/pr111736.c: New testcase. > --- > gcc/asan.cc | 4 > gcc/testsuite/gcc.target/i386/pr111736.c | 23 +++ > 2 files changed, 27 insertions(+) > create mode 100644 gcc/testsuite/gcc.target/i386/pr111736.c > > diff --git a/gcc/asan.cc b/gcc/asan.cc > index cfe83106460..04caf8802e2 100644 > --- a/gcc/asan.cc > +++ b/gcc/asan.cc > @@ -2755,6 +2755,10 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t, >if (VAR_P (inner) && DECL_HARD_REGISTER (inner)) > return; > > + /* Accesses to non-generic address-spaces are not handled. */ I'd say s/are not handled/should not be instrumented/ > + if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (inner > +return; > + Otherwise LGTM. >poly_int64 decl_size; >if ((VAR_P (inner) > || (TREE_CODE (inner) == RESULT_DECL > diff --git a/gcc/testsuite/gcc.target/i386/pr111736.c > b/gcc/testsuite/gcc.target/i386/pr111736.c > new file mode 100644 > index 000..231fdd07e80 > --- /dev/null > +++ b/gcc/testsuite/gcc.target/i386/pr111736.c > @@ -0,0 +1,23 @@ > +/* { dg-do compile } */ > +/* { dg-options "-O2 -fsanitize=address" } */ > + > +int __seg_gs m; > + > +int foo (void) > +{ > + return m; > +} > + > +extern int __seg_gs n; > + > +int bar (void) > +{ > + return n; > +} > + > +int baz (int __seg_gs *o) > +{ > + return *o; > +} > + > +/* { dg-final { scan-assembler-not "asan_report_load" } } */ > -- > 2.35.3 Jakub
[PATCH] tree-optimization/111736 - avoid address sanitizing of __seg_gs
The following more thoroughly avoids address sanitizing accesses to non-generic address-spaces. Bootstrapped and tested on x86_64-unknown-linux-gnu. OK? Thanks, Richard. PR tree-optimization/111736 * asan.cc (instrument_derefs): Do not instrument accesses to non-generic address-spaces. * gcc.target/i386/pr111736.c: New testcase. --- gcc/asan.cc | 4 gcc/testsuite/gcc.target/i386/pr111736.c | 23 +++ 2 files changed, 27 insertions(+) create mode 100644 gcc/testsuite/gcc.target/i386/pr111736.c diff --git a/gcc/asan.cc b/gcc/asan.cc index cfe83106460..04caf8802e2 100644 --- a/gcc/asan.cc +++ b/gcc/asan.cc @@ -2755,6 +2755,10 @@ instrument_derefs (gimple_stmt_iterator *iter, tree t, if (VAR_P (inner) && DECL_HARD_REGISTER (inner)) return; + /* Accesses to non-generic address-spaces are not handled. */ + if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (inner +return; + poly_int64 decl_size; if ((VAR_P (inner) || (TREE_CODE (inner) == RESULT_DECL diff --git a/gcc/testsuite/gcc.target/i386/pr111736.c b/gcc/testsuite/gcc.target/i386/pr111736.c new file mode 100644 index 000..231fdd07e80 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr111736.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fsanitize=address" } */ + +int __seg_gs m; + +int foo (void) +{ + return m; +} + +extern int __seg_gs n; + +int bar (void) +{ + return n; +} + +int baz (int __seg_gs *o) +{ + return *o; +} + +/* { dg-final { scan-assembler-not "asan_report_load" } } */ -- 2.35.3