selftests: seccomp: Handle syscall interruption in notification test
Subsystems (3)
PATCH 1/1 selftests: seccomp: Handle syscall interruption in notification test
The user_notification_wait_killable_after_reply test fails due to an unhandled error when a traced syscall is interrupted by a signal.
When a signal arrives after the tracer has received a seccomp notification but before it has replied, the notification can become stale. Any subsequent reply (like with SECCOMP_IOCTL_NOTIF_ADDFD) will fail with -ENOENT.
This patch fixes the test by handling the -ENOENT return value from SECCOMP_IOCTL_NOTIF_ADDFD, preventing the test from failing incorrectly. The loop counter is decremented to re-run the iteration for the restarted syscall.
Signed-off-by Wake Liu <[email protected]>
--- tools/testing/selftests/seccomp/seccomp_bpf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +6 -2
@@ -5048,8 +5048,12 @@ TEST(user_notification_wait_killable_after_reply) addfd.id = req.id; addfd.flags =SECCOMP_ADDFD_FLAG_SEND ; addfd.srcfd =0 ; - ASSERT_GE(ioctl(listener, SECCOMP_IOCTL_NOTIF_ADDFD, &addfd), 0) -kill (pid,SIGKILL ); + ret =ioctl (listener,SECCOMP_IOCTL_NOTIF_ADDFD , &addfd); +if (ret <0 && errno ==ENOENT ) { + i--; +continue ; + } +ASSERT_GE (ret,0 ); }/*
--
2.52.0.rc1.455.g30608eb744-goog