From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id D10583858405 for ; Mon, 27 Sep 2021 13:02:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D10583858405 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-338-20QCoiHlMNeXGCyBNFUrPg-1; Mon, 27 Sep 2021 09:02:57 -0400 X-MC-Unique: 20QCoiHlMNeXGCyBNFUrPg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 58323835DE8; Mon, 27 Sep 2021 13:02:56 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.176]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4DD8A6CA24; Mon, 27 Sep 2021 13:02:55 +0000 (UTC) From: Florian Weimer To: Fangrui Song Cc: libc-alpha@sourceware.org, Adhemerval Zanella Subject: Re: [PATCH] elf: Add __libc_get_static_tls_bounds [BZ #16291] References: <20210925004227.1829014-1-maskray@google.com> Date: Mon, 27 Sep 2021 15:02:53 +0200 In-Reply-To: <20210925004227.1829014-1-maskray@google.com> (Fangrui Song's message of "Fri, 24 Sep 2021 17:42:27 -0700") Message-ID: <877df2i32a.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_INFOUSMEBIZ, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Sep 2021 13:03:09 -0000 * Fangrui Song: > Sanitizer runtimes need static TLS boundaries for a variety of use cases. > > * asan/hwasan/msan/tsan need to unpoison static TLS blocks to prevent false > positives due to reusing the TLS blocks with a previous thread. > * lsan needs TCB for pointers into pthread_setspecific regions. > > See https://maskray.me/blog/2021-02-14-all-about-thread-local-storage > for details. > > compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp GetTls has > to infer the static TLS bounds from TP, _dl_get_tls_static_info, and > hard-coded TCB sizes. Currently this is somewhat robust for > aarch64/powerpc64/x86-64 but is brittle for many other architectures. > > This patch implements __libc_get_static_tls_bounds@@GLIBC_PRIVATE which > is available in Android bionic since API level 31. This API allows the > sanitizer code to be more robust. _dl_get_tls_static_info@@GLIBC_PRIVATE > can probably be removed when Clang/GCC sanitizers drop reliance on it. > I am unclear whether the version should be GLIBC_2.*. Does this really cover the right memory region? I assume LSAN needs something that identifies pointers to malloc'ed memory that are stored in non-malloc'ed (mmap'ed) memory. The static TLS region is certainly a place where such pointers can be stored. But struct pthread also contains other such pointers: the DTV, the TPP data, and POSIX TLS (pthread_setspecific) data, and struct pthread is not obviously part of the static TLS region. Thanks, Florian