linux/tools/testing
Aristeu Rozanski b24335521d selftests/memfd: use IPC semaphore instead of SIGSTOP/SIGCONT
selftests/memfd: use IPC semaphore instead of SIGSTOP/SIGCONT

In order to synchronize new processes to test inheritance of memfd_noexec
sysctl, memfd_test sets up the sysctl with a value before creating the new
process.  The new process then sends itself a SIGSTOP in order to wait for
the parent to flip the sysctl value and send a SIGCONT signal.

This would work as intended if it wasn't the fact that the new process is
being created with CLONE_NEWPID, which creates a new PID namespace and the
new process has PID 1 in this namespace.  There're restrictions on sending
signals to PID 1 and, although it's relaxed for other than root PID
namespace, it's biting us here.  In this specific case the SIGSTOP sent by
the new process is ignored (no error to kill() is returned) and it never
stops its execution.  This is usually not noticiable as the parent usually
manages to set the new sysctl value before the child has a chance to run
and the test succeeds.  But if you run the test in a loop, it eventually
reproduces:

	while [ 1 ]; do ./memfd_test >log 2>&1 || break; done; cat log

So this patch replaces the SIGSTOP/SIGCONT synchronization with IPC
semaphore.

Link: https://lkml.kernel.org/r/a7776389-b3d6-4b18-b438-0b0e3ed1fd3b@work
Fixes: 6469b66e3f ("selftests: improve vm.memfd_noexec sysctl tests")
Signed-off-by: Aristeu Rozanski <aris@redhat.com>
Cc: Aleksa Sarai <cyphar@cyphar.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: liuye <liuye@kylinos.cn>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2026-02-12 15:45:57 -08:00
..
crypto/chacha20-s390
cxl cxl: Check for invalid addresses returned from translation functions on errors 2026-01-13 08:30:40 -07:00
fault-injection
ktest ktest.pl: Fix uninitialized var in config-bisect.pl 2025-12-03 18:25:18 -05:00
kunit kunit: qemu_configs: Add MIPS configurations 2025-09-15 10:30:07 -06:00
memblock
nvdimm tools/testing/nvdimm: Use per-DIMM device handle 2025-11-03 16:47:13 -06:00
radix-tree idr: fix idr_alloc() returning an ID out of range 2025-12-23 11:23:11 -08:00
rbtree
scatterlist mm: remove nth_page() 2025-09-21 14:22:10 -07:00
selftests selftests/memfd: use IPC semaphore instead of SIGSTOP/SIGCONT 2026-02-12 15:45:57 -08:00
shared Summary of significant series in this pull request: 2025-10-02 18:18:33 -07:00
vma mm: introduce VMA flags bitmap type 2025-11-29 10:41:09 -08:00
vsock vsock/test: add a final full barrier after run all tests 2026-01-10 12:07:25 -08:00