public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Jakub Jelinek <jakub@redhat.com>
Cc: gcc-patches@gcc.gnu.org, ubizjak@gmail.com
Subject: Re: [PATCH] tree-optimization/111736 - avoid address sanitizing of __seg_gs
Date: Thu, 21 Mar 2024 10:50:04 +0100 (CET)	[thread overview]
Message-ID: <6s6232os-orp0-3rrs-o2s8-527147op3879@fhfr.qr> (raw)
In-Reply-To: <Zfv9rl7rOSSlXtwX@tucnak>

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)

  reply	other threads:[~2024-03-21  9:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <00997.124032105252600733@us-mta-75.us.mimecast.lan>
2024-03-21  9:28 ` Jakub Jelinek
2024-03-21  9:50   ` Richard Biener [this message]
2024-03-21  9:52     ` Jakub Jelinek
2024-03-21 10:29       ` Richard Biener
2024-03-21  9:25 Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6s6232os-orp0-3rrs-o2s8-527147op3879@fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=ubizjak@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).