From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id 245EE3858C39 for ; Tue, 9 Apr 2024 14:03:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 245EE3858C39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 245EE3858C39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712671434; cv=none; b=Muvg6xFreTVkxdYzwhD0hCfWeuWt4sON8HWelsIxkQwcS8ulKyqLHyLT5Sqda+efy7OF30xf8fU7UwHNHpK0lxCyRaxSDxjIpdT5+VC766ZwCpgzg9cBJQOTL209QtPZMqEvoHgdIssWAxPrsmxwPD6Zur4sDehrg4tzqP+JisM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712671434; c=relaxed/simple; bh=i8PrTTt2NDztFRTpGVTRj74qjrPxECmhtj3CK2++usg=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=nwWDFNL4MJi345IQlV7llaUtizzM9XtvpuH7bhF8isHbroUvAoZucxUVHSbp+pteRwHneXeZLz+8RbGvUxeY5EUJpiifYpitdmwtcUy56gA2Y0Xmqf64W/Pcw+cfYbmi6zH0CR5XUx/aJEL367b6QkE6wc6K4ibnxJ6NP/moRyQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1e3c9300c65so31618655ad.0 for ; Tue, 09 Apr 2024 07:03:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712671430; x=1713276230; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=NPrtaDNB9j36KNGv61Z55cQBPW9Teto5tWX9ricSwe8=; b=osAVV1YUk6GzTyggsDn5UXb+wznU9Uhi2yyS2q7HqzBUgg9rbzt6purF2Xbes5x4tk B/cX147TmaVhLHguQvDiO819mbNWgZm+b1Hyjns4NATtA0w44yLrXiALeyfIHT23vEWG M/Xm1RJoHEtFD5M93cRfWsNBRmn4QWC8pNZ9HUfMC18SBRBSkczZojiRbTGCyfXNz+Ia xB7oGhafgC2j6uk4Rh39uCdskiv/GRMFv0ryYyry1+Gx5mg3zllAZQDOsmR1hrWB24mt mS+pd96yBI47usiCavmnbsVoJkfYAVTw9C+Jw6R5Vbl6p76sRI0gLvVMjrv8XfO4/LMx nL2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712671430; x=1713276230; h=content-transfer-encoding:in-reply-to:organization:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=NPrtaDNB9j36KNGv61Z55cQBPW9Teto5tWX9ricSwe8=; b=sNO7v+aRFYhd9z6mnhzS09HW1AcijMVMlz6P+3gOVE/fwfCwNAgbrHpUx1LXbyTDVW 0an2w3NR6tTnTeIlPvdrdD/UA1QdeAkkFe/OyZKV4ZZybHdltGACXs1MSxJDCydj3HJP SNTqreiakF+IyMH22N90lwYouJsaJlNO331NaASBRwcPk70c0d77q+QiYodfZ6JnFl7+ ACmbfhK12GJ/4sck7C6/KzZq0ShhGnJMZxHXxlNF7dY/thikx2dXI8wpGgILUVXA0dVz 7ieX6jLNSn5YRj5n4UwRRA6QOTi0VNlMQKhc3w1iDvczpEYheI5H/nMBXsJZEHfTaM2Y 3hlA== X-Gm-Message-State: AOJu0YzDV0AOIMhSigA1wji2O0PVR9owFogte72+ud6xB3Kbl78dysXJ zSFDeNFILafbp5d6qJVD1MumiTTDzKGOjX3pMV9h4EBjrKWz1gX0SkHkJXn+SSY= X-Google-Smtp-Source: AGHT+IGGqeBobcNzOQyi1hqykJQOZz0Laz2I8PPuiHnfKiJH+9MF6hG1eyoHb+1IFdLkqtOkuIbdMQ== X-Received: by 2002:a17:902:db08:b0:1e4:ae60:91fe with SMTP id m8-20020a170902db0800b001e4ae6091femr1186404plx.51.1712671429913; Tue, 09 Apr 2024 07:03:49 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c0:3e7e:c5ca:dd5b:a5af:8027? ([2804:1b3:a7c0:3e7e:c5ca:dd5b:a5af:8027]) by smtp.gmail.com with ESMTPSA id z8-20020a170903018800b001e45b3539dbsm3085303plg.41.2024.04.09.07.03.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 09 Apr 2024 07:03:49 -0700 (PDT) Message-ID: Date: Tue, 9 Apr 2024 11:03:45 -0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] aarch64: Remove ld.so __tls_get_addr plt usage To: Szabolcs Nagy , =?UTF-8?Q?Cristian_Rodr=C3=ADguez?= , "H.J. Lu" , Florian Weimer Cc: libc-alpha@sourceware.org, Vitaly Buka , Fangrui Song , Evgenii Stepanov , Kostya Serebryany , Dmitry Vyukov References: <20240405123550.1748641-1-adhemerval.zanella@linaro.org> Content-Language: en-US From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 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 will take a look again on the ThreadPropertiesAPI, since it is has been more and more a demanding issue.