From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 686CB385842E; Thu, 21 Mar 2024 09:18:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 686CB385842E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1711012708; bh=Uu/zwPHpjJav+xmAuSk3Daji2EF2PetYQJ8I3vkBXAI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AB7iE0uIMNWTSwxf9lsSXTb2TyoUu65OZMOIhZTNGYEoJDOATrYGGO8q6NhNtw4uz +9HOVUzceS/QADh8ZYKRXOFIEUTlxuUMmRg//kuwrJGG5C11KkHM2dBt9qWOR4ojJW vhzAJwFpaNM9CqEQKZ0rvjVDaWPE4st8kKP6Qri0= From: "ubizjak at gmail dot com" 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:18:26 +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: ubizjak at gmail dot com 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 #19 from Uro=C5=A1 Bizjak --- (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 with > ADDR_SPACE_GENERIC_P check. >=20 > However, ASAN should back off from annotating *any* gs: prefixed address.= =20 >=20 > I'll test your patch from Comment #13 ASAP. Weee, it works! Decompressing Linux... Parsing ELF... Performing relocations... done. Booting the kernel (entry_offset: 0x0000000000000000). [ 0.000000] Linux version 6.8.0-11485-ge1826833c3a9 (uros@localhost) (xg= cc (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 CET 2024 ... I have used slightly different patch: --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; + if (!ADDR_SPACE_GENERIC_P (TYPE_ADDR_SPACE (TREE_TYPE (inner)))) + return; + poly_int64 decl_size; if ((VAR_P (inner) || (TREE_CODE (inner) =3D=3D RESULT_DECL --cut here-- Hard registers and named address spaces really have nothing in common. IMO, the fixes here should be applied to all release branches. Running KASAN sanitized kernel with the named AS is the ultimate test for this PR.=