18. Crossing into the Lima VM
18. Crossing into the Lima VM¶
Plan 2's Mac runner runs on the Mac and keeps its sandboxes in a Lima VM (#17). Four things cross between them: the helper's socket, staged and running workspaces, CRI logs, and the pod-to-run map. This checks how each behaves, and that pods stay boxed in inside the VM.
Predictions¶
Written before running. #17's template plus one writable virtiofs mount
(the share) and one portForwards socket entry, in a scratch LIMA_HOME.
| Question | Expected |
|---|---|
plain: true honours an explicit mount and socket forward |
no: plain mode drops both, and non-plain needs its defaults turned off one by one |
A socket listened on in the VM appears at hostSocket and carries a request and reply |
yes |
SO_PEERCRED in the VM for a forwarded connection |
the Lima user's uid (the forwarder is its SSH session) |
| One VM user renames another's setgid directory between two directories on the share | yes, as on Linux, if virtiofs honours group permissions |
| Files written in the share by VM root or another VM uid, seen on the Mac | owned by the Mac user |
makeRemovable + RemoveAll on the Mac clear a 0500 directory holding a 0400 file written by VM root |
yes |
| A file appended in the VM every 100 ms, read on the Mac | growth visible within 200 ms |
A gVisor pod on allmyram-egress with egress.nft loaded, direct TCP to the VM's gateway, the Mac's LAN and tailnet addresses, and IPv6 |
all blocked; a canary on the Mac sees nothing |
| Running VM's idle footprint at 4 GiB and 8 GiB | under #17's 791 MB at 4 GiB |
Setup (2026-11-23)¶
- The MacBook and Lima 2.3.0 as in #17.
LIMA_HOME=/tmp/claude-501/l18(never~/.lima); instancex18fromspike/lima_crossings.yaml: #17's template plus a writable virtiofs mount of/tmp/claude-501/l18shareat/var/lib/allmyram/shareand aportForwardsentry from/run/allmyram-x18/helper.sockto/tmp/claude-501/l18/helper.sock. spike/lima_egress_check.py: Plan 1'sdeploy/linuxegress bridge, nft table and CNI config in the VM,spike/egress_proxy.pyon10.78.0.1:3128, a gVisor probe pod, and a canary on the Mac on[::].
Raw results¶
- Plain mode ignores both: Lima logs "Running in plain mode. Mounts,
dynamic port forwarding, containerd, etc. will be ignored. Guest agent
will not be running", and neither the mount nor the socket appeared.
With
plain: false,containerd: {system: false, user: false},ssh.forwardAgent: false, no other mounts, and a finalportForwardsruleguestPortRange: [1, 65535], guestIP: 0.0.0.0, ignore: true, the share is the VM's only virtiofs mount and Lima logs "Not forwarding" for every TCP and UDP port the VM listens on,[::]and loopback included. - Socket forward: works. The Mac side is
srw-------owned by the Mac user. In the VM,SO_PEERCREDreports uid 0, processlima-guestagent. - Ownership on the share: inside the VM every entry shows
0:0, whoever made it.chgrpis ignored and the setgid bit is dropped (chmod 2770reads back0770). On the Mac everything is owned by the Mac user (501). A VM user that is neither the owner nor in the group renamed a0770directory fromstaging/toworkspaces/: the share doesn't enforce permissions. A gVisor job running as uid 1000 wrote files and made directories in a bind-mounted workspace the VM shows as0:00770(this did not hold later; see the correction below). - Cleanup: on the Mac,
chmod -R u+rwxthenrm -rfremoved a0500directory holding a0400file written by VM root. - Log growth: a line appended in the VM every 100 ms was seen on the Mac after 1 / 8 / 13 / 27 ms (min / median / p95 / max of 100 lines).
- Egress in the VM:
| Probe from a gVisor pod | Outcome |
|---|---|
https://example.com through 10.78.0.1:3128 |
200 |
Direct TCP 1.1.1.1:443, [2606:4700:4700::1111]:443 |
network unreachable |
| Direct TCP to the canary at the VM's gateway (192.168.5.2, the Mac), the VM (192.168.5.15), the Mac's two LAN and its tailnet addresses | network unreachable |
Direct TCP 10.78.0.1:22 and :53 (the VM's sshd listens on all addresses; routed, on the pod's own bridge) |
timed out; nft's iifname "allmyram-e0" drop counted 15 packets |
| Canary connections on the Mac | none |
- Idle footprint (running VM, 30 s and 60 s after start): 699 / 701 MB at 8 GiB, 617 / 617 MB at 4 GiB.
What we learned¶
- Every crossing Plan 2 needs works, but only outside plain mode, with plain's other effects turned off by hand.
- The helper's caller in the VM is Lima's guest agent, as root. Who may call the helper is then decided on the Mac: the forwarded socket is the Mac user's alone.
- The share enforces no permissions in the VM, in either direction. Plan 1's staging group, setgid directories and the runner uid for jobs don't protect anything here. Keeping other VM processes out of the share has to be done on the VM's own disk, on the directory above the mount point. Jobs can write their workspace whatever uid they run as (wrong for gVisor; see the correction below).
- Forced egress holds in the VM, both layers. The pod's only route is its bridge, and nft drops what the route allows. The Mac saw nothing.
- About 600–700 MB idle, mostly fixed. Halving the VM's memory saved only 84 MB.
What it changes¶
- Plan 2's VM template:
plain: falsewith the settings above. - The helper in the VM:
allowed_uid0. Its staging and workspace roots are on the share, with no staging group./var/lib/allmyramis0750root:allmyram-helper, so only root, the helper and members of its group reach the share.
Correction (2026-11-24)¶
The claim above that a gVisor job running as uid 1000 wrote into a 0:0
0770 workspace on the share did not hold under Task 9a's probes, and what
was actually observed then is unknown. On a real Mac runner a job running
as allmyram-job (uid 994) failed to start: failed to find initial working
directory "/workspace/meristem": permission denied. The VM's kernel
enforces no permissions on the share, but gVisor checks mode bits itself
against the 0:0 it is shown, so a job that isn't uid 0 is refused a
0770 directory there. Opening the modes doesn't help: with /workspace
at 0777, a directory the job makes reads back 0:0 0755 and the job
can't write into it.
So a running workspace can't live on the share. The warden in the VM copies
a run's staged workspace onto the VM's own disk
(/var/lib/allmyram/warden/workspaces), owned by the job's uid, and removes
it at Stop. Its unit gains CAP_CHOWN, CAP_FOWNER and CAP_DAC_OVERRIDE
in the VM only. The share keeps staging/, logs/ and pods/; it has no
workspaces/.