From: Mathieu Desnoyers Date: Tue, 22 Nov 2022 20:39:03 +0000 (-0500) Subject: selftests/rseq: Fix: Fail thread registration when CONFIG_RSEQ=n X-Git-Tag: v6.6.17~5545^2~108 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4842dadfc66f627083ec46c4e9a426e805c765f3;p=platform%2Fkernel%2Flinux-rpi.git selftests/rseq: Fix: Fail thread registration when CONFIG_RSEQ=n When linking the selftests against a libc which does not handle rseq registration (before 2.35), rseq thread registration silently succeed even with CONFIG_RSEQ=n because it erroneously thinks that libc is handling rseq registration. This is caused by setting the rseq ownership flag only after the rseq_available() check. It should rather be set before the rseq_available() check. Set the rseq_size to 0 (error value) immediately after the rseq_available() check fails rather than in the thread registration functions. Signed-off-by: Mathieu Desnoyers Signed-off-by: Peter Zijlstra (Intel) Link: https://lore.kernel.org/r/20221122203932.231377-2-mathieu.desnoyers@efficios.com --- diff --git a/tools/testing/selftests/rseq/rseq.c b/tools/testing/selftests/rseq/rseq.c index 4177f950..376a73f 100644 --- a/tools/testing/selftests/rseq/rseq.c +++ b/tools/testing/selftests/rseq/rseq.c @@ -119,9 +119,11 @@ void rseq_init(void) rseq_flags = *libc_rseq_flags_p; return; } - if (!rseq_available()) - return; rseq_ownership = 1; + if (!rseq_available()) { + rseq_size = 0; + return; + } rseq_offset = (void *)&__rseq_abi - rseq_thread_pointer(); rseq_size = sizeof(struct rseq_abi); rseq_flags = 0;