1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-25 07:49:18 +00:00
freebsd/libexec/rtld-elf
Konstantin Belousov a687683b99 rtld: mask signals for default read locks
Rtld locks from libthr defer signals delivery, which means that binding
is not possible while a signal handler is executed.

Binding might upgrade read-locked rtld_bind_lock to write-lock, if
symbol resolution requires loading filters.  If a signal would be delivered
while rtld is in read-locked section, and signal handler needs binding
which upgrades the lock, for non-threaded image that uses default rtld
locks, we get the rtld data structures modified under the top-level
active rtld frame.

To correct the problem, mask signals for read-locking of default locks
in addition to the write-locking.  It is very cheap now with
sigfastblock(2).

Note that the global state is used to track pre-locked state of either
sigfastblock(2) or signal mask (if sigfastblock(2) is administratively
disabled).  It is fine for non-threaded images since there are no other
threads.  But I believe that it is fine for threaded images using libc_r
as well, since masking signals disables preemption (I did not tested
it).

NetBSD PR:	https://gnats.netbsd.org/56979
Reported by:	tmunro
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D36396
2022-09-04 07:28:02 +03:00
..
aarch64 rtld(1): Fix a typo in a source code comment 2022-09-03 19:16:32 +02:00
amd64
arm
i386
powerpc
powerpc64
riscv
rtld-libc Have rtld query the page size from the kernel 2022-04-07 15:37:37 +01:00
tests
debug.c
debug.h
libmap.c
libmap.conf
libmap.h
Makefile
Makefile.depend
map_object.c Have rtld query the page size from the kernel 2022-04-07 15:37:37 +01:00
rtld_lock.c rtld: mask signals for default read locks 2022-09-04 07:28:02 +03:00
rtld_lock.h
rtld_malloc.c
rtld_malloc.h
rtld_paths.h
rtld_printf.c
rtld_printf.h
rtld_tls.h
rtld_utrace.h
rtld.1
rtld.c rtld: fix display of the mapbase for the traced objects 2022-08-14 18:11:06 +03:00
rtld.h Have rtld query the page size from the kernel 2022-04-07 15:37:37 +01:00
Symbol.map
xmalloc.c