From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4C9E53858C35; Thu, 21 Mar 2024 09:26:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C9E53858C35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711013194; bh=xpLvII2x+MvymD5YWzlkqsj4y0lqE+D3NxZqRIpSTi8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ipm5mOrT4kfsBi++6/kFfbPaRywDFIeURGj25sOGcHotB+GWXDYzPMOFOJb5QSuDz 6aBUj5tuBvkazPntPlS/vTMEiJ2RaJkXItO0uzGECBb11QIpgWaoBOqaPZ98vgI/Dg 6wIurlyApB1rCXhuOoePc/IdJZhNjDaCR+IUsbdk= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug sanitizer/111736] Address sanitizer is not compatible with named address spaces Date: Thu, 21 Mar 2024 09:26:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: sanitizer X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: addr-space, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D111736 --- Comment #20 from Jakub Jelinek --- (In reply to Uro=C5=A1 Bizjak from comment #19) > (In reply to Uro=C5=A1 Bizjak from comment #16) > > (In reply to Richard Biener from comment #13) > > > The original testcase is fixed, appearantly slapping 'extern' on the = int > > > makes it not effective. > > >=20 > > > Possibly better amend the > > >=20 > > > if (VAR_P (inner) && DECL_HARD_REGISTER (inner)) > > > return; > > >=20 > > > check though. As indicated my fix fixed only VAR_DECL cases, there's > > > still pointer-based accesses (MEM_REF) to consider. So possibly even > > > the following is necessary > >=20 > > I must admit that to create the patch from Comment #11 I just mindlessly > > searched for DECL_THREAD_LOCAL_P in asan.cc and amended the location wi= th > > ADDR_SPACE_GENERIC_P check. > >=20 > > However, ASAN should back off from annotating *any* gs: prefixed addres= s.=20 > >=20 > > I'll test your patch from Comment #13 ASAP. >=20 > Weee, it works! >=20 > Decompressing Linux... Parsing ELF... Performing relocations... done. > Booting the kernel (entry_offset: 0x0000000000000000). > [ 0.000000] Linux version 6.8.0-11485-ge1826833c3a9 (uros@localhost) > (xgcc (GCC) 14.0.1 20240321 (experimental) [master r14-9588-g415091f0909], > GNU ld version 2.40-14.fc39) #1 SMP PREEMPT_DYNAMIC Thu Mar 21 09:44:30 C= ET > 2024 > ... >=20 > I have used slightly different patch: >=20 > --cut here-- > diff --git a/gcc/asan.cc b/gcc/asan.cc > index cfe83106460..026d079a4a1 100644 > --- a/gcc/asan.cc > +++ b/gcc/asan.cc > @@ -2755,6 +2755,9 @@ instrument_derefs (gimple_stmt_iterator *iter, tree= t, > if (VAR_P (inner) && DECL_HARD_REGISTER (inner)) > return; >=20=20 > + if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (inner)))) > + return; > + Agreed, this looks better. Though, talking about address spaces, guess we also need to change ubsan.cc, so that for targetm.addr_space.zero_address_valid (as) case it actually doe= sn't try to verify the pointers aren't NULL (it still should check alignment).=