Repository navigation
A NIC the net zone renamed is renamed nic<N> before the next net zone takes it - #304
Merged
Merged
Conversation
The net zone holds CAP_NET_ADMIN in its namespace and can give its NIC any name the kernel takes: a leading dash, a quote, an escape, bytes that are not UTF-8. When the zone ends the NIC comes back to zone 0 under that name, and the next start handed it on as it was. A name that is not UTF-8 failed every later start, since kryptikd looked up the lossy copy, and kept the machine offline until a reboot. Any other reached the fresh zone's script: a quote ended the name in the nft uplink set and could add kryptik0 to it, and a leading dash reached dhcpcd as an option. kryptikd now reads each physical interface's name as the kernel holds it, with its index, and renames one that is not plain, a lower-case letter then lower-case letters and digits, to the kernel's nic%d before it moves. netzone-init.sh names the device to ip with dev, so a plain name that is also an ip keyword is still read as a name.
…tart making kryptik0
This was referenced Oct 9, 2026
DevomB
added a commit
that referenced
this pull request
Oct 9, 2026
An altname sits in the same name table as names and moves with the NIC, so a net zone that gave its NIC the altname kryptik0 stopped every later start making the bridge, as #304's plain names otherwise prevent. The alias is free text that ip link prints. reset_nic now reads both with RTM_GETLINK, removes the altnames with RTM_DELLINKPROP and drops the alias with the address and MTU. mac_of was test-only, which the release build refused.
DevomB
marked this pull request as ready for review
October 9, 2026 13:21
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.
What was wrong. The net zone holds
CAP_NET_ADMINin its own namespace, so it can rename its NIC to anything the kernel'sdev_valid_nametakes. That excludes only/,:and whitespace, so a leading dash, a quote, an escape and bytes that aren't UTF-8 all pass. When the zone ends, the kernel returns the NIC to zone 0 under that name, and the next start handed it on as it was. A compromised net zone could therefore shape the zone that replaces it:physical_interfaces_underread names withto_string_lossy, socarry_niclooked up a name that does not exist. The net zone crash-looped and the machine stayed offline until a reboot; the restart meant to give a fresh zone did not.netzone-init.sh. A quote ended the name in the nft uplink set ("$n"at line 52), sox","kryptik0puts the bridge in it. A leading dash reached dhcpcd as an option ("$@").What changed.
compartments/kryptikd/src/netzone.rs:physical_interfaces_underreturns each physical interface's name as the kernel holds it (anOsString), with its index from sysfs.physical_interfacespasses on a plain name (a lower-case letter, then lower-case letters and digits, as the kernel and eudev name NICs, and notkryptik0: the start makes that bridge in the zone after the NICs move, and a NIC by that name would fail it with EEXIST). It renames any other name to the kernel'snic%dtemplate by index before the NIC moves, and logs the old name escaped. A returned NIC is down, as a rename needs. One that cannot be renamed is left in zone 0, with the reason logged.compartments/kryptikd/src/netlink.rs:rename_index(RTM_NEWLINK with IFLA_IFNAME by index) andname_of(if_indextoname).tools/net/netzone-init.sh:uplink_addrnames the device to ip withdev, so a plain name that is also an ip keyword, such asup, is still read as a name.netzone::tests::only_plain_names_pass_oncovers the class, including-k,x","kryptik0, an escape,kryptik0and\xff.netlink::tests::rename_by_index_takes_a_templatemakes a veth namedx"yin a user and network namespace of its own, renames it by index tonic%d, and reads backnic0under the same index.build/guest-tests/zones-check.sh: the new checkuplink-renamed-plainrenames the net zone's NIC-x"yfrom inside the zone and stops the service. It sees the NIC back in zone 0 under that name, starts the service again, and passes only on a newREADYline withuplinks=nic<N>and nothing left in zone 0. Then it stops the service, names the NICeth0again and restarts, for the checks that follow.tools/image/zones-test.sh: lists the verdict on a line of its own, which merges with Every claim in docs/architecture.md about what zones cannot share or reach has a guest check #280's, The net zone runs on one CPU's worth of time, and the zones suite reads its limit back #295's and The clock query and the update fetcher give up every capability before they read from the network #300's changes to that list.docs/design/net-zone.md: the gateway-failure bullet on what comes back to zone 0, and the tests.How the run proves it. CI runs both unit tests. On main the rename test does not compile, as
rename_indexis new. In the Distro run's zones suite,uplink-renamed-plainfails on main: the next start hands-x"ytonetzone-init.sh, whose nft set does not parse, so the zone reportsNOT READYand dhcpcd takes the name as options. With this change the zone comes upREADYonnic0.Reported by linux-distro-fe, who widened it from the crash loop to the nft set and dhcpcd.