Skip to content

fix: harden cocoon for sub-1500-MTU / high-vCPU cloud hosts (CH rlimits + CNI MTU/MSS)#135

Merged
CMGS merged 4 commits into
masterfrom
fix/cocoon-cloud-host-hardening
Jul 16, 2026
Merged

fix: harden cocoon for sub-1500-MTU / high-vCPU cloud hosts (CH rlimits + CNI MTU/MSS)#135
CMGS merged 4 commits into
masterfrom
fix/cocoon-cloud-host-hardening

Conversation

@CMGS

@CMGS CMGS commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Two independent robustness fixes surfaced while validating cocoon on a GCP C4A
(arm64) host, each verified on that hardware.

1. Raise RLIMIT_MEMLOCK / RLIMIT_NOFILE before launching the VMM (hypervisor/cloudhypervisor/start.go)

Cloud Hypervisor allocates an io_uring ring plus eventfds per virtio-blk queue, and
num_queues scales with vCPU. A high-vCPU multi-disk guest — e.g. an 8-vCPU, 10-disk
Android VM = 80 queues — exhausts the process defaults (RLIMIT_MEMLOCK ~93 MiB,
RLIMIT_NOFILE soft 1024) and fails:

virtio device activation failed: CloneEventFd(... "Too many open files")
thread 'vmm' panicked ... -> CH aborts

(preceded by failed to create new AsyncIo: I/O error once memlock is exhausted).
raiseVMMRlimits lifts both before the fork; the VMM inherits them.

Verified (arm64 testbed): without the fix an 8-vCPU VM needs a manual
ulimit -l unlimited; ulimit -n 1048576 wrapper to boot; with it, a plain
cocoon vm run --cpu 8 --memory 8G boots in ~29 s with 0 io_uring/disk errors.

2. Match CNI bridge MTU to the host + clamp forward MSS (doctor/check.sh)

On a host whose egress MTU is below the CNI bridge default 1500 (GCP is 1460),
guests silently blackhole large DF packets: small requests and ping work, but reaching
a CDN with a big TLS cert chain times out (the VM sends 1500-byte segments that the
1460-MTU host egress drops, and the ICMP frag-needed never makes it back). Fix:

  • set the bridge mtu in the generated conflist to the detected host egress MTU, and
  • add a mangle FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
    rule so existing hosts are fixed immediately, without a bridge rebuild.

Verified (arm64 testbed): before, curl https://p0.meituan.net from a guest times
out after 8 s (0 bytes); after the clamp it returns in ~0.2 s. The conflist regenerates
with "mtu": 1460 on a GCP host.

CMGS added 4 commits July 16, 2026 16:13
Cloud Hypervisor allocates an io_uring ring plus eventfds per virtio-blk queue,
and num_queues scales with vCPU, so a high-vCPU multi-disk guest (e.g. an 8-vCPU
10-disk Android VM = 80 queues) exhausts the default RLIMIT_MEMLOCK (~memlock) and
RLIMIT_NOFILE (1024), failing disk activation with 'AsyncIo: I/O error' then
'Too many open files' VMM panic. Lift both before fork; the VMM inherits them.
On a host whose egress MTU is below the CNI bridge default 1500 (GCP is 1460),
guests silently blackhole large DF packets (TLS/data), so e.g. reaching a CDN with
a big cert chain times out while ping/small requests work. Set the bridge mtu to
the detected host MTU in the generated conflist, and add a mangle FORWARD
TCPMSS --clamp-mss-to-pmtu rule so existing hosts are fixed without bridge rebuild.
Remove unnecessary comments about VMM resource limits.
…recracker

The rlimit raise sat in the CH-specific launch path, but Firecracker also forks a
VMM with an io_uring block engine (IoEngine=Async) and hits the same
RLIMIT_MEMLOCK/NOFILE exhaustion. Both backends go through Backend.LaunchVMProcess,
so raise the limits there, right before spec.Cmd.Start().
@CMGS
CMGS merged commit 8b18266 into master Jul 16, 2026
4 checks passed
@CMGS
CMGS deleted the fix/cocoon-cloud-host-hardening branch July 16, 2026 08:45
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.

1 participant