From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12864 Path: news.gmane.org!.POSTED!not-for-mail From: Phillip Berndt Newsgroups: gmane.linux.lib.musl.general Subject: Re: TLS issue on aarch64 Date: Thu, 31 May 2018 17:22:57 +0200 Message-ID: References: <20180525145059.GG4418@port70.net> <20180526005415.GI4418@port70.net> <20180527003430.GG1392@brightrain.aerifal.cx> <20180528204730.GJ4418@port70.net> <20180528221521.GI1392@brightrain.aerifal.cx> <20180529063316.GK4418@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1527780065 9678 195.159.176.226 (31 May 2018 15:21:05 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 31 May 2018 15:21:05 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-12880-gllmg-musl=m.gmane.org@lists.openwall.com Thu May 31 17:21:01 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1fOPNt-0002Oj-49 for gllmg-musl@m.gmane.org; Thu, 31 May 2018 17:21:01 +0200 Original-Received: (qmail 25634 invoked by uid 550); 31 May 2018 15:23:10 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 25616 invoked from network); 31 May 2018 15:23:09 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=0psmNwhecgyhfrhRDdt3ABWmhFmsWn3aN+uDUikW/50=; b=l9ms/3bbsm4qdhMXuZp0Gx5yotLF2BkJyXhBIPIoHZs2+ZE4LomgpYYemPHnpwZirE HZiIc9mTqMfGxjRVQWiNcJkkalFdfvrDKuQfbcbLp1a9pUozybsQEm+GgEkOhITl76Wy wxOfcT8CGqoDcSrBMHIUF7x3BsiSqUURDbJ6wXMqSyT7st3d48tCqAh0x77//2NLg34A HnDzT7lYjI26WqHU7NxeAx4EYoTnF6NVQACJ5IhyeC9iZANDo39outQlZmHCTzROdLN0 aWni+eIqqUkHiy6U4yVf7KnVCtjB19DSvQogy13n3J5Pg8Vu1wCTga+mjZTbzsf6odJ9 XRZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=0psmNwhecgyhfrhRDdt3ABWmhFmsWn3aN+uDUikW/50=; b=LZ2z7FBPC91z28I1GsMuybMR0dRmljUKhfWrE7iTJwYLlWkkMX7JoKE6UiOZHxqUEQ Dikc2o2vhdtauhSYPe/rEZjoI1q+ORnLYZbXDGZC0s0Fo5S5eaQdtFgQ5vWWhV/bdEgo Wjr6R3eyPB9egRyYKmFR3vyLGOPmGADArV9u8IVTjoQDdOXmFN6/0sHx97M3Ptw9bWDX 98Nnknz4CkzY6PohQqs6IVr6osErUbFKymPHU/NzRMiDTl/++30DcYsoJiqAQLhlEd1p Q6RkfXN6SjOsmpLo2rxcspz4EvmRH1WMF5jg5mCK79GuZ7J3v9O80/13dE9LKCpMymGP 1eXg== X-Gm-Message-State: ALKqPwf+FPTWDFXn+herRDg6lb21FEMcfvxzOLydiffjj0jf/MMTxO/n iKuw8COF6tiEhbQB96qsTct5a4ovGu39+r9RGinyFmmE X-Google-Smtp-Source: ADUXVKI4OAsZqciAKR/NKm06YFsUFywQ+00ppDWl3W/Tv8tRK/9Yfr9GD+iLimPHeVpcx4RvfuxOB4WVjPRNomMzxZ0= X-Received: by 2002:a2e:1d53:: with SMTP id d80-v6mr5757774ljd.104.1527780177819; Thu, 31 May 2018 08:22:57 -0700 (PDT) In-Reply-To: <20180529063316.GK4418@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:12864 Archived-At: Regarding the interaction with dynamic TLS: I can't get dynamically linked programs to work at all with musl 1.1.19. The third stage of the dynamic linker initializes the thread pointer with the built-in TLS before doing anything else. But again, the pointer doesn't end up where it's supposed to: (gdb) p &builtin_tls.pt $2 = (struct __pthread *) 0x5555642828 (gdb) p __pthread_self() $5 = (struct __pthread *) 0x5555642810 Since this is the wrong address, the pthread structure isn't actually zero-initialized, which for me means that the cancel state is non-zero, which means that the linker exits at the first syscall (because __syscall_cp_c() does that for canceled pthreads). I've got a musl 1.1.18 dynamic linker flying around that at least doesn't fail to start programs. Your discussion of dynamically linked objects got me interested, so I wanted to see what happens if I run a program using TLS in the main program, TLS from a statically linked library, TLS from a dynamically linked library, and TLS from a shared library opened by dlopen(), all at the same time. Here's what happens: [ main] 0x0x415ff0: 0 [ SO_dlopen] 0x0x415ff0: 0 [ SO_linked] 0x0x415ff0: 0 [ static] 0x0x416ff0: 0 ..note that all four variables have differently named symbols, they should not end up at the same location. All should be page-aligned and have non-zero values. >From what I can see, Szabolcs's patch still does the right thing for statically linked applications. Those can't use dlopen() anyway. Would it hence be an option to proceed with his patch, and fix dynamically linked programs in the next step? - Phillip