* Re: [PATCH] tree-optimization/111736 - avoid address sanitizing of __seg_gs
[not found] <00997.124032105252600733@us-mta-75.us.mimecast.lan>
@ 2024-03-21 9:28 ` Jakub Jelinek
2024-03-21 9:50 ` Richard Biener
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2024-03-21 9:28 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches, ubizjak
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 00000000000..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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tree-optimization/111736 - avoid address sanitizing of __seg_gs
2024-03-21 9:28 ` [PATCH] tree-optimization/111736 - avoid address sanitizing of __seg_gs Jakub Jelinek
@ 2024-03-21 9:50 ` Richard Biener
2024-03-21 9:52 ` Jakub Jelinek
0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2024-03-21 9:50 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches, ubizjak
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 00000000000..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 <rguenther@suse.de>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Ivo Totev, Andrew McDonald, Werner Knoblich; (HRB 36809, AG Nuernberg)
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tree-optimization/111736 - avoid address sanitizing of __seg_gs
2024-03-21 9:50 ` Richard Biener
@ 2024-03-21 9:52 ` Jakub Jelinek
2024-03-21 10:29 ` Richard Biener
0 siblings, 1 reply; 5+ messages in thread
From: Jakub Jelinek @ 2024-03-21 9:52 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches, ubizjak
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] tree-optimization/111736 - avoid address sanitizing of __seg_gs
2024-03-21 9:52 ` Jakub Jelinek
@ 2024-03-21 10:29 ` Richard Biener
0 siblings, 0 replies; 5+ messages in thread
From: Richard Biener @ 2024-03-21 10:29 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches, ubizjak
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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] tree-optimization/111736 - avoid address sanitizing of __seg_gs
@ 2024-03-21 9:25 Richard Biener
0 siblings, 0 replies; 5+ messages in thread
From: Richard Biener @ 2024-03-21 9:25 UTC (permalink / raw)
To: gcc-patches; +Cc: Jakub Jelinek, ubizjak
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 00000000000..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
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-03-21 10:29 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <00997.124032105252600733@us-mta-75.us.mimecast.lan>
2024-03-21 9:28 ` [PATCH] tree-optimization/111736 - avoid address sanitizing of __seg_gs Jakub Jelinek
2024-03-21 9:50 ` Richard Biener
2024-03-21 9:52 ` Jakub Jelinek
2024-03-21 10:29 ` Richard Biener
2024-03-21 9:25 Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).