linux/tools/testing/selftests/rseq
Sean Christopherson b167bfa432 rseq/selftests: Use weak symbol reference, not definition, to link with glibc
commit a001cd248a upstream.

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
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2025-10-19 16:21:47 +02:00
..
.gitignore .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
basic_percpu_ops_test.c selftests/rseq: Fix ppc32 offsets by using long rather than off_t 2022-07-07 17:53:31 +02:00
basic_test.c rseq/selftests: Provide basic test 2018-06-06 11:58:35 +02:00
compiler.h selftests/rseq: Fix: work-around asm goto compiler bugs 2022-07-07 17:53:31 +02:00
Makefile selftests/rseq: Fix build with undefined __weak 2023-08-16 18:22:00 +02:00
param_test.c selftests/rseq: Fix warnings about #if checks of undefined tokens 2022-07-07 17:53:31 +02:00
rseq-abi.h selftests/rseq: introduce own copy of rseq uapi header 2022-07-07 17:53:30 +02:00
rseq-arm.h selftests/rseq: Fix: work-around asm goto compiler bugs 2022-07-07 17:53:31 +02:00
rseq-arm64.h selftests/rseq: Fix: work-around asm goto compiler bugs 2022-07-07 17:53:31 +02:00
rseq-generic-thread-pointer.h selftests/rseq: Introduce thread pointer getters 2022-07-07 17:53:30 +02:00
rseq-mips.h selftests/rseq: Remove arm/mips asm goto compiler work-around 2022-07-07 17:53:31 +02:00
rseq-ppc-thread-pointer.h selftests/rseq: Introduce thread pointer getters 2022-07-07 17:53:30 +02:00
rseq-ppc.h selftests/rseq: Fix: work-around asm goto compiler bugs 2022-07-07 17:53:31 +02:00
rseq-s390.h selftests/rseq: Fix: work-around asm goto compiler bugs 2022-07-07 17:53:31 +02:00
rseq-skip.h selftests/rseq: Fix ppc32 offsets by using long rather than off_t 2022-07-07 17:53:31 +02:00
rseq-thread-pointer.h selftests/rseq: Introduce thread pointer getters 2022-07-07 17:53:30 +02:00
rseq-x86-thread-pointer.h selftests/rseq: Introduce thread pointer getters 2022-07-07 17:53:30 +02:00
rseq-x86.h selftests/rseq: Change type of rseq_offset to ptrdiff_t 2022-07-07 17:53:31 +02:00
rseq.c rseq/selftests: Use weak symbol reference, not definition, to link with glibc 2025-10-19 16:21:47 +02:00
rseq.h selftests/rseq: Change type of rseq_offset to ptrdiff_t 2022-07-07 17:53:31 +02:00
run_param_test.sh rseq/selftests: Test MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ 2020-09-25 14:23:27 +02:00
settings rseq/selftests: Turn off timeout setting 2019-12-23 10:52:41 -07:00