Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1234858ybe; Wed, 11 Sep 2019 11:30:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqwM2m4kMC/fmfiTOpR39knYWy7GC99U+V0FQNQ1nmAPDGkBjkLN5R2MzS1oz5bSPyh8WCmi X-Received: by 2002:a50:9eee:: with SMTP id a101mr15562536edf.128.1568226623311; Wed, 11 Sep 2019 11:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568226623; cv=none; d=google.com; s=arc-20160816; b=IfIbFUQoeo0V/zpyZFUwTKiyA8T8TBY4ZcnJo0xfhZoytx/QTwK+FfXNJa4LM6K5sU VruyP7NmtfXSCSdxwxT30YKSN9/AY/dVjtmodq1vy7OcXy4FmKQXmlEeCop517hp/eRX mcfVq0JEUg9XKWraPRU7Xyl8+7WklTLvHAfT2r1Rit0lypMjzvizr3nanmiRYwMObAsG 9NeBPgkGD/sRM4ibbrq19UeEOls6wjylOlMzsWkB1mkc5M3xG0r/Ucoybhbtnxl5tr9b Jhox3SBN+gl7MaxZ69ReKB7aon8Y/RhleVEXhXTbcGxV4mEKuUVhdQE9eZhS1aTlYdnN +2rw== 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=osesdj1snNsWVoqFuQIQ2o5WCFkE8NszrFrfokn+U/g=; b=AjSgyHNPNwtvc8fLE5UL2fRPRn329IaJpGrjOvWguHgbI0/l0cCd7NYKsHyHmVD5+6 xAijpidbtHywkV4am917ORMpHAqFYg0OYMLYfqxUyvjPyq5cFykJmA9dWNvF9wdLw2Wx g7n6CMu2RlokAWcPmLodWbaZwEXrT4debqi6dr4If3u/ulDB7J7GKf3RgSeh+GCH/2/U xiJR1P7uMixaEaUrWk8Onfs9cMLLBlDGeSdGKIoABJtWIwYnfheKw2nPHeNgQWAiPfd3 LQHgZtIq+63JLJx+5r498XprZFTMY62FVeIzDNDf3KC7wBfnwcRRDeCyY0zjeshHwNdM l1lw== 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 v5si10971606edf.92.2019.09.11.11.29.59; Wed, 11 Sep 2019 11:30:23 -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 S1730104AbfIKS0g (ORCPT + 99 others); Wed, 11 Sep 2019 14:26:36 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43328 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728198AbfIKS0g (ORCPT ); Wed, 11 Sep 2019 14:26:36 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E4FFF8AC6FB; Wed, 11 Sep 2019 18:26:34 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 868C919C6A; Wed, 11 Sep 2019 18:26:28 +0000 (UTC) From: Florian Weimer To: Mathieu Desnoyers Cc: Carlos O'Donell , Joseph Myers , Szabolcs Nagy , libc-alpha@sourceware.org, Thomas Gleixner , Ben Maurer , Peter Zijlstra , "Paul E. McKenney" , Boqun Feng , Will Deacon , Dave Watson , Paul Turner , Rich Felker , linux-kernel@vger.kernel.org, linux-api@vger.kernel.org Subject: Re: [PATCH glibc 2.31 1/5] glibc: Perform rseq(2) registration at C startup and thread creation (v12) References: <20190807142726.2579-1-mathieu.desnoyers@efficios.com> <20190807142726.2579-2-mathieu.desnoyers@efficios.com> Date: Wed, 11 Sep 2019 20:26:21 +0200 In-Reply-To: <20190807142726.2579-2-mathieu.desnoyers@efficios.com> (Mathieu Desnoyers's message of "Wed, 7 Aug 2019 10:27:22 -0400") Message-ID: <8736h2sn8y.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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Wed, 11 Sep 2019 18:26:35 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Mathieu Desnoyers: > +#ifdef SHARED > + if (rtld_active ()) > + { > + /* Register rseq ABI to the kernel. */ > + (void) rseq_register_current_thread (); > + } > +#else I think this will need *another* check for the inner libc in an audit module. See what we do in malloc. __libc_multiple_libcs is supposed to cover that, but it's unfortunately not reliable. I believe without that additional check, the first audit module we load will claim rseq, and the main program will not have control over the rseq area. Reversed roles would be desirable here. In October, I hope to fix __libc_multiple_libcs, and then you can use just that. (We have a Fedora patch that is supposed to fix it, I need to documen the mechanism and upstream it.) > +/* Advertise Restartable Sequences registration ownership across > + application and shared libraries. > + > + Libraries and applications must check whether this variable is zero or > + non-zero if they wish to perform rseq registration on their own. If it > + is zero, it means restartable sequence registration is not handled, and > + the library or application is free to perform rseq registration. In > + that case, the library or application is taking ownership of rseq > + registration, and may set __rseq_handled to 1. It may then set it back > + to 0 after it completes unregistering rseq. > + > + If __rseq_handled is found to be non-zero, it means that another > + library (or the application) is currently handling rseq registration. > + > + Typical use of __rseq_handled is within library constructors and > + destructors, or at program startup. */ > + > +int __rseq_handled; Are there any programs that use __rseq_handled *today*? I'm less convinced that we actually need this. I don't think we have ever done anything like that before, and I don't think it's necessary. Any secondary rseq library just needs to note if it could perform registration, and if it failed to do so, do not perform unregistration in a pthread destructor callback. Sure, there's the matter of pthread destructor ordering, but that problem is not different from any other singleton (thread-local or not), and the fix for the last time this has come up (TLS destructors vs dlclose) was to upgrade glibc. Thanks, Florian