Skip to contentSkip to conversation

selftests: seccomp: Handle syscall interruption in notification test

PATCH New Wake Liu 1 participant 1 message Nov 19, 2025

Subsystems (3)
lore
Share & tools
lore

Wake Liu

author
#0 lore raw

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.

---
 tools/testing/selftests/seccomp/seccomp_bpf.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
tools/testing/selftests/seccomp/seccomp_bpf.c +6 -2
index 574fdd102eb5..c3e598c9c4ee 100644
@@ -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