summaryrefslogtreecommitdiffstats
path: root/lib/libthr/thread/thr_init.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2015-01-18 11:54:20 +0000
committerkib <kib@FreeBSD.org>2015-01-18 11:54:20 +0000
commit7fe8fbec77343dc12cd90833d80eb7f721248bc7 (patch)
tree0e4ae5740dfb6ba34a4755307529abeee008c52c /lib/libthr/thread/thr_init.c
parent5846d19730e47a408fae1ccea41b50ccb351b403 (diff)
downloadFreeBSD-src-7fe8fbec77343dc12cd90833d80eb7f721248bc7.zip
FreeBSD-src-7fe8fbec77343dc12cd90833d80eb7f721248bc7.tar.gz
Fix known issues which blow up the process after dlopen("libthr.so")
(or loading a dso linked to libthr.so into process which was not linked against threading library). MFC r276630: Remove interposing, fix malloc, reinstall signal handlers wrappers on libthr load. MFC r276681: Avoid calling internal libc function through PLT or accessing data though GOT. MFC r277032: Reduce the size of the interposing table and amount of cancellation-handling code in the libthr. MFC note: r276646 ("do not erronously export 'openat' symbol from rtld") is not applicable to stable/10 yet, since PATHFDS support was not merged.
Diffstat (limited to 'lib/libthr/thread/thr_init.c')
-rw-r--r--lib/libthr/thread/thr_init.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/libthr/thread/thr_init.c b/lib/libthr/thread/thr_init.c
index 6d6a532..9a1a67a 100644
--- a/lib/libthr/thread/thr_init.c
+++ b/lib/libthr/thread/thr_init.c
@@ -37,6 +37,7 @@
#include <sys/types.h>
#include <sys/signalvar.h>
#include <sys/ioctl.h>
+#include <sys/link_elf.h>
#include <sys/resource.h>
#include <sys/sysctl.h>
#include <sys/ttycom.h>
@@ -302,7 +303,7 @@ _thread_init_hack(void)
void
_libpthread_init(struct pthread *curthread)
{
- int fd, first = 0;
+ int fd, first, dlopened;
/* Check if this function has already been called: */
if ((_thr_initial != NULL) && (curthread == NULL))
@@ -316,6 +317,7 @@ _libpthread_init(struct pthread *curthread)
if (sizeof(jmp_table) != (sizeof(pthread_func_t) * PJT_MAX * 2))
PANIC("Thread jump table not properly initialized");
memcpy(__thr_jtable, jmp_table, sizeof(jmp_table));
+ __thr_interpose_libc();
/*
* Check for the special case of this process running as
@@ -349,7 +351,10 @@ _libpthread_init(struct pthread *curthread)
if (curthread == NULL)
PANIC("Can't allocate initial thread");
init_main_thread(curthread);
+ } else {
+ first = 0;
}
+
/*
* Add the thread to the thread list queue.
*/
@@ -361,7 +366,8 @@ _libpthread_init(struct pthread *curthread)
if (first) {
_thr_initial = curthread;
- _thr_signal_init();
+ dlopened = _rtld_is_dlopened(&_thread_autoinit_dummy_decl) != 0;
+ _thr_signal_init(dlopened);
if (_thread_event_mask & TD_CREATE)
_thr_report_creation(curthread, curthread);
/*
OpenPOWER on IntegriCloud