From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by sourceware.org (Postfix) with ESMTPS id 0644D3858C39 for ; Tue, 9 Apr 2024 14:11:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0644D3858C39 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dabbelt.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 0644D3858C39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::630 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712671889; cv=none; b=pT1Y2jBdCZ59KDoOJIU6LKRJGSgx8+qVdFmk//yvUDyUE9zc0NsHSuz28SgTJgqDM21rqVhDwyUuAcHp4GC6fuJRN6pGGrtraODueXUNNIxEYq48/shCHb+Dc8bim31OfsCw19eO0YVsmadyWDuUA+hfxvDvRhcYIIo54SsKJmo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712671889; c=relaxed/simple; bh=rGX7mCobal8QKokxVyYe0aHON/Elo93KY42MvDbtCQk=; h=DKIM-Signature:Date:Subject:From:To:Message-ID; b=ftehqoP99MkKBkYwHl18dXeMVg7pzw9cj33B36EXyGLvsEgijWtNVbkC9C1kSCMtHNA0W5BQjrbTC5F5zskyL1RoADeQtRUWOQdbju5Kp12fO24ZX4rMCsHsBY1lJ2F4dz1KWGPQTntagHWkuhhSWrsNpA7NThKMfsAqvV8I9AA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1e455b630acso10011075ad.1 for ; Tue, 09 Apr 2024 07:11:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20230601.gappssmtp.com; s=20230601; t=1712671886; x=1713276686; darn=sourceware.org; h=message-id:to:from:cc:in-reply-to:subject:date:from:to:cc:subject :date:message-id:reply-to; bh=COwhYHnh5/b+PEVo/tApYFh04FoRBNQAUXSaAzmr/mo=; b=TeWuEok+akm98XNuiDJtlaJR4m6nUeQk/H7DXV/jUt/9lz4AHvUDCU50IvNHvW/T5z mBNSYvRd/XHavXAd4+3HmZrxxfKddoAA0ttyLQQrq/ODWKQ0mEASFAAsU4xiCnOk003I eNqU6cAaCBZGSKa9bX/xoww7NzJDxwbRrMwvdNIDAkNscr1KEo4xaONmikb1wq6YmGNI E5QpaVUvPrGa0HBfTmk3zTSQ2YseBkaVZhh6ter2N4fu4IfzdXNhTEawBvmv7ZGVp094 jwzwB9d3dHJMmEt9eUzG6E8FB9owvKoM55Gs2xXhTLee3Rl+JC2sw5RlSbKZvPAHpmxI 7WGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712671886; x=1713276686; h=message-id:to:from:cc:in-reply-to:subject:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=COwhYHnh5/b+PEVo/tApYFh04FoRBNQAUXSaAzmr/mo=; b=iaMXtzwKCZFSPuLwp57W/lA52i2wJGQgs5UqHi+dm2WCwYZqV6rDeFIJ2OvzVp6TXg WHRwhVYPidS0GpSaOwcV592xZlnQHk7lM8NTalEN1FBjExZmnWUxj/EELhIyuW2eYW+q xDsw1wGz6I8vCIKXIS4q3FShCq8BZ74m5QFd2I3VAgxobnylFsbMb9XcSJqwt6vn6z9e XteOvzdedpq3l64fous+tIHJTvCkv6zGWup7PIVuSrT2TA8MObOAxW8IJP1Rx+emjj4/ uUTeOgamrL/dPX41gNsRmIKtu2oXFH7daDL4birufqndSbSb+zkrbaRAQfLiUR6DZj9U OIYw== X-Forwarded-Encrypted: i=1; AJvYcCVgycHYdpOa2LDX6AZmM+RebYAagjbYiLXocG52z/7rn7PV+wcvHDwOkLNsQYtog75QIV6u0GPsTErT6EB0EmjR1wDZJLczrBLT X-Gm-Message-State: AOJu0YwybOAWpRfNergdCG3RDiXYFv1tsf8W23KBYvw6H8bGwlbLwcPP YQ4S2hZ26mnhTJ/f0DFCr1Ciohc2s1eLOGNd4I9I3O9hMts+peKML6wKG3odJHwfSmM1rsg1+yy S X-Google-Smtp-Source: AGHT+IFSIRk6tdxaDLgC/Vz4g0n81UiNSBGh9uhTtMd0WxdgBRbdCvfimvdiNdMfL9Cd1aCOm/AISQ== X-Received: by 2002:a17:902:f30c:b0:1df:fa1a:529f with SMTP id c12-20020a170902f30c00b001dffa1a529fmr8383685ple.24.1712671885524; Tue, 09 Apr 2024 07:11:25 -0700 (PDT) Received: from localhost ([50.145.13.30]) by smtp.gmail.com with ESMTPSA id n3-20020a170902e54300b001e3dd5972ccsm6609498plf.185.2024.04.09.07.11.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 07:11:25 -0700 (PDT) Date: Tue, 09 Apr 2024 07:11:25 -0700 (PDT) X-Google-Original-Date: Tue, 09 Apr 2024 07:11:05 PDT (-0700) Subject: Re: [PATCH] aarch64: Remove ld.so __tls_get_addr plt usage In-Reply-To: CC: szabolcs.nagy@arm.com, cristian@rodriguez.im, H.J. Lu , fweimer@redhat.com, libc-alpha@sourceware.org, vitalybuka@google.com, i@maskray.me, eugenis@google.com, kcc@google.com, dvyukov@google.com From: Palmer Dabbelt To: adhemerval.zanella@linaro.org Message-ID: X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,PP_MIME_FAKE_ASCII_TEXT,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, 09 Apr 2024 07:03:45 PDT (-0700), adhemerval.zanella@linaro.org 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íguez wrote: >>>>> On Fri, Apr 5, 2024 at 11:59 AM 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 either >>>>> 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=16291 >>>> 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=gnu as default >>> (the same tests fail on x86 with -mtls=gnu2). >>> >>> 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=gnu2 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. > > It also means to document it properly somewhere and make the new > RISC-V and loongarch follow the same guidelines. I also don't have a strong opinion on whether __tls_get_addr should be interposable, but I'm happy to try and make the RISC-V port match arm64/x86. I guess we're kind of safe for now as we don't have TLSDESC merged, though I think we were getting pretty close there so we should probbaly decide before we accidentally commit to an ABI. > I will take a look again on the ThreadPropertiesAPI, since it is has > been more and more a demanding issue.