From patchwork Sat Feb 4 02:34:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos O'Donell X-Patchwork-Id: 723988 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vFdB64fchz9s7G for ; Sat, 4 Feb 2017 13:35:09 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="ZQSlWf7k"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:subject:to:cc:message-id:date :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=FlncDb+ZynHHYQAORr9VzzGR7JmwwtOcoC3tTeu4Zj0oT8R+MQOZf hPuYrb3NunR+Hojh9Y1/QWXyReh+smIdeRO6nJyZo30g/aNZ+onOekM/z2bAV471 ULRpsvenOlikhnSL8SaRKs8XjZG78e7uVwtJzSZYTq/4nEc8WhRqJo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:subject:to:cc:message-id:date :mime-version:content-type:content-transfer-encoding; s=default; bh=lSs0m1zz3RqJQ2+Eq7ut3zwK+Rw=; b=ZQSlWf7kLwcMMepfneT+Lj+1XNEB Ts2X3LiP2pPEDmsh3Dbqs1EvcXD3hVacZOpSzoX8gPLiP5lwE9dddicREJHIfr57 KGkLBg2wn7XudnD+dNXszUOwh+hL5I38PByuG6E7yqgry7L2LaJ+XvRbzge/XSWO t2rTukigHzhr0R0= Received: (qmail 51040 invoked by alias); 4 Feb 2017 02:35:01 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 50986 invoked by uid 89); 4 Feb 2017 02:35:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_SORBS_SPAM autolearn=no version=3.3.2 spammy=1376, Fill, sk:tst-tls, sk:tsttls X-HELO: mail-qk0-f170.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:organization:to:cc:message-id:date :user-agent:mime-version:content-transfer-encoding; bh=9UTNkybmA/PtcoFB9swZfeky9zaxbwG9n7dO6Ez24tI=; b=AKpyibJCh5LeFmw01GcIHQI6KxtzpuWivi3uNgfhJ1aclegxAbzzwpl63qMdui6Vi0 ybwPaBF9Uknjt5p0gtkE81ZR9y0guEKbDf/57fhDpWy71lKpvdyGri/B/XCdpGrRlISz 614UipzOpGkjOSd1U55GU3rcEPCnFm0x2I/c5Vqo2PeU/mKG4PKcTZtDywbDVOAaC5M8 Nsxcrsh4U4SfeVKxKm7HvsACqD0q2X9dw+CorcOEWTOcSIrIk+bmCZiAjj9qwabdIYZy lb3wRy2RL4G62tXhMSGuUBCSShJ8Ah6P/qeHS/74Z9aIndREDX+fdIogLuITEMZwQ8/g VJqw== X-Gm-Message-State: AMke39ljZuXdEZ3rlOIRWWp27NkK9S3TTucThBqg5AlWL+ehvtxMMceV0L7r0KEL0j8obqZc X-Received: by 10.55.43.149 with SMTP id r21mr137454qkr.123.1486175688901; Fri, 03 Feb 2017 18:34:48 -0800 (PST) From: Carlos O'Donell Subject: [COMMITTED] Bug 20915: Do not initialize DTV of other threads. To: GNU C Library , Siddhesh Poyarekar Cc: Alexandre Oliva , Florian Weimer Message-ID: <71e7257c-9195-204e-b995-2373709dd0dc@redhat.com> Date: Fri, 3 Feb 2017 21:34:46 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In _dl_nothread_init_static_tls() and init_one_static_tls() we must not touch the DTV of other threads since we do not have ownership of them. The DTV need not be initialized at this point anyway since only LD/GD accesses will use them. If LD/GD accesses occur they will take care to initialize their own thread's DTV. Concurrency comments were removed from the patch since they need to be reworked along with a full description of DTV ownership and when it is or is not safe to modify these structures. Alexandre Oliva's original patch and discussion: https://sourceware.org/ml/libc-alpha/2016-09/msg00512.html I have verified this fix on aarch64, ppc64, ppc64le, and x86_64 with no regressions. The changes fix tst-tls-manydynamic on aarch64, ppc64, ppc64le. I have commited the following patch. 2017-02-03 Alexandre Oliva Florian Weimer Carlos O'Donell [BZ #20915] * elf/dl-reloc.c (_dl_nothread_init_static_tls): Do not initialize DTV. * nptl/allocatestack.c (init_one_static_tls): Likewise. diff --git a/elf/dl-reloc.c b/elf/dl-reloc.c index 52311f0..4ac558d 100644 --- a/elf/dl-reloc.c +++ b/elf/dl-reloc.c @@ -137,12 +137,6 @@ _dl_nothread_init_static_tls (struct link_map *map) # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" #endif - /* Fill in the DTV slot so that a later LD/GD access will find it. */ - dtv_t *dtv = THREAD_DTV (); - assert (map->l_tls_modid <= dtv[-1].counter); - dtv[map->l_tls_modid].pointer.to_free = NULL; - dtv[map->l_tls_modid].pointer.val = dest; - /* Initialize the memory. */ memset (__mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size), '\0', map->l_tls_blocksize - map->l_tls_initimage_size); diff --git a/nptl/allocatestack.c b/nptl/allocatestack.c index 6402ea4..8a228ab 100644 --- a/nptl/allocatestack.c +++ b/nptl/allocatestack.c @@ -1191,11 +1191,6 @@ init_one_static_tls (struct pthread *curp, struct link_map *map) # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined" # endif - /* Fill in the DTV slot so that a later LD/GD access will find it. */ - dtv_t *dtv = GET_DTV (TLS_TPADJ (curp)); - dtv[map->l_tls_modid].pointer.to_free = NULL; - dtv[map->l_tls_modid].pointer.val = dest; - /* Initialize the memory. */ memset (__mempcpy (dest, map->l_tls_initimage, map->l_tls_initimage_size), '\0', map->l_tls_blocksize - map->l_tls_initimage_size);