* [2.25 COMMITTED 1/3] Don't use IFUNC resolver for longjmp or system in libpthread (bug 21041)
@ 2017-01-01 0:00 Aurelien Jarno
2017-01-01 0:00 ` [2.25 COMMITTED 2/3] Fix s390 version of pt-longjmp.c Aurelien Jarno
2017-01-01 0:00 ` [2.25 COMMITTED 3/3] Add test for bug 21041 Aurelien Jarno
0 siblings, 2 replies; 3+ messages in thread
From: Aurelien Jarno @ 2017-01-01 0:00 UTC (permalink / raw)
To: libc-stable; +Cc: Andreas Schwab
From: Andreas Schwab <schwab@suse.de>
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.
(cherry picked from commit fc5ad7024c620cdfe9b76e94638aac83b99c5bf8)
---
ChangeLog | 6 ++++++
nptl/pt-longjmp.c | 31 ++++++++++---------------------
nptl/pt-system.c | 24 ++++++++----------------
3 files changed, 24 insertions(+), 37 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 687fd20c46..3cf3c8013c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-08-08 Andreas Schwab <schwab@suse.de>
+
+ [BZ #21041]
+ * nptl/pt-longjmp.c (longjmp, siglongjmp): Don't use IFUNC resolver.
+ * nptl/pt-system.c (system): Likewise.
+
2017-10-13 James Clarke <jrtc27@jrtc27.com>
* sysdeps/powerpc/powerpc32/dl-machine.h (elf_machine_rela):
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
--
2.15.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [2.25 COMMITTED 2/3] Fix s390 version of pt-longjmp.c
2017-01-01 0:00 [2.25 COMMITTED 1/3] Don't use IFUNC resolver for longjmp or system in libpthread (bug 21041) Aurelien Jarno
@ 2017-01-01 0:00 ` Aurelien Jarno
2017-01-01 0:00 ` [2.25 COMMITTED 3/3] Add test for bug 21041 Aurelien Jarno
1 sibling, 0 replies; 3+ messages in thread
From: Aurelien Jarno @ 2017-01-01 0:00 UTC (permalink / raw)
To: libc-stable; +Cc: Andreas Schwab
From: Andreas Schwab <schwab@suse.de>
(cherry picked from commit 5797b410a87f6f6f6d3661d730fac320cbd5f270)
---
ChangeLog | 5 +++++
sysdeps/unix/sysv/linux/s390/pt-longjmp.c | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 3cf3c8013c..368459008d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2017-08-09 Andreas Schwab <schwab@suse.de>
+
+ * sysdeps/unix/sysv/linux/s390/pt-longjmp.c: Update reference to
+ renamed alias.
+
2017-08-08 Andreas Schwab <schwab@suse.de>
[BZ #21041]
diff --git a/sysdeps/unix/sysv/linux/s390/pt-longjmp.c b/sysdeps/unix/sysv/linux/s390/pt-longjmp.c
index d324237edd..0221ac2cf5 100644
--- a/sysdeps/unix/sysv/linux/s390/pt-longjmp.c
+++ b/sysdeps/unix/sysv/linux/s390/pt-longjmp.c
@@ -26,8 +26,8 @@
/* In glibc release 2.19 new versions of longjmp-functions were introduced,
but were reverted before 2.20. Thus both versions are the same function. */
-strong_alias (longjmp_ifunc, __v2longjmp)
+strong_alias (longjmp_alias, __v2longjmp)
compat_symbol (libpthread, __v2longjmp, longjmp, GLIBC_2_19);
-strong_alias (siglongjmp_ifunc, __v2siglongjmp)
+strong_alias (siglongjmp_alias, __v2siglongjmp)
compat_symbol (libpthread, __v2siglongjmp, siglongjmp, GLIBC_2_19);
#endif /* SHLIB_COMPAT (libpthread, GLIBC_2_19, GLIBC_2_20)) */
--
2.15.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* [2.25 COMMITTED 3/3] Add test for bug 21041
2017-01-01 0:00 [2.25 COMMITTED 1/3] Don't use IFUNC resolver for longjmp or system in libpthread (bug 21041) Aurelien Jarno
2017-01-01 0:00 ` [2.25 COMMITTED 2/3] Fix s390 version of pt-longjmp.c Aurelien Jarno
@ 2017-01-01 0:00 ` Aurelien Jarno
1 sibling, 0 replies; 3+ messages in thread
From: Aurelien Jarno @ 2017-01-01 0:00 UTC (permalink / raw)
To: libc-stable; +Cc: Andreas Schwab
From: Andreas Schwab <schwab@suse.de>
(cherry picked from commit 40c06a3d0450365e9675fe26f34fc56ce8497325)
---
ChangeLog | 10 ++++++++++
nptl/Makefile | 6 ++++--
nptl/tst-compat-forwarder-mod.c | 28 ++++++++++++++++++++++++++++
nptl/tst-compat-forwarder.c | 35 +++++++++++++++++++++++++++++++++++
4 files changed, 77 insertions(+), 2 deletions(-)
create mode 100644 nptl/tst-compat-forwarder-mod.c
create mode 100644 nptl/tst-compat-forwarder.c
diff --git a/ChangeLog b/ChangeLog
index 368459008d..d3c5570239 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2017-08-09 Andreas Schwab <schwab@suse.de>
+
+ * nptl/Makefile (tests) [$(build-shared) = yes]: Add
+ tst-compat-forwarder.
+ (modules-names): Add tst-compat-forwarder-mod.
+ ($(objpfx)tst-compat-forwarder): Depend on
+ $(objpfx)tst-compat-forwarder-mod.so.
+ * nptl/tst-compat-forwarder.c: New file.
+ * nptl/tst-compat-forwarder-mod.c: New file.
+
2017-08-09 Andreas Schwab <schwab@suse.de>
* sysdeps/unix/sysv/linux/s390/pt-longjmp.c: Update reference to
diff --git a/nptl/Makefile b/nptl/Makefile
index 24067768ed..8def69ae22 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -356,7 +356,7 @@ tests += tst-cancelx2 tst-cancelx3 tst-cancelx4 tst-cancelx5 \
tst-oncex3 tst-oncex4
ifeq ($(build-shared),yes)
tests += tst-atfork2 tst-tls3 tst-tls3-malloc tst-tls4 tst-tls5 tst-_res1 \
- tst-fini1 tst-stackguard1
+ tst-fini1 tst-stackguard1 tst-compat-forwarder
tests-nolibpthread += tst-fini1
ifeq ($(have-z-execstack),yes)
tests += tst-execstack
@@ -367,7 +367,7 @@ modules-names = tst-atfork2mod tst-tls3mod tst-tls4moda tst-tls4modb \
tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \
tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \
tst-_res1mod1 tst-_res1mod2 tst-execstack-mod tst-fini1mod \
- tst-join7mod
+ tst-join7mod tst-compat-forwarder-mod
extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \
tst-cleanup4aux.o tst-cleanupx4aux.o
test-extras += $(modules-names) tst-cleanup4aux tst-cleanupx4aux
@@ -705,6 +705,8 @@ $(objpfx)tst-oddstacklimit.out: $(objpfx)tst-oddstacklimit $(objpfx)tst-basic1
$(evaluate-test)
endif
+$(objpfx)tst-compat-forwarder: $(objpfx)tst-compat-forwarder-mod.so
+
# The tests here better do not run in parallel
ifneq ($(filter %tests,$(MAKECMDGOALS)),)
.NOTPARALLEL:
diff --git a/nptl/tst-compat-forwarder-mod.c b/nptl/tst-compat-forwarder-mod.c
new file mode 100644
index 0000000000..823bfa22de
--- /dev/null
+++ b/nptl/tst-compat-forwarder-mod.c
@@ -0,0 +1,28 @@
+/* Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Call the function system through a statically initialized pointer. */
+
+#include <stdlib.h>
+
+int (*system_function) (const char *) = system;
+
+void
+call_system (void)
+{
+ system_function (NULL);
+}
diff --git a/nptl/tst-compat-forwarder.c b/nptl/tst-compat-forwarder.c
new file mode 100644
index 0000000000..f96806b7fe
--- /dev/null
+++ b/nptl/tst-compat-forwarder.c
@@ -0,0 +1,35 @@
+/* Copyright (C) 2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* Test that the compat forwaders in libpthread work correctly. */
+
+#include <support/test-driver.h>
+
+extern void call_system (void);
+
+int
+do_test (void)
+{
+ /* Calling the system function from a shared library that is not linked
+ against libpthread, when the main program is linked against
+ libpthread, should not crash. */
+ call_system ();
+
+ return 0;
+}
+
+#include <support/test-driver.c>
--
2.15.0
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-21 21:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-01 0:00 [2.25 COMMITTED 1/3] Don't use IFUNC resolver for longjmp or system in libpthread (bug 21041) Aurelien Jarno
2017-01-01 0:00 ` [2.25 COMMITTED 2/3] Fix s390 version of pt-longjmp.c Aurelien Jarno
2017-01-01 0:00 ` [2.25 COMMITTED 3/3] Add test for bug 21041 Aurelien Jarno
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).