8000 unotify: break out of SECCOMP_IOCTL_NOTIF_SEND retry loop on success and handle POLLERR/POLLNVAL by phenomenon0 · Pull Request #421 · google/nsjail · GitHub
[go: up one dir, main page]

Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions unotify/unotify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static void threadMain() {
PLOG_E("poll failed");
continue;
}
if (pfd.revents == POLLHUP) {
if ((pfd.revents & (POLLHUP | POLLERR | POLLNVAL)) && !(pfd.revents & POLLIN)) {
break;
}

8000 Expand All @@ -77,25 +77,16 @@ static void threadMain() {
resp.flags = SECCOMP_USER_NOTIF_FLAG_CONTINUE;

for (;;) {
if (ioctl(unotif_fd, SECCOMP_IOCTL_NOTIF_SEND, &resp) == -1) {
if (errno == EINTR) {
continue;
}
if (errno == ENOENT) {
break;
}
/*
* ENOENT means the thread has moved on (killed or interrupted).
* EINPROGRESS indicates either misuse by sending again after
* a successful send (which we're not doing) but we also see it
* when a process is exiting, perhaps related to thread shutdown.
* No need to print for these cases.
*/
if (errno != ENOENT && errno != EINPROGRESS) {
PLOG_E("SECCOMP_IOCTL_NOTIF_SEND failed");
}
if (ioctl(unotif_fd, SECCOMP_IOCTL_NOTIF_SEND, &resp) == 0) {
break;
}
if (errno == EINTR) {
continue;
}
if (errno != ENOENT && errno != EINPROGRESS) {
PLOG_E("SECCOMP_IOCTL_NOTIF_SEND failed");
}
break;
}
}
}
Expand Down
0