From patchwork Tue Aug 8 14:50:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 799227 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-82855-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="aDzNMHTH"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xRclY1KmHz9s65 for ; Wed, 9 Aug 2017 00:50:48 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=f7ih8KF0w5QGrWxSDjSGJ1aTnMr7z qWmqrBeahXaLmsvT7kFL6eF3XgwaniVkiSBG/5Kv5Ak5hn/HLleu4dyQi1Z2EhL6 CRW7QAsireZV2PA8GuVJSpk/mdOR6l1kO/BSS0YheX015BTR/4b4CBeLbsncpM7a mwhKIGljOtDRAo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=yAahg6lxhc4vzcCyeqATx81s6xU=; b=aDz NMHTHOpSorGikhcyIQFTmHpsUaIK8XeDWyYj7cQT+IoVK52wqmLsS8QJJA7J+qMH NA/J6DqWlgNLuLSIQo+yf8JyxFO8+gqkvHchaMUyYwUSZTXlDs+GORdczkz+KZcK lFPiS9ixOnAQA3a6rLHSNQUqylMy18prBKjIyddQ= Received: (qmail 37865 invoked by alias); 8 Aug 2017 14:50:42 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 37843 invoked by uid 89); 8 Aug 2017 14:50:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=2529 X-HELO: mx1.suse.de From: Andreas Schwab To: libc-alpha@sourceware.org Subject: [PATCH] Don't use IFUNC resolver for longjmp or system in libpthread (bug 21041) X-Yow: Here I am at the flea market but nobody is buying my urine sample bottles.. Date: Tue, 08 Aug 2017 16:50:37 +0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 Unlike the vfork forwarder and like the fork forwarder as in bug 19861, there won't be a problem when the compiler does not turn this into a tail call. Andreas. * nptl/pt-longjmp.c (longjmp, siglongjmp): Don't use IFUNC resolver. * nptl/pt-system.c (system): Likewise. diff --git a/nptl/pt-longjmp.c b/nptl/pt-longjmp.c index 2ef757e687..8f3c6b3a09 100644 --- a/nptl/pt-longjmp.c +++ b/nptl/pt-longjmp.c @@ -25,21 +25,14 @@ symbol in libpthread, but the historical ABI requires it. For static linking, there is no need to provide anything here--the libc version will be linked in. For shared library ABI compatibility, there must be - longjmp and siglongjmp symbols in libpthread.so; so we define them using - IFUNC to redirect to the libc function. */ + longjmp and siglongjmp symbols in libpthread.so. -#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22) - -# if HAVE_IFUNC - -# undef INIT_ARCH -# define INIT_ARCH() -# define DEFINE_LONGJMP(name) libc_ifunc (name, &__libc_longjmp) - -extern __typeof(longjmp) longjmp_ifunc; -extern __typeof(siglongjmp) siglongjmp_ifunc; + With an IFUNC resolver, it would be possible to avoid the indirection, + but the IFUNC resolver might run before the __libc_longjmp symbol has + been relocated, in which case the IFUNC resolver would not be able to + provide the correct address. */ -# else /* !HAVE_IFUNC */ +#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22) static void __attribute__ ((noreturn, used)) longjmp_compat (jmp_buf env, int val) @@ -47,14 +40,10 @@ longjmp_compat (jmp_buf env, int val) __libc_longjmp (env, val); } -# define DEFINE_LONGJMP(name) strong_alias (longjmp_compat, name) - -# endif /* HAVE_IFUNC */ - -DEFINE_LONGJMP (longjmp_ifunc) -compat_symbol (libpthread, longjmp_ifunc, longjmp, GLIBC_2_0); +strong_alias (longjmp_compat, longjmp_alias) +compat_symbol (libpthread, longjmp_alias, longjmp, GLIBC_2_0); -strong_alias (longjmp_ifunc, siglongjmp_ifunc) -compat_symbol (libpthread, siglongjmp_ifunc, siglongjmp, GLIBC_2_0); +strong_alias (longjmp_alias, siglongjmp_alias) +compat_symbol (libpthread, siglongjmp_alias, siglongjmp, GLIBC_2_0); #endif diff --git a/nptl/pt-system.c b/nptl/pt-system.c index f8ca6ba0d9..b30ddf2b39 100644 --- a/nptl/pt-system.c +++ b/nptl/pt-system.c @@ -25,29 +25,21 @@ libpthread, but the historical ABI requires it. For static linking, there is no need to provide anything here--the libc version will be linked in. For shared library ABI compatibility, there must be a - 'system' symbol in libpthread.so; so we define it using IFUNC to - redirect to the libc function. */ + 'system' symbol in libpthread.so. -#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22) - -# if HAVE_IFUNC - -extern __typeof(system) system_ifunc; -# undef INIT_ARCH -# define INIT_ARCH() -libc_ifunc (system_ifunc, &__libc_system) + With an IFUNC resolver, it would be possible to avoid the indirection, + but the IFUNC resolver might run before the __libc_system symbol has + been relocated, in which case the IFUNC resolver would not be able to + provide the correct address. */ -# else /* !HAVE_IFUNC */ +#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22) static int __attribute__ ((used)) system_compat (const char *line) { return __libc_system (line); } -strong_alias (system_compat, system_ifunc) - -# endif /* HAVE_IFUNC */ - -compat_symbol (libpthread, system_ifunc, system, GLIBC_2_0); +strong_alias (system_compat, system_alias) +compat_symbol (libpthread, system_alias, system, GLIBC_2_0); #endif