mirror of
git://sourceware.org/git/glibc.git
synced 2026-09-08 23:58:31 +08:00
The BZ#33326 testcase triggers an assertion during process startup, which results in a segmentation fault instead of an error message and process termination with a SIGABRT. The assert issues __libc_message_impl, which in turn might call string functions depending on the ABI (strchrnul, strlen, memcpy/mempcpy), system calls (writev and mmap), and finally the abort call. The dl-symbol-redir-ifunc.h is also expanded to cover strchrnul on x86_64, s390, powerpc64 (both endianness) and loongarch, mempcpy on powerpc64be, and memcpy on aarch64. On s390 the redirection is only issued if the ifunc variant is built, since strchrnul-c.c only renames the C implementation to STRCHRNUL_DEFAULT when HAVE_STRCHRNUL_IFUNC is set. The buffer that backs up the assert message is now allocated through _dl_mmap, which issues the syscall directly instead of calling __mmap (setting errno on failure requires the thread pointer). The abort call now issues __raise_direct instead of raise (the Hurd port aliases __raise_direct to raise). On i386, syscalls should not use the vDSO during program startup because the thread pointer is not yet initialized. This requires __raise_direct, _dl_writev, and _dl_mmap to be built with I386_USE_SYSENTER set to 0. Creating a test case is challenging. For static-pie, the assert is only called for ill-formed ELF files on elf_get_dynamic_info and by some targets on ELF_DYNAMIC_RELOCATE (although not all targets use assert in their dl-machine.h). Some targets also issue __libc_fatal on ARCH_SETUP_IREL, but also only for ill-formatted ELF files. The test employs a different strategy and overrides the __tunables_init symbol, which is invoked immediately before self-relocation and TLS setup. The test is built with -Wl,-z,muldefs to avoid linker issues. I checked on aarch64, x86_64, i686, s390x (qemu), sparc (qemu), mips64el (qemu), armhf, riscv, and powerpc. Reviewed-by: Florian Weimer <fweimer@redhat.com>