Repository navigation
net, contain: run under gVisor (skip an unused link cache, tolerate a no-op RLIMIT_MSGQUEUE EPERM) - #365
Open
rubenfiszel wants to merge 1 commit into
Open
net, contain: run under gVisor (skip an unused link cache, tolerate a no-op RLIMIT_MSGQUEUE EPERM)#365rubenfiszel wants to merge 1 commit into
rubenfiszel wants to merge 1 commit into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Merged
12 of 13 tasks
Author
|
I've signed the CLA now. |
… no-op RLIMIT_MSGQUEUE EPERM) With clone_newnet, initParent built an rtnetlink link cache even when no interface is moved or cloned into the jail. gVisor acks NLM_F_ACK dump requests before NLMSG_DONE (google/gvisor#15945), which libnl rejects, so every jail with a network namespace failed there. Return before the netlink part when iface_own and macvlan_iface are both empty, keeping init_success so a user-mode networking backend is not torn down. gVisor refuses setrlimit(RLIMIT_MSGQUEUE) with EPERM for any value (google/gvisor#15944). Tolerate that EPERM, with a warning, when the current limit already has the requested value, as with the default 'soft'.
rubenfiszel
force-pushed
the
gvisor-netlink-msgqueue
branch
from
October 19, 2026 10:01
f843842 to
4bf7297
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
nsjail cannot create a jail inside a gVisor (runsc) sandbox, for example a Kubernetes pod with
runtimeClassName: gvisor. Two calls are answered differently from Linux there, and neither changes the jail nsjail builds:net::initParentbuilds an rtnetlink link cache it does not use. Withclone_newnet, it always connects aNETLINK_ROUTEsocket and runsrtnl_link_alloc_cache(). The cache is only used to move interfaces into the jail (iface_own) or to clone a MACVLAN (macvlan_iface). gVisor acks dump requests that setNLM_F_ACKbeforeNLMSG_DONE, which libnl rejects withMessage sequence number mismatch(netlink: dump requests with NLM_F_ACK are acked before NLMSG_DONE, which breaks libnl caches gvisor#15945). So every jail with a network namespace fails withCouldn't initialize net namespace, including jails that move no interface.Change: when
iface_ownandmacvlan_ifaceare both empty, return before the netlink part. This setsinit_success, so a user-mode networking backend started just above (nstun, pasta) is kept as on the existing!clone_newnetpath. Jails that move or clone an interface are unchanged. On Linux the jail is the same, minus one netlink round trip.RLIMIT_MSGQUEUE.containSetLimitsfails on the first rlimit it cannot set. gVisor does not allow settingRLIMIT_MSGQUEUEand returnsEPERMfor any value (setrlimit(RLIMIT_MSGQUEUE) fails with EPERM, even to its current value gvisor#15944). With the defaultrlimit_msgqueue_type: SOFT, nsjail only reasserts the inherited limit, so the failing call would change nothing.Change: if that
setrlimitfails withEPERMwhile the current soft and hard limits already equal the requested ones, log a warning and continue. A request that would change the limit still fails, and every other rlimit stays fatal.Running a jail under gVisor also needs
SECBIT_NO_SETUID_FIXUP, which gVisor implemented in google/gvisor#15130. That was merged on 2026-10-12 and is not yet in a release (release-20261012.0lacks it). It also needsclone_newcgroup: false, since gVisor refusesCLONE_NEWCGROUPuntil a cgroup2 filesystem has been mounted.Testing
Built from
4ff54a6with and without this change (Debian trixie, libnl 3.7, protobuf 3.21). The same jails were run with both binaries:-Mo -R /bin -R /lib -R /lib64 -R /usr -R /etc --rlimit_as 4096 --rlimit_nofile 1024 --rlimit_fsize 1000, with the jailed shell printing its capability sets,/proc/self/limits, its network interfaces and the result of a TCP connect.Linux 6.8 (privileged container under runc): identical output with and without the change for:
loup);--iface_no_lo;--user_net(nstun:loandeth0, the connect succeeds);--macvlan_iface eth0(the link cache is still built, the jail getsvs).Capabilities are all 0 everywhere, and the limits match.
gVisor (runsc nightly with kernel: implement SECBIT_NO_SETUID_FIXUP gvisor#15130, non-root,
--disable_clone_newcgroup):rtnl_link_alloc_cache().--iface_no_lojails start. They logRLIMIT_MSGQUEUE ... failed with EPERM, but the limit already has that value, and their capabilities, limits, interfaces (onlylo) and connect result (ENETUNREACH) match the Linux jail.--user_netstill fails under gVisor, with or without the change, atioctl(SIOCSIFADDR)in nstun. That is not addressed here.