about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorian Weimer <fweimer@redhat.com>2018-01-15 16:05:36 +0100
committerAurelien Jarno <aurelien@aurel32.net>2018-12-28 15:03:05 +0100
commitfff112f4c4442af52bec90353e80bc4e801ab79b (patch)
tree7ee7de186e700db7196f18d3abfab0500072647f
parent23758d3539232de8368ea601f2df1c2a9da145e8 (diff)
downloadglibc-fff112f4c4442af52bec90353e80bc4e801ab79b.tar.gz
glibc-fff112f4c4442af52bec90353e80bc4e801ab79b.tar.xz
glibc-fff112f4c4442af52bec90353e80bc4e801ab79b.zip
nptl: Open libgcc.so with RTLD_NOW during pthread_cancel [BZ #22636]
Disabling lazy binding reduces stack usage during unwinding.

Note that RTLD_NOW only makes a difference if libgcc.so has not
already been loaded, so this is only a partial fix.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
(cherry picked from commit f993b8754080ac7572b692870e926d8b493db16c)
-rw-r--r--ChangeLog6
-rw-r--r--NEWS1
-rw-r--r--sysdeps/nptl/unwind-forcedunwind.c2
3 files changed, 8 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 7f37d678be..48292d6bf0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-01-10  Florian Weimer  <fweimer@redhat.com>
+
+	[BZ #22636]
+	* sysdeps/nptl/unwind-forcedunwind.c (pthread_cancel_init): Open
+	libgcc.so with RTLD_NOW, to avoid lazy binding during unwind.
+
 2018-01-08  Szabolcs Nagy  <szabolcs.nagy@arm.com>
 
 	[BZ #22637]
diff --git a/NEWS b/NEWS
index f2e9b3bf9f..9a11b86b11 100644
--- a/NEWS
+++ b/NEWS
@@ -71,6 +71,7 @@ The following bugs are resolved with this release:
   [21609] x86-64: Align the stack in __tls_get_addr
   [21624] Unsafe alloca allows local attackers to alias stack and heap (CVE-2017-1000366)
   [21654] nss: Fix invalid cast in group merging
+  [22636] PTHREAD_STACK_MIN is too small on x86-64
   [22637] nptl: Fix stack guard size accounting
   [22644] string: memmove-sse2-unaligned on 32bit x86 produces garbage when
     crossing 2GB threshold (CVE-2017-18269)
diff --git a/sysdeps/nptl/unwind-forcedunwind.c b/sysdeps/nptl/unwind-forcedunwind.c
index ca757c48ce..24a1c5b30d 100644
--- a/sysdeps/nptl/unwind-forcedunwind.c
+++ b/sysdeps/nptl/unwind-forcedunwind.c
@@ -49,7 +49,7 @@ pthread_cancel_init (void)
       return;
     }
 
-  handle = __libc_dlopen (LIBGCC_S_SO);
+  handle = __libc_dlopen_mode (LIBGCC_S_SO, RTLD_NOW | __RTLD_DLOPEN);
 
   if (handle == NULL
       || (resume = __libc_dlsym (handle, "_Unwind_Resume")) == NULL