Skip to contentSkip to conversation

kselftest/runner: allow to properly deliver signals to tests

PATCH In review Andrea Righi 2 participants 2 messages Apr 10, 2020 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kselftest/runner: allow to properly deliver signals to tests

While running seccomp_bpf, kill_after_ptrace() gets stuck if we run it via /usr/bin/timeout (that is the default), until the timeout expires.

This is because /usr/bin/timeout is preventing to properly deliver signals to ptrace'd children (SIGSYS in this case).

This problem can be easily reproduced by running:

 $ sudo make TARGETS=seccomp kselftest
 ...

# [ RUN ] TRACE_syscall.skip_a#
not ok 1 selftests: seccomp: seccomp_bpf # TIMEOUT

The test is hanging at this point until the timeout expires and then it reports the timeout error.

Prevent this problem by passing --foreground to /usr/bin/timeout, allowing to properly deliver signals to children processes.

---
 tools/testing/selftests/kselftest/runner.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kselftest/runner.sh +1 -1
index e84d901f8567..676b3a8b114d 100644
@@ -33,7 +33,7 @@ tap_timeout()
 {
 	# Make sure tests will time out if utility is available.
 	if [ -x /usr/bin/timeout ] ; then
-		/usr/bin/timeout "$kselftest_timeout" "$1"
+		/usr/bin/timeout --foreground "$kselftest_timeout" "$1"
 	else
 		"$1"
 	fi
Signature · 1 line
2.25.1
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · Andrea Righi

While running seccomp_bpf, kill_after_ptrace() gets stuck if we run it via /usr/bin/timeout (that is the default), until the timeout expires.

This is because /usr/bin/timeout is preventing to properly deliver signals to ptrace'd children (SIGSYS in this case).

This problem can be easily reproduced by running:

 $ sudo make TARGETS=seccomp kselftest
 ...
Quoted 8 lines

# [ RUN ] TRACE_syscall.skip_a#
not ok 1 selftests: seccomp: seccomp_bpf # TIMEOUT

The test is hanging at this point until the timeout expires and then it reports the timeout error.

Prevent this problem by passing --foreground to /usr/bin/timeout, allowing to properly deliver signals to children processes.

Interesting! This seems a poor behavior on "timeout"'s part. Is it setting a signal mask? Hmpf. Thanks for tracking this down! This seems like the best solution now, so:

-Kees

Quoted 22 lines
---
 tools/testing/selftests/kselftest/runner.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/kselftest/runner.sh +1 -1
index e84d901f8567..676b3a8b114d 100644
@@ -33,7 +33,7 @@ tap_timeout()
 {
 	# Make sure tests will time out if utility is available.
 	if [ -x /usr/bin/timeout ] ; then
-		/usr/bin/timeout "$kselftest_timeout" "$1"
+		/usr/bin/timeout --foreground "$kselftest_timeout" "$1"
 	else
 		"$1"
 	fi
Signature · 1 line
2.25.1
Signature · 1 line
Kees Cook