Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp980034ybi; Fri, 14 Jun 2019 06:39:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwHDWDfHVgjYHjyxVg8jO5bEOOeqB76hofG41Kw9S8SW2jjr7vckOq/x9vLpFUjFCY4R1eQ X-Received: by 2002:a63:480a:: with SMTP id v10mr9279439pga.60.1560519592963; Fri, 14 Jun 2019 06:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560519592; cv=none; d=google.com; s=arc-20160816; b=q3jJzbTifIii1bCzuXIJnY9n8ei512Oa4dPCPiGzVvwxjZMWl+aMwWBH0yrBPp6E4T +ha4rnFQ4SfzZddmhYGIonVrPAHJmYQVCtxSnZNueAaTV7/i4mQUdvucsofgB4oD6JfW b1IgttcakjDdM/oXO65XbGmEMXh/8kaHbJ8PHmCYkIcdNWVsNLe2ak7rhwb6e5xJpxh0 G8KilNnDl3mNwin9xB9rUnmw3YmHTm4crOmNHxco5gvHzLxdd7y7n4R2wWvQAio4LO+X E41SuDZSg0ZlN6/bGYZykiwCuj8ojhMEjmFzSLZ0nq9HLIs3LNUCUNjdt1P69GlHdcXo ZB2w== 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=g11SeW4F7paEUETkOqOR7pC/7HcUtfs8xDR7RV9Lcyc=; b=gYc37mQZsSnTKKA9LMwuwnkvIdN6i9axXtmTDW/rfxGhadASVv4urLtQ4KULMKo3Wc OLg5Kfrok9kOX4DjkujFXzLwI9wi4eH+xp/AkvAml6Nlky0jIoMZS9U1QZ9R+e3yk6f9 88eA3RKVB5TDibc2Q24SYe0bSLsP0lfBsU8HLEbtyyv+VkUnShtI8sXbLAcqJtvpIrWc TPuLrQSlTUWjPslC0vQ0Qlz2x23e7DfjWHyUbHUjwTsg8rHbiLb77WPVvuJqAtnNUImR piAAVTA9UyPw2OYgETQWbnra9A32VOJjMvmfkFvTBM3BnUxBVvY7JCi8wxYZ1mUcHjrb E7yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@efficios.com header.s=default header.b=bmoEbTEo; 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 a23si947445pls.189.2019.06.14.06.39.37; Fri, 14 Jun 2019 06:39:52 -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=bmoEbTEo; 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 S1728202AbfFNNjN (ORCPT + 99 others); Fri, 14 Jun 2019 09:39:13 -0400 Received: from mail.efficios.com ([167.114.142.138]:41242 "EHLO mail.efficios.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727808AbfFNNjN (ORCPT ); Fri, 14 Jun 2019 09:39:13 -0400 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id A563B251635; Fri, 14 Jun 2019 09:39:11 -0400 (EDT) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id GnCFb0jxdTlM; Fri, 14 Jun 2019 09:39:11 -0400 (EDT) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 3112D25162D; Fri, 14 Jun 2019 09:39:11 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 3112D25162D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1560519551; bh=g11SeW4F7paEUETkOqOR7pC/7HcUtfs8xDR7RV9Lcyc=; h=Date:From:To:Message-ID:MIME-Version; b=bmoEbTEoy8FbWGZKWm4OIDeztip9KPC7WHuudiL4/WygRNBbB7MHLq6cp/Q82/u6s MZIRFg9ankQrHB1IzwB0XutT1gJsfq6AbpKOJKLnxO6d2R2CG6Ip36uB8VWPKzR8tl ekw891XGCbzwWZuE0IGxHiJARWkEVrp8Oges+tXqhNN7+jmCWR+/WaiU1mj2l0iG9H i5JJ5gPseoFn5cp5Py420JTHRMp/OnxxyDNLeWQ1xEkbMDtS5/J9FMaSCCaACvg6zA MoMmMPoqcmd/uqWeo24R6bn/rV/DTXW1kLtdZDyl2G+Prz6V9YKvKfw3Sa1On3BbqL j9mOh7xxX9GqQ== 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 A4nfGl2sb7Zt; Fri, 14 Jun 2019 09:39:11 -0400 (EDT) Received: from mail02.efficios.com (mail02.efficios.com [167.114.142.138]) by mail.efficios.com (Postfix) with ESMTP id 176B2251626; Fri, 14 Jun 2019 09:39:11 -0400 (EDT) Date: Fri, 14 Jun 2019 09:39:10 -0400 (EDT) From: Mathieu Desnoyers To: David Laight Cc: Florian Weimer , 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: <1503067753.3387.1560519550939.JavaMail.zimbra@efficios.com> In-Reply-To: <69a53ec2ce184af29c4cae58e0b2fb57@AcuMS.aculab.com> References: <20190503184219.19266-1-mathieu.desnoyers@efficios.com> <802638054.3032.1560506584705.JavaMail.zimbra@efficios.com> <87ftocwkei.fsf@oldenburg2.str.redhat.com> <1635690189.3049.1560507249693.JavaMail.zimbra@efficios.com> <87tvcsv1pk.fsf@oldenburg2.str.redhat.com> <1190407525.3131.1560516910936.JavaMail.zimbra@efficios.com> <1085273942.3137.1560517301721.JavaMail.zimbra@efficios.com> <69a53ec2ce184af29c4cae58e0b2fb57@AcuMS.aculab.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: AdUitTFqJqb3c4uCSB28nMsheH09dGcCn4Ez Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org ----- On Jun 14, 2019, at 3:29 PM, David Laight David.Laight@ACULAB.COM wrote: > From: Mathieu Desnoyers >> Sent: 14 June 2019 14:02 > ... >> But my original issue remains: if I define a variable called __rseq_handled >> within either the main executable or the preloaded library, it overshadows >> the libc one: > > 1) That is the was elf symbol resolution is required to work. > Otherwise variables like 'errno' (non-thread safe form) wouldn't work. > > 2) Don't do it then :-) > Names starting with __ will be reserved (probably 'for the implementation'). > > The real 'fun' starts because, under some circumstances, looking up a symbol as: > foo = dlsym(lib_handle, "foo"); > Can find the data item instead of the function! > Usually it works (even when foo is global data) because 'lib_handle' refers > to a different symbol table. > But it can go horribly wrong. I was setting __rseq_handled too soon, before re-relocation of the dynamic linker. I moved the initialization after re-relocation and it works fine now. The purpose of __rseq_handled is to allow early adopter libraries and applications to define their own global instance of the symbol, and check whether the libc they are linked against handle rseq registration or not. libc specifies the layout of that variable (an integer). The dynamic linker chooses one of those instances so it's used in the global symbol table of the program. The important thing is that all libraries agree on that global symbol. Of course this is not compatible with libraries compiled with forced "hidden" symbols only. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. http://www.efficios.com