freebsd-dev/libexec/rtld-elf
Konstantin Belousov b88a8d3d1d Fix acquisition of nested write compat rtld locks.
Obtaining compat rtld lock in write mode sets process signal mask to
block all signals.  Previous mask is stored in the global variable
oldsigmask.  If a lock is write-locked while another lock is already
write-locked, oldsigmask is overwritten by the total mask and on the
last unlock, all signals except traps appear to be blocked.

Fix this by counting the write-lock nested level, and only storing to
oldsigmask/restoring from it at the outermost level.

Masking signals disables involuntary preemption for libc_r, and there
could be no voluntary context switches in the locked code
(dl_iterate_phdr(3) keeps a lock around user callback, but it was
added long after libc_r was renounced).  Due to this, remembering the
level in the global variable after the lock is obtained should be
safe, because no two libc_r threads can acquire different write locks
in parallel.

PR:	215826
Reported by:	kami
Tested by:	yamagi@yamagi.org (previous version)
To be reviewed by:	kan
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
2017-01-10 19:26:55 +00:00
..
aarch64 Retire long-broken/unused static rtld support 2016-12-02 14:23:26 +00:00
amd64 Adjust r308689 to make rtld compilable with either in-tree or 2016-11-21 14:13:57 +00:00
arm Adjust r308689 to make rtld compilable with either in-tree or 2016-11-21 14:13:57 +00:00
i386 Adjust r308689 to make rtld compilable with either in-tree or 2016-11-21 14:13:57 +00:00
mips Fix _mips_rtld_bind() to handle ELF filters. 2016-11-23 20:21:53 +00:00
powerpc Adjust r308689 to make rtld compilable with either in-tree or 2016-11-21 14:13:57 +00:00
powerpc64 Adjust r308689 to make rtld compilable with either in-tree or 2016-11-21 14:13:57 +00:00
riscv Retire long-broken/unused static rtld support 2016-12-02 14:23:26 +00:00
sparc64 Retire long-broken/unused static rtld support 2016-12-02 14:23:26 +00:00
tests DIRDEPS_BUILD: Add some missing dirctories to the build. 2016-08-31 19:30:59 +00:00
debug.c Do not call callbacks for dl_iterate_phdr(3) with the rtld bind and 2016-01-20 07:21:33 +00:00
debug.h Remove historical GNUC test 2015-05-06 15:29:11 +00:00
libmap.c Rather than using the #define for path names, indirect through a char * 2015-10-31 04:39:55 +00:00
libmap.h Make the directory mapping functionality, which was previously only 2013-09-21 21:03:52 +00:00
Makefile Assert that there is no unresolved symbols during rtld linking. 2016-11-15 09:40:03 +00:00
Makefile.depend new depends 2015-06-16 23:37:19 +00:00
malloc.c libexec: minor spelling fixes in comments. 2016-05-01 19:39:23 +00:00
map_object.c Fix handling of DT_TEXTREL for an object with more than one read-only 2016-03-02 16:36:24 +00:00
paths.h Convert casperd(8) daemon to the libcasper. 2016-02-25 18:23:40 +00:00
rtld_lock.c Fix acquisition of nested write compat rtld locks. 2017-01-10 19:26:55 +00:00
rtld_lock.h Change compiler setting to make default visibility of the symbols for 2015-03-29 18:53:21 +00:00
rtld_printf.c Add the LD_LIBRARY_PATH_FDS environmental variable. 2014-06-20 17:08:32 +00:00
rtld_printf.h Add the LD_LIBRARY_PATH_FDS environmental variable. 2014-06-20 17:08:32 +00:00
rtld_tls.h Change compiler setting to make default visibility of the symbols for 2015-03-29 18:53:21 +00:00
rtld_utrace.h Move defines common between rtld and libsysdecode into the header, 2016-08-12 19:31:41 +00:00
rtld.1 mdoc: remove superfluous paragraph macros. 2014-06-23 18:40:21 +00:00
rtld.c rtld: Fix a couple of bugs around the unloading of ELF filters. 2016-12-22 17:44:27 +00:00
rtld.h rtld: Ensure that dlopen() cannot obtain a reference on a doomed object. 2016-12-22 17:41:32 +00:00
Symbol.map Add rtld private interface for dso to detect dynamic loading 2015-01-03 18:09:53 +00:00
xmalloc.c Increase alignment to size of pointer if the alignment is too small. 2014-02-22 11:06:48 +00:00