Skip to content

netlink: honor SOCK_NONBLOCK and SOCK_CLOEXEC on the virtual socket - #362

Merged
congwang-mk merged 1 commit into
multikernel:mainfrom
saviourmk:netlink-socket-flags
Nov 28, 2026
Merged

congwang-mk merged 1 commit into
multikernel:mainfrom
saviourmk:netlink-socket-flags

Conversation

@saviourmk

Copy link
Copy Markdown
Contributor

handle_socket ignored the flags in the socket type. The child end of the socketpair always came back blocking and close-on-exec, so socket(AF_NETLINK, SOCK_RAW | SOCK_NONBLOCK, NETLINK_ROUTE) got a blocking fd, and a caller that left out SOCK_CLOEXEC got one that closes on exec anyway. Python is an easy way to hit the first one: it trusts SOCK_NONBLOCK and never calls fcntl, so recv on such a socket blocks forever instead of raising BlockingIOError once there is nothing left to read.

The child end now gets O_NONBLOCK when SOCK_NONBLOCK was passed, and newfd_flags follows SOCK_CLOEXEC. Callers that pass neither, like glibc, see no change.

I added an integration test that creates the socket through libc with no flag, with SOCK_NONBLOCK and with SOCK_CLOEXEC and checks O_NONBLOCK and FD_CLOEXEC on each, then checks that a Python SOCK_NONBLOCK socket gets EAGAIN from an empty recv. On main the recv hangs until the 30s guard in the test fires. With the change the whole test_netlink_virt suite passes.

@congwang-mk
congwang-mk merged commit a0674f6 into multikernel:main Nov 28, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants