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 [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 9D537385802A for ; Sat, 2 Jan 2021 08:24:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9D537385802A 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-324-poJy5BmQNNOTnwS1PrxBCw-1; Sat, 02 Jan 2021 03:24:20 -0500 X-MC-Unique: poJy5BmQNNOTnwS1PrxBCw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 16730180A094; Sat, 2 Jan 2021 08:24:19 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-112-104.ams2.redhat.com [10.36.112.104]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 22B4D100164C; Sat, 2 Jan 2021 08:24:17 +0000 (UTC) Date: Sat, 2 Jan 2021 09:24:15 +0100 From: Jan Kratochvil To: Florian Weimer Cc: Jan Kratochvil via Libc-alpha Subject: Re: [patch] Make _thread_db_sizeof_pthread public for Sanitizers Message-ID: <20210102082415.GA474645@host1.jankratochvil.net> References: <20210101100818.GA368024@host1.jankratochvil.net> <87sg7kesl8.fsf@mid.deneb.enyo.de> MIME-Version: 1.0 In-Reply-To: <87sg7kesl8.fsf@mid.deneb.enyo.de> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Sat, 02 Jan 2021 08:24:26 -0000 On Fri, 01 Jan 2021 13:42:43 +0100, Florian Weimer wrote: > Do you know why the GetTLS function needs to know the size of the > thread descriptor? And why it adds it to the start address of the TLS > area, without subtracting it from the area size? I think this > identifies the wrong memory region as TLS. I do not know the memory layout of glibc TLSes (all of their kinds there are). I just find my proposed fix a better one than to play the catch-up with each glibc version. If you can find some better fix I sure welcome it. https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp#L468 https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cpp#L237 = static void GetTls(uptr *addr, uptr *size) { #if defined(__x86_64__) || defined(__i386__) || defined(__s390__) *addr = ThreadSelf(); *size = GetTlsSize(); // get_tls_static_info_ptr()->dl_tls_static_size *addr -= *size; *addr += ThreadDescriptorSize(); Jan