linux/tools
Mickaël Salaün 130e428067
selftests/harness: Fix tests timeout and race condition
We cannot use CLONE_VFORK because we also need to wait for the timeout
signal.

Restore tests timeout by using the original fork() call in __run_test()
but also in __TEST_F_IMPL().  Also fix a race condition when waiting for
the test child process.

Because test metadata are shared between test processes, only the
parent process must set the test PID (child).  Otherwise, t->pid may be
set to zero, leading to inconsistent error cases:

  #  RUN           layout1.rule_on_mountpoint ...
  # rule_on_mountpoint: Test ended in some other way [127]
  #            OK  layout1.rule_on_mountpoint
  ok 20 layout1.rule_on_mountpoint

As safeguards, initialize the "status" variable with a valid exit code,
and handle unknown test exits as errors.

The use of fork() introduces a new race condition in landlock/fs_test.c
which seems to be specific to hostfs bind mounts, but I haven't found
the root cause and it's difficult to trigger.  I'll try to fix it with
another patch.

Cc: Christian Brauner <brauner@kernel.org>
Cc: Günther Noack <gnoack@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Will Drewry <wad@chromium.org>
Cc: stable@vger.kernel.org
Closes: https://lore.kernel.org/r/9341d4db-5e21-418c-bf9e-9ae2da7877e1@sirena.org.uk
Fixes: a86f18903d ("selftests/harness: Fix interleaved scheduling leading to race conditions")
Fixes: 24cf65a622 ("selftests/harness: Share _metadata between forked processes")
Link: https://lore.kernel.org/r/20240621180605.834676-1-mic@digikod.net
Tested-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Mickaël Salaün <mic@digikod.net>
2024-06-28 16:06:03 +02:00
..
accounting
arch tools headers arm64: Sync arm64's cputype.h with the kernel sources 2024-06-04 16:46:40 -03:00
bootconfig
bpf bpf: Fix potential integer overflow in resolve_btfids 2024-05-24 17:12:12 +02:00
build
certs
cgroup proc: rewrite stable_page_flags() 2024-04-25 20:56:15 -07:00
counter
crypto
debugging
firewire
firmware
gpio
hv tools: hv: suppress the invalid warning for packed member alignment 2024-05-28 05:27:35 +00:00
iio
include perf tools fixes for v6.10: 2nd batch 2024-06-09 09:04:51 -07:00
kvm/kvm_stat
laptop
leds
lib libbpf: don't close(-1) in multi-uprobe feature detector 2024-05-31 14:56:51 -07:00
memory-model
mm
net/ynl ynl: ensure exact-len value is resolved 2024-05-13 14:59:24 -07:00
objtool objtool: Fix compile failure when using the x32 compiler 2024-03-30 22:12:37 +01:00
pci
pcmcia
perf perf bpf: Fix handling of minimal vmlinux.h file when interrupting the build 2024-06-05 11:33:00 -03:00
power tools/power/cpupower: Fix Pstate frequency reporting on AMD Family 1Ah CPUs 2024-05-28 09:22:57 -06:00
rcu
scripts
sound ASoC: dapm-graph: new tool to visualize DAPM state 2024-04-21 09:58:17 +09:00
spi
testing selftests/harness: Fix tests timeout and race condition 2024-06-28 16:06:03 +02:00
thermal
time
tracing tools/latency-collector: Fix -Wformat-security compile warns 2024-05-23 10:46:01 -04:00
usb
verification tools/verification: Use tools/build makefiles on rv 2024-03-20 05:39:06 +01:00
virtio tools: virtio: introduce vhost_net_test 2024-03-05 11:38:14 +01:00
wmi
workqueue workqueue: remove unnecessary import and function in wq_monitor.py 2024-03-25 10:11:32 -10:00
writeback writeback: add wb_monitor.py script to monitor writeback info on bdi 2024-05-05 17:53:51 -07:00
Makefile tools/Makefile: remove cgroup target 2024-03-26 11:07:21 -07:00