Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5937624ybi; Wed, 12 Jun 2019 11:02:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxnVPRbzPP2ZEnnm+AQPsYzTgcgyhdaNhkFcKZPK+FparGeD+SYeb+pb6lO3oeRoC9Qt63x X-Received: by 2002:a62:ce07:: with SMTP id y7mr59064589pfg.12.1560362528382; Wed, 12 Jun 2019 11:02:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560362528; cv=none; d=google.com; s=arc-20160816; b=snx0atI9XKaGkwyKYf/HIg4nUzyUujdygT5mVrg09yB+RJDVJ5Z/lkzO2mM080eOII jZzAQU5pJTFBaJn0MSNOWhHla07XrFq8Y4DeOugrFKSfj5aunw2pzlEKqKHpzhNNiK2S N7PzGUy0Ehv8git4HOmxNdM9iXAYd447tjjwFam8bnaVNuzKD8UGb5+1vhvbSjXZfoF2 UVw6J3l94dUBqVvTiIYIu9QuovrrcE7L4+ApRCvQxGqmJAfq0+xgI4DMdc1PiGxaofG8 YYTjXD02GJY7UiFykYKbCEQ7iuOwjbGEITQfFBl664XrWP9HUQm0xDQIBw+FdSZQcnqt 6oiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:dkim-signature:dkim-filter; bh=CQJvFqLWHjpXxyGISC4bp4dzIRicyxqlzHNr21zpE6c=; b=WiU74Eqkju1fZqP7NxH1aT990vTGzU1RZUCGu/093pR5q3oywAw0Z36FEsm7tuDEqO d0GCmozJ/48+CuXdqs0Qrm4bjCyKoYPmtq+x5fiLBjtiHe6S0pg63BdnNYM247blh9At Tcr50OyhZO5vi+23GuZKJ+0OpdtPPNf2U/dXsVzaIlGeKiGWaJGDJvgLjxUcLz/DvJum Bxlg3PRclcBvKEHXjx9aGXSXNZxCSp89TGdYoxFwJs9qul/uYW2SyCVqjCNoOPpZCwnC 7LOk9JHjokTOG2THZMm3cpGFUzOuwTnKZQ46ulVy4rZZbq+3fbqGgIU4f83BV8kR78Im EB0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=q33EV28k; 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=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q35si407771pgm.565.2019.06.12.11.01.52; Wed, 12 Jun 2019 11:02:08 -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; dkim=pass header.i=@efficios.com header.s=default header.b=q33EV28k; 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=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437505AbfFLOgG (ORCPT + 99 others); Wed, 12 Jun 2019 10:36:06 -0400 Received: from mail.efficios.com ([167.114.142.138]:54476 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726840AbfFLOgG (ORCPT ); Wed, 12 Jun 2019 10:36:06 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 8911D249436; Wed, 12 Jun 2019 10:36:04 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id lj07YLCufUMI; Wed, 12 Jun 2019 10:36:03 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 5599B24942E; Wed, 12 Jun 2019 10:36:03 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 5599B24942E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1560350163; bh=CQJvFqLWHjpXxyGISC4bp4dzIRicyxqlzHNr21zpE6c=; h=Date:From:To:Message-ID:MIME-Version; b=q33EV28kaNy1/vmwbhSQwXx5/2HYtlLIrgzGsf17zDqgBPwm+IgEW5rqsJWmfAWI9 nFa53eojvq5rojoCsVg3pdaYCesQAEsSSWolBHdDaR40KlaoSPOtR7PojlDH0uHiMW fwn5MfPk/sIQysQe0J2I2FPqVXOlVzIBVmiOpOCLlcJN130xde0kaPlT8SuNY83tSO 5Iipld3BzRO5V/FA/lnKTC6o5hsWI0lJ7iaddqf1GaYnprFBYANpExfZnQ7Pw9iIMO /tWdrX2lJVRXxstD27aqInD6EO7tHO7rfLeAsLe5cjb9/mfQnxCZGGKojz4TxOvGoD 4jRHQSEjds9wA== X-Virus-Scanned: amavisd-new at efficios.com Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id YBV3Ug4T_Nce; Wed, 12 Jun 2019 10:36:03 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id 3D439249426; Wed, 12 Jun 2019 10:36:03 -0400 (EDT) Date: Wed, 12 Jun 2019 10:36:03 -0400 (EDT) From: Mathieu Desnoyers To: Florian Weimer 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 Message-ID: <512441263.43096.1560350163180.JavaMail.zimbra@efficios.com> In-Reply-To: <87blz27uio.fsf@oldenburg2.str.redhat.com> References: <20190503184219.19266-1-mathieu.desnoyers@efficios.com> <87muj2k4ov.fsf@oldenburg2.str.redhat.com> <1528929896.22217.1559326257155.JavaMail.zimbra@efficios.com> <87o93d4lqb.fsf@oldenburg2.str.redhat.com> <117220011.27079.1559663870037.JavaMail.zimbra@efficios.com> <87wohzorj0.fsf@oldenburg2.str.redhat.com> <1329439108.43041.1560348962006.JavaMail.zimbra@efficios.com> <87blz27uio.fsf@oldenburg2.str.redhat.com> Subject: Re: [PATCH 1/5] glibc: Perform rseq(2) registration at C startup and thread creation (v10) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Originating-IP: [167.114.142.138] X-Mailer: Zimbra 8.8.12_GA_3803 (ZimbraWebClient - FF67 (Linux)/8.8.12_GA_3794) Thread-Topic: glibc: Perform rseq(2) registration at C startup and thread creation (v10) Thread-Index: QXw97AD98r6EHKvsnZ7iwPC2gI7hig== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Jun 12, 2019, at 4:22 PM, Florian Weimer fweimer@redhat.com wrote: > * Mathieu Desnoyers: > >>> It's the registration from libc.so which needs some care. In >>> particular, we must not override an existing registration. >> >> OK, so it could check if __rseq_abi.cpu_id is -1, and only >> perform registration if it is the case. Or do you have another >> approach in mind ? > > No, __rseq_abi will not be shared with the outer libc, so the inner libc > will always see -1 there, even if the outer libc has performed > registration. > > libio/vtables.c has some example what you can do: > > /* In case this libc copy is in a non-default namespace, we always > need to accept foreign vtables because there is always a > possibility that FILE * objects are passed across the linking > boundary. */ > { > Dl_info di; > struct link_map *l; > if (!rtld_active () > || (_dl_addr (_IO_vtable_check, &di, &l, NULL) != 0 > && l->l_ns != LM_ID_BASE)) > return; > } > > _IO_vtable_check would have to be replaced with your own function; the > actual function doesn't really matter. > > The rtld_active check covers the static dlopen case, where > rtld_active () is false in the inner libc. Then out of curiosity, would it also work if I check for if (!__libc_multiple_libcs) in LIBC_START_MAIN ? Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com