From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb35.google.com (mail-yb1-xb35.google.com [IPv6:2607:f8b0:4864:20::b35]) by sourceware.org (Postfix) with ESMTPS id 2E4853858C39 for ; Tue, 9 Apr 2024 14:06:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2E4853858C39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2E4853858C39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::b35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712671600; cv=none; b=kT5XXyezgyaRu+cY3bkHQkMmBa0MI8CfzJcTrFrun5KeSodPvm7qT5Rh3vk6+6D/cipqFadBJmf39pOz/FWE8S7BvQ2xT1EBusy8Skn/OVQG7dc+gPM7Bkv4t7Xo2EpCnvj64upsL5yNiCsfUHco/qUFD5J/PMt6WygHe6iwBEk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712671600; c=relaxed/simple; bh=SNWhTn0+y24Jkt59t76e6A6rtz2rYgHhleMEDZqSdPs=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=ajRIvpMvvkq+4tAqs0qCmAP32QDlO865MjmmCl6zsG0E37EPbPIGJVXzssz9JLmnfedW0gXXl3Ll8sGmGBPTVgviqxa/EJvKNYF0yg7MjL3gR/Jgi1klD5yUfs+2aso14Y63VAt4lyFyX8Eqchb8WjbOnXYBlCv7nzIGZTNyGFQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yb1-xb35.google.com with SMTP id 3f1490d57ef6-dcc73148611so6021627276.3 for ; Tue, 09 Apr 2024 07:06:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712671591; x=1713276391; darn=sourceware.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Nis6WEsMLALZWdsrkXgXbdwg3RLRPp8EmgeFCq0xhgw=; b=Kce64zIdCjoJWVxSoc7l0+AgG6r2bUJkSI7akg1EvTVFceT15kwUCaRQzN5mNaPL1G SF20Pk6lRFWl8TQasNcQMrQIQsleU8QNPCywuwEi74IbirDN+SNVThD8ye58a50/plQ9 knM/XxQZ0QkA0k1jOiatren3rAWt+kBymEQB28/VZXriZwI5weJ1BJ4QNT8SCkvmy6iQ ZDbkeIE1q9KXCXtHSuXvQtZ7vtFB6nGqKl+9hfOWRwm9nRbRraWVIHACbNLg1IvnI+QS R3Z1CFI0ygP7KXrPnkI0FunN12zHfXxT2plfTwBxVW5cwzyrIV2jVXjxiMj+DFu4b/xD eUig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712671591; x=1713276391; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Nis6WEsMLALZWdsrkXgXbdwg3RLRPp8EmgeFCq0xhgw=; b=f4Kzqf6Nw4R8tcAMAofsSYqpULwRgd8n5dWSMzWJfLhcMWXqSb/YCFHAgoq6KoDPXB J/ZroV8bQ7JtbTKNrDjJTQ0uSMBsBHPY2AwMzuyJ76k2FNRjeeLosreiRpjHoE5fcVQX NYuRHTFbdMgIU6TJAhBIuagThYIzfeNifTE9UrdmBH1HgAX+h7Jyq4GvUHwsDOwibFv6 J8+uafqIf0iDboegBvFQNvFdFwkwk8i0HBc5TwqNzfnJ15+mgVRiiJtQSpHkdc84Hrem jn1sdprJKVx8KPDqOB063y+qVH3W4quaDMOvYG15YEQ2tnu8+QkSeUfqpCfGg9QKOH/a OHeQ== X-Forwarded-Encrypted: i=1; AJvYcCXFocjbxIPSPIHFfT+NcM9V6hW2bQ8f1M1h2Z+p45Y+mnwQIqwm6KPk9VnoPhb1cvz6+6sPISQtv3HbRnWg6/Umsqt1cNyh7eg8 X-Gm-Message-State: AOJu0YxuVrvKGviZ7csVasHH6S4Z3UcBGrCBUXCXjA2jEYir7IY7Jdp2 fIa7KhjZzBSnZpmQUWMgnqkhht613GC4H6Xb+yerOsJjkTgOKj2LohpD0h+7LxcSxKkLb0j34xb jA/3MUEH8b44AEp+bFR9lB4NZxBM= X-Google-Smtp-Source: AGHT+IH8L3l/Za/3ITGpS8MEwoNICyHfY1eVbd7qq40gQ12q4ctEiRCC2a62L7DFGJUQYhll6goFJWK8q91H93oPfsE= X-Received: by 2002:a25:6b4c:0:b0:dd1:3421:b3ea with SMTP id o12-20020a256b4c000000b00dd13421b3eamr8912005ybm.21.1712671591447; Tue, 09 Apr 2024 07:06:31 -0700 (PDT) MIME-Version: 1.0 References: <20240405123550.1748641-1-adhemerval.zanella@linaro.org> In-Reply-To: From: "H.J. Lu" Date: Tue, 9 Apr 2024 07:05:55 -0700 Message-ID: Subject: Re: [PATCH] aarch64: Remove ld.so __tls_get_addr plt usage To: Adhemerval Zanella Netto Cc: Szabolcs Nagy , =?UTF-8?Q?Cristian_Rodr=C3=ADguez?= , Florian Weimer , libc-alpha@sourceware.org, Vitaly Buka , Fangrui Song , Evgenii Stepanov , Kostya Serebryany , Dmitry Vyukov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3013.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Apr 9, 2024 at 7:03=E2=80=AFAM Adhemerval Zanella Netto wrote: > > > > On 09/04/24 05:30, Szabolcs Nagy wrote: > > The 04/08/2024 13:57, Adhemerval Zanella Netto wrote: > >> On 08/04/24 04:26, Szabolcs Nagy wrote: > >>> The 04/07/2024 16:29, Cristian Rodr=C3=ADguez wrote: > >>>> On Fri, Apr 5, 2024 at 11:59=E2=80=AFAM Szabolcs Nagy wrote: > >>>>> The 04/05/2024 09:35, Adhemerval Zanella wrote: > >>>>>> Use the hidden alias instead. > >>>>>> > >>>>>> Checked on aarch64-linux-gnu. > >>>>> > >>>>> does this change behaviour in case __tls_get_addr is interposed? > >>>> > >>>> Wut ? is that really supported.. I mean.. isn't that symbol prefix > >>>> reserved for the implementation and any assumption about it is eithe= r > >>>> ID or UB? > >>> > >>> a behaviour can change even if it's not supported. > >>> i did not try to imply that it should be supported. > >>> > >>> i know sanitizers interpose __tls_get_addr, because > >>> https://sourceware.org/bugzilla/show_bug.cgi?id=3D16291 > >>> i don't know if that hack works at all now for tlsdesc > >>> (where the ld.so calls __tls_get_addr, not user code) > >>> > >>> my question was if we investigated this issue since it > >>> is useful to document then in the commit msg (or news > >>> entry if this affects users) > >> > >> This change 'breaks' the sanitizer trick to get the dynamic TLS, with > >> this patch I now see: > >> > >> MemorySanitizer-AARCH64 :: dtls_test.c > >> SanitizerCommon-asan-aarch64-Linux :: Linux/resize_tls_dynamic.cpp > >> SanitizerCommon-msan-aarch64-Linux :: Linux/resize_tls_dynamic.cpp > >> SanitizerCommon-tsan-aarch64-Linux :: Linux/resize_tls_dynamic.cpp > >> > >> And it does not fail on x86 only because it uses -mtls=3Dgnu as defaul= t > >> (the same tests fail on x86 with -mtls=3Dgnu2). > >> > >> Now that GCC and distributions are aiming to use GNU2/DESC as the > >> default TLS, this hack will also break on x86. So the question is > >> whether we revert 050f7298e1ecc39887c329037575ccd972071255 and > >> document that __tls_get_addr should be interposable, or move with this > >> change and try to come up with a possible solution for BZ#16291. > >> > >> I bringing this because we will have another two ABIs with tlsdesc > >> support (loongarch and riscv). > > > > adding some sanitizer committers to cc. > > > > tl;dr: in the next glibc release tlsdesc will not call > > __tls_get_addr in an interposable way in the dynamic tls > > allocation case, unless somebody screems that this is needed. > > (affects targets that may default to tlsdesc, but note that > > the dynamic case only triggers with tlsdesc when a lot of > > dlopened tls is used, otherwise static tls area is used) > > Just a note that this already true for x86 with -mtls=3Dgnu2 since > 2.21. And now that distro are aiming to make it default, this issues > will happen more often. > > > > > i think it is also possible that we will use custom malloc > > in ld.so which may be just as big change for the sanitizers. > > (this can make tls access signal safe) > > > > i'm not against the change, but if we plan to add several > > interposable hooks as in > > https://sourceware.org/glibc/wiki/ThreadPropertiesAPI > > then we might as well keep __tls_get_addr PLT for now. > > > > I don't have a strong opinion, but what I really want is to have > consistency over the architectures. Meaning that if we want to keep > the __tls_get_addr PLT for sanitizer/runtime hooks, it would be good > to revert the x86 change. We need to add gnu2 tests to libsanitizer when making the x86 change. > It also means to document it properly somewhere and make the new > RISC-V and loongarch follow the same guidelines. > > I will take a look again on the ThreadPropertiesAPI, since it is has > been more and more a demanding issue. --=20 H.J.