]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/landlock: Fix screwed up pointers in the scoped_signal_test
authorThomas Huth <thuth@redhat.com>
Thu, 9 Jul 2026 16:43:40 +0000 (18:43 +0200)
committerMickaël Salaün <mic@digikod.net>
Fri, 10 Jul 2026 10:59:11 +0000 (12:59 +0200)
commitd793186aa3bb833c878ae6826c87e62c843afaa3
tree0f28bda1f1f1628cd1f671bb117ff0ae42500c22
parent97c0e344e03818dbf3116e77d3d7fe81f1fbe795
selftests/landlock: Fix screwed up pointers in the scoped_signal_test

The scoped_signal_test uses pthread_join(..., (void **)&ret)) in
a couple of places, i.e. the return value of the thread is stored
in the shape of a "void *" into the memory location of &ret.
Pointers are 64-bit on modern computers, but the ret variable is
declared as a simple "enum thread_return" which is only 32 bits.
So the pthread_join() will overflow the ret variable by 4 byte.

The problem is very visible on big endian systems like s390x
where the test is failing: The least significant byte that carries
the return code of the thread is not written into the ret variable
here, but somewhere else in the stack frame, so the comparison
for the right return code is failing here.

Fix it by getting rid of the enum and defining the THREAD_* constants
and "ret" variables as proper "void *" pointers. This way we can
also get rid of some ugly (void *) castings in a couple of spots.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Link: https://patch.msgid.link/20260709164340.339656-1-thuth@redhat.com
Cc: stable@vger.kernel.org
Fixes: c8994965013e ("selftests/landlock: Test signal scoping for threads")
[mic: Add clang-format markups]
Signed-off-by: Mickaël Salaün <mic@digikod.net>
tools/testing/selftests/landlock/scoped_signal_test.c