Re: [PATCH v2 3/3] selftests/seccomp: Test SECCOMP_IOCTL_NOTIF_ADDFD

From
Sargun Dhillon <hidden>
Date
2020-05-29 18:46:11
Also in
lkml
Reply to
Kees Cook, 2020-05-29
On Fri, May 29, 2020 at 12:41:51AM -0700, Kees Cook wrote:
On Thu, May 28, 2020 at 04:08:58AM -0700, Sargun Dhillon wrote:
quoted
+	EXPECT_EQ(ioctl(listener, SECCOMP_IOCTL_NOTIF_SEND, &resp), 0);
+
+	nextid = req.id + 1;
+
+	/* Wait for getppid to be called for the second time */
+	sleep(1);
I always rebel at finding "sleep" in tests. ;) Is this needed? IIUC,
userspace will immediately see EINPROGRESS after the NOTIF_SEND
finishes, yes?

Otherwise, yes, this looks good.

-- 
Kees Cook
I'm open to better suggestions, but there's a race where if getppid
is not called before the second SECCOMP_IOCTL_NOTIF_ADDFD is called,
you will just get an ENOENT, since the notification ID is not found.

The other approach is to "poll" the child, and wait for it to enter
the second syscall. Calling receive beforehand doesn't work because
it moves the state of the notification in the kernel to received,
and then the kernel doesn't error with EINPROGRESS.
Thread (35 messages) 35 messages, 6 authors, last reply 2020-06-01
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help