Skip to content

Commit 49e245c

Browse files
authored
Fix: bind interrupted by seccomp signal race (#14554)
* Use wait_for_completion_killable instead of the default wait_for_completion_interruptible * retry if kernel does not support the new flag
1 parent 4417383 commit 49e245c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/linux/init/main.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3615,7 +3615,13 @@ Return Value:
36153615
.filter = Filter,
36163616
};
36173617

3618-
wil::unique_fd Fd{syscall(__NR_seccomp, SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_NEW_LISTENER, &Prog)};
3618+
wil::unique_fd Fd{syscall(
3619+
__NR_seccomp, SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_NEW_LISTENER | SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV, &Prog)};
3620+
if (!Fd && errno == EINVAL)
3621+
{
3622+
LOG_INFO("seccomp failed with EINVAL with SECCOMP_FILTER_FLAG_WAIT_KILLABLE_RECV, retrying without it.");
3623+
Fd = syscall(__NR_seccomp, SECCOMP_SET_MODE_FILTER, SECCOMP_FILTER_FLAG_NEW_LISTENER, &Prog);
3624+
}
36193625
if (!Fd)
36203626
{
36213627
LOG_ERROR("Failed to register bpf syscall hook, {}", errno);

0 commit comments

Comments
 (0)