mirror-linux/tools/testing/selftests/rseq
Sean Christopherson a001cd248a rseq/selftests: Use weak symbol reference, not definition, to link with glibc
Add "extern" to the glibc-defined weak rseq symbols to convert the rseq
selftest's usage from weak symbol definitions to weak symbol _references_.
Effectively re-defining the glibc symbols wreaks havoc when building with
-fno-common, e.g. generates segfaults when running multi-threaded programs,
as dynamically linked applications end up with multiple versions of the
symbols.

Building with -fcommon, which until recently has the been the default for
GCC and clang, papers over the bug by allowing the linker to resolve the
weak/tentative definition to glibc's "real" definition.

Note, the symbol itself (or rather its address), not the value of the
symbol, is set to 0/NULL for unresolved weak symbol references, as the
symbol doesn't exist and thus can't have a value.  Check for a NULL rseq
size pointer to handle the scenario where the test is statically linked
against a libc that doesn't support rseq in any capacity.

Fixes: 3bcbc20942 ("selftests/rseq: Play nice with binaries statically linked against glibc 2.35+")
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Suggested-by: Florian Weimer <fweimer@redhat.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: stable@vger.kernel.org
Closes: https://lore.kernel.org/all/87frdoybk4.ffs@tglx
2025-09-13 19:51:59 +02:00
..
.gitignore selftests/rseq: Add rseq syscall errors test 2025-02-22 14:13:45 +01:00
Makefile selftests/rseq: Add rseq syscall errors test 2025-02-22 14:13:45 +01:00
basic_percpu_ops_test.c
basic_test.c
compiler.h
param_test.c rseq/selftests: Add support for OpenRISC 2025-01-14 17:17:16 +00:00
rseq-abi.h
rseq-arm-bits.h
rseq-arm.h
rseq-arm64-bits.h
rseq-arm64.h
rseq-bits-reset.h
rseq-bits-template.h
rseq-generic-thread-pointer.h
rseq-mips-bits.h
rseq-mips.h
rseq-or1k-bits.h rseq/selftests: Add support for OpenRISC 2025-01-14 17:17:16 +00:00
rseq-or1k-thread-pointer.h rseq/selftests: Add support for OpenRISC 2025-01-14 17:17:16 +00:00
rseq-or1k.h rseq/selftests: Add support for OpenRISC 2025-01-14 17:17:16 +00:00
rseq-ppc-bits.h
rseq-ppc-thread-pointer.h
rseq-ppc.h
rseq-riscv-bits.h rseq/selftests: Fix riscv rseq_offset_deref_addv inline asm 2025-02-14 13:06:36 -08:00
rseq-riscv.h rseq/selftests: Fix riscv rseq_offset_deref_addv inline asm 2025-02-14 13:06:36 -08:00
rseq-s390-bits.h
rseq-s390.h
rseq-thread-pointer.h rseq/selftests: Add support for OpenRISC 2025-01-14 17:17:16 +00:00
rseq-x86-bits.h
rseq-x86-thread-pointer.h
rseq-x86.h
rseq.c rseq/selftests: Use weak symbol reference, not definition, to link with glibc 2025-09-13 19:51:59 +02:00
rseq.h selftests/rseq: Add rseq syscall errors test 2025-02-22 14:13:45 +01:00
run_param_test.sh
run_syscall_errors_test.sh selftests/rseq: Add rseq syscall errors test 2025-02-22 14:13:45 +01:00
settings
syscall_errors_test.c selftests/rseq: Add rseq syscall errors test 2025-02-22 14:13:45 +01:00