Date: Friday, September 8, 2017 @ 12:20:46 Author: bpiotrowski Revision: 305066
2.26-3 Don't use IFUNC resolver for longjmp or system in libpthread (FS#55220) Added: glibc/trunk/0001-Don-t-use-IFUNC-resolver-for-longjmp-or-system-in-li.patch Modified: glibc/trunk/PKGBUILD -----------------------------------------------------------------+ 0001-Don-t-use-IFUNC-resolver-for-longjmp-or-system-in-li.patch | 110 ++++++++++ PKGBUILD | 11 - 2 files changed, 118 insertions(+), 3 deletions(-) Added: 0001-Don-t-use-IFUNC-resolver-for-longjmp-or-system-in-li.patch =================================================================== --- 0001-Don-t-use-IFUNC-resolver-for-longjmp-or-system-in-li.patch (rev 0) +++ 0001-Don-t-use-IFUNC-resolver-for-longjmp-or-system-in-li.patch 2017-09-08 12:20:46 UTC (rev 305066) @@ -0,0 +1,110 @@ +From fc5ad7024c620cdfe9b76e94638aac83b99c5bf8 Mon Sep 17 00:00:00 2001 +From: Andreas Schwab <sch...@suse.de> +Date: Tue, 8 Aug 2017 16:21:58 +0200 +Subject: [PATCH] Don't use IFUNC resolver for longjmp or system in libpthread + (bug 21041) + +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. +--- + nptl/pt-longjmp.c | 31 ++++++++++--------------------- + nptl/pt-system.c | 24 ++++++++---------------- + 3 files changed, 18 insertions(+), 37 deletions(-) + +diff --git a/nptl/pt-longjmp.c b/nptl/pt-longjmp.c +index 2ef757e687f..8f3c6b3a09f 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 f8ca6ba0d94..b30ddf2b398 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 +-- +2.14.1 + Modified: PKGBUILD =================================================================== --- PKGBUILD 2017-09-08 12:20:39 UTC (rev 305065) +++ PKGBUILD 2017-09-08 12:20:46 UTC (rev 305066) @@ -7,7 +7,7 @@ pkgname=glibc pkgver=2.26 -pkgrel=2 +pkgrel=3 pkgdesc='GNU C Library' arch=(i686 x86_64) url='http://www.gnu.org/software/libc' @@ -24,10 +24,12 @@ _commit=58270c0049404ef2f878fdd45df55f17f0b8c1f7 source=(git+https://sourceware.org/git/glibc.git#commit=${_commit} locale.gen.txt - locale-gen) + locale-gen + 0001-Don-t-use-IFUNC-resolver-for-longjmp-or-system-in-li.patch) md5sums=('SKIP' '07ac979b6ab5eeb778d55f041529d623' - '476e9113489f93b348b21e144b6a8fcf') + '476e9113489f93b348b21e144b6a8fcf' + 'cbc073315c00b03898b7fc614274d6b3') # pkgver() { # cd glibc @@ -36,6 +38,9 @@ prepare() { mkdir -p glibc-build + + cd glibc + patch -p1 -i "$srcdir/0001-Don-t-use-IFUNC-resolver-for-longjmp-or-system-in-li.patch" } build() {