opnsense-src/libexec/rtld-elf
Jessica Clarke 461cad31f3 rtld-elf: Fix leaks and wild frees in origin_subst
55abf23dd3 inverted the value passed to origin_subst_one when rolling
up the existing code into a loop. If the first token is found ($ORIGIN),
this results in a wild free of part of strtab. Processing the second
token works fine and will act how the first should have regardless of
whether found, allocating memory for the string without freeing.
Processing subsequent tokens however will then leak, regardless of
whether found, as they will also believe they need to allocate memory
and can't free the string.

Found by:	CHERI
Reviewed by:	kib, markj
Fixes:		55abf23dd3 ("rtld: make token substitution table-driven")
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D35792

(cherry picked from commit becd9908be)
2022-08-11 00:11:48 +01:00
..
aarch64 TLS: Use <machine/tls.h> for libc and rtld. 2022-04-29 13:50:05 -07:00
amd64 TLS: Use <machine/tls.h> for libc and rtld. 2022-04-29 13:50:05 -07:00
arm TLS: Use <machine/tls.h> for libc and rtld. 2022-04-29 13:50:05 -07:00
i386 TLS: Use <machine/tls.h> for libc and rtld. 2022-04-29 13:50:05 -07:00
mips TLS: Use <machine/tls.h> for libc and rtld. 2022-04-29 13:50:05 -07:00
powerpc TLS: Use <machine/tls.h> for libc and rtld. 2022-04-29 13:50:05 -07:00
powerpc64 TLS: Use <machine/tls.h> for libc and rtld. 2022-04-29 13:50:05 -07:00
riscv TLS: Use <machine/tls.h> for libc and rtld. 2022-04-29 13:50:05 -07:00
rtld-libc Have rtld query the page size from the kernel 2022-05-03 15:04:04 +01:00
tests rtld: introduce PRELOAD_FDS 2021-08-20 12:31:46 +03:00
debug.c libexec: adoption of SPDX licensing ID tags. 2017-11-27 15:25:02 +00:00
debug.h Use rtld_putstr() instead of write() for the rtld msg() macro 2019-06-26 15:43:26 +00:00
libmap.c rtld-elf/paths.h: Make it usable outside rtld 2021-10-23 02:32:27 +03:00
libmap.conf Move libmap.conf to libexec/rtld-elf/ 2018-09-18 00:25:00 +00:00
libmap.h rtld: constify most variables holding references to the environment values 2021-08-23 12:20:56 +03:00
Makefile rtld: Do not install libmap.conf when installing the COMPAT32 version 2021-11-06 16:03:06 +01:00
Makefile.depend new depends 2015-06-16 23:37:19 +00:00
map_object.c Have rtld query the page size from the kernel 2022-05-03 15:04:04 +01:00
rtld.1 rtld.1: Fix misplaced text 2022-02-28 09:05:30 -05:00
rtld.c rtld-elf: Fix leaks and wild frees in origin_subst 2022-08-11 00:11:48 +01:00
rtld.h Have rtld query the page size from the kernel 2022-05-03 15:04:04 +01:00
rtld_lock.c rtld: initialize default dlerror_seen_val as true 2021-05-19 06:13:14 +03:00
rtld_lock.h rtld_lock.h: add some comments about versioning of struct RtldLockInfo 2021-04-23 14:14:08 +03:00
rtld_malloc.c rtld-elf/paths.h: Make it usable outside rtld 2021-10-23 02:32:27 +03:00
rtld_malloc.h Add header file missed in r343564. 2019-01-29 22:45:24 +00:00
rtld_paths.h rtld_paths.h: Provide _PATH_ELF32_HINTS string, unconditionally 2021-12-01 03:07:19 +02:00
rtld_printf.c rtld: add rtld_fdprintfx() 2021-11-19 06:25:27 +02:00
rtld_printf.h rtld: add rtld_fdprintfx() 2021-11-19 06:25:27 +02:00
rtld_tls.h Remove sparc64 specific parts of rtld-elf. 2020-02-26 18:49:25 +00:00
rtld_utrace.h Renumber copyright clause 4 2017-02-28 23:42:47 +00:00
Symbol.map rtld dl_iterate_phdr(): dlpi_tls_data is wrong 2021-04-23 14:14:06 +03:00
xmalloc.c Make p_vaddr % p_align == p_offset % p_align for (some) TLS segments. 2020-04-04 22:37:50 +00:00