Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp280724ybi; Fri, 31 May 2019 01:08:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSqD/u8GVw//zidCUD93s7d6OyGJaz4bjbI7Jva9ActZmeYFrU2XTNOmSZn4puoDOmL5KY X-Received: by 2002:a62:ea0a:: with SMTP id t10mr8137921pfh.236.1559290113587; Fri, 31 May 2019 01:08:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559290113; cv=none; d=google.com; s=arc-20160816; b=Rnt9t35h0WlIYbyUu3f+vgZ1w7C/TpGeevTNmLYX4HlVLFUd/S3mP9E3xvD3BdVfQB CKC4nWF+0H+gZXUytUGyXo95jiKII1nprzXezJgbjw53PTYBtEv5PeuLZ35B5EWFnvwq xJgmldzPBvU9JTd//mmDczggT/2efgKqYtx/V/BJan/E987S0w0pqMBHcCHBjn8eR3Rq U7Sq4Sf8aF+yPSVDRWFWVexeQAHmJxGP+HXOEuQo8zJC9zhwFj2us2bwnX4OSYDqoDhS oKyImp4q5KwWIrOJpeCEBZT/qroWsgiVIJLBRkoz1nLYSipOeoXdLbnqizOFMZjI5opD lbtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=hhA8QpDfCelLX0Sqv4Hqf8PATL3Tn6pddYbSVSI7k+o=; b=STnplA/VW89SWcWbv7iyQpZ2eOWYJk+CLLztBNGyiDvxrk+XhstNz+iW/3NMoSluk5 V21TbKtJAp8v2isCrwGFGKtMd/6bqgZv3WgYvd44yG/Ye3z/Qf2uqNRtmtf52RVCZDz7 girNJI8nR7zxYgysCwpAskxjvUxhEge1U/njU12vpBPsivYVUats9ieWkWvb+sk4MDdo m2FqUEltKRiD770BBhEpQhDACVw/o23dWZDi9/2V+d8+n64iUGqDJXxFcGLpk8EpwFnK HjYs6esOfNv3tVu2MnfRo3UCVQK0zhLeZ0+v5pO55ZmhXRoSzRooOHfH6rVu5RE30Gju JTrg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o10si5456563pfo.196.2019.05.31.01.08.16; Fri, 31 May 2019 01:08:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726947AbfEaIGc (ORCPT + 99 others); Fri, 31 May 2019 04:06:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44826 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726724AbfEaIGc (ORCPT ); Fri, 31 May 2019 04:06:32 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8AAEE30C31B7; Fri, 31 May 2019 08:06:31 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-116-86.ams2.redhat.com [10.36.116.86]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 49EDA5126B; Fri, 31 May 2019 08:06:21 +0000 (UTC) From: Florian Weimer To: Mathieu Desnoyers Cc: carlos , Joseph Myers , Szabolcs Nagy , libc-alpha , Thomas Gleixner , Ben Maurer , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Will Deacon , Dave Watson , Paul Turner , Rich Felker , linux-kernel , linux-api Subject: Re: [PATCH 1/5] glibc: Perform rseq(2) registration at C startup and thread creation (v10) References: <20190503184219.19266-1-mathieu.desnoyers@efficios.com> <20190503184219.19266-2-mathieu.desnoyers@efficios.com> <87h89gjgaf.fsf@oldenburg2.str.redhat.com> <1239705947.14878.1558985272873.JavaMail.zimbra@efficios.com> <140718133.18261.1559144710554.JavaMail.zimbra@efficios.com> <2022553041.20966.1559249801435.JavaMail.zimbra@efficios.com> Date: Fri, 31 May 2019 10:06:19 +0200 In-Reply-To: <2022553041.20966.1559249801435.JavaMail.zimbra@efficios.com> (Mathieu Desnoyers's message of "Thu, 30 May 2019 16:56:41 -0400 (EDT)") Message-ID: <875zprm4jo.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Fri, 31 May 2019 08:06:31 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Mathieu Desnoyers: > I found that it's because touching a __thread variable from > ld-linux-x86-64.so.2 ends up setting the DF_STATIC_TLS flag > for that .so, which is really not expected. > > Even if I tweak the assert to make it more lenient there, > touching the __thread variable ends up triggering a SIGFPE. Sorry, I got distracted at this critical juncture. Yes, I forgot that there isn't TLS support in the dynamic loader today. > So rather than touching the TLS from ld-linux-x86-64.so.2, > I've rather experimented with moving the rseq initialization > for both SHARED and !SHARED cases to a library constructor > within libc.so. > > Are you aware of any downside to this approach ? The information whether the kernel supports rseq would not be available to IFUNC resolvers. And in some cases, ELF constructors for application libraries could run before the libc.so.6 constructor, so applications would see a transition from lack of kernel support to kernel support. > +static > +__attribute__ ((constructor)) > +void __rseq_libc_init (void) > +{ > + rseq_init (); > + /* Register rseq ABI to the kernel. */ > + (void) rseq_register_current_thread (); > +} I think the call to rseq_init (and the __rseq_handled variable) should still be part of the dynamic loader. Otherwise there could be confusion about whether glibc handles the registration (due the constructor ordering issue). Thanks, Florian