-
Notifications
You must be signed in to change notification settings - Fork 326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
interaction between seccomp-notify code and signal restarting looks broken #526
Comments
thanks for the report.
Is |
opened a PR: #527 |
Yes; if you use it correctly, |
Actually, there's another thing that can happen: If all the target processes have died, the seccomp fd will constantly signal an error condition ( For nonblocking users, options for the kernel patch are that we can either keep returning Maybe I filed this bug a bit prematurely and it'd be better to hold off on actually patching it in LXC until we have a decision on how exactly we want to amend the UAPI... I'll CC you on the patch submission in case you want to give input there. |
We're already handling the |
Where is that code? |
@thejh I've pinged you on the PR. |
cc @giuseppe @brauner @kees @mkerrisk
tl;dr:
ENOENT
errors fromSECCOMP_IOCTL_NOTIF_RECV
correctly inlibcrun_seccomp_notify_plugins
so that containers don't crash because of spurious errors that can happen legitimately.O_NONBLOCK
on theseccomp_notify_fd
at the same time to make life easier for us kernel folks.As far as I can tell, crun treats any error return values from
SECCOMP_IOCTL_NOTIF_RECV
as fatal inlibcrun_seccomp_notify_plugins
:libcrun_seccomp_notify_plugins
returns that error value up, thenwait_for_process
returns it up further,libcrun_container_run_internal
again returns it up, and then e.g.libcrun_container_run
will callforce_delete_container_status
to nuke the container.However,
SECCOMP_IOCTL_NOTIF_RECV
can return an error code in normal usage in the following scenario (where "target" refers to a process running inside the container):epoll_wait()
to wait for events on theseccomp_notify_fd
(and other fds)SECCOMP_RET_USER_NOTIF
; this inserts metadata about this syscall invocation to a kernel-internal list of pending syscallsepoll_wait()
returns and signals readiness ofseccomp_notify_fd
(because the kernel-internal list of pending syscalls is not empty)SIGUSR1
SECCOMP_IOCTL_NOTIF_RECV
(expecting to receive information about a pending syscall; but that pending syscall has disappeared in the meantime)SECCOMP_IOCTL_NOTIF_RECV
returns-1
witherrno
set toENOENT
The same kind of thing can also happen if someone kills the target process in the meantime.
(
SECCOMP_IOCTL_NOTIF_SEND
can also fail in the same way, but there you seem to be handling it correctly already.)In addition to fixing this, it would be helpful for the kernel if you could set the
O_NONBLOCK
flag onseccomp_notify_fd
at the same time (to explicitly signal that you don't wantseccomp_notify_fd
to block when no events are pending). That isn't currently necessary, but it would allow us to clean up the kernel code around this feature a bit; and if you fix these two things at the same time, we can argue that a UAPI-breaking change that makesSECCOMP_IOCTL_NOTIF_RECV
always block when no syscalls are currently available would not have negative consequences for any current users (because current crun is completely broken in this case anyway).For more details, see the current draft of a manual page for the
seccomp_user_notif
mechanism and the discussion thread on the first draft.The text was updated successfully, but these errors were encountered: