Repository navigation
Conversation
A Boxfile can now set data_size (512M, 10G, 1T); new Boxfiles say 10G. On firecracker /data is a disk of exactly that size, so the guest's own kernel refuses a write that does not fit. A larger data_size grows the disk offline, keeping its files; a smaller one is refused, since a filesystem cannot shrink in place. The snapshot's placeholder disk and its key use the same size, so a restored VM always sees the disk it gets. On podman and krun /data is a host directory shared over virtiofs, and a rootless process cannot put a quota on it, so box measures it: a sandbox over its limit does not start, and while one runs -- a cold run, an exec, a warm run, or a process left running in an up sandbox (a detached watcher) -- box checks every 2 seconds and stops the VM when it goes over. A fast writer can overshoot by what it writes in those 2 seconds; SECURITY.md and box inspect say so. A Boxfile without data_size keeps no limit there, and box inspect warns about it. Fixed on the way: - Every box upgrade, and every change to RAM, CPUs or /data's size, made a new firecracker image (a rootfs and a full memory snapshot, RAM-sized) and never removed the old one. The others are now deleted once the new one is built; a VM still restored from an old one keeps its files until it exits. - The tools image had no resize2fs; it now has (as fc-tools:2, so an old build is not reused), and a grow either completes or leaves the disk as it was. The escape suite gains a host disk check: on a fresh VM the guest writes 300M into a 64M /data. firecracker: the guest runs out of space at 64 MiB. podman and krun: box stops the sandbox and will not start it again. All three pass, no escapes. The in-guest pids limit is split out to #53. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Closes #10 (the /data part; the in-guest pids limit is split out to #53). Part of v0.5.
data_size:caps/data, so an agent cannot fill your disk. New Boxfiles saydata_size: 10G. On podman, a guest's/datareported the host's free space (1.2 GB left on the test machine): an agent writing in a loop would have filled the real disk.How it is enforced
/datais a disk ofdata_size; the guest's own kernel refuses a write that does not fit. A largerdata_sizegrows the disk offline, keeping its files; a smaller one is refused (a filesystem cannot shrink in place)./datais a host directory over virtiofs, and a rootless process cannot quota it. box refuses to start a sandbox that is over, and checks every 2 s during a cold run, anexec, a warm run, and — through a detached watcher — while anupsandbox sits between execs, stopping the VM when it goes over. A fast writer can overshoot by what it writes in 2 s;SECURITY.mdandbox inspectsay so.box inspectshows the limit, the usage and how it is enforced, warns when a sandbox has no limit, and fails when it is over.Fixed on the way
/data's size made a new image — a rootfs plus a RAM-sized memory snapshot — and the old ones were never removed. They are now deleted once the new one is built.resize2fs. Now it does (fc-tools:2, so an old build is not reused), and a grow either completes or leaves the disk exactly as it was.Tests
-race.box resetrecovers; anexecthat goes over brings the sandbox down; a background writer left in anupsandbox is brought down by the watcher (~8 s). firecracker — the guest runs out of space at 64M; raising to 128M grows the disk and keeps the files; lowering is refused; one image kept per sandbox./data. firecracker: the guest runs out of space at 64 MiB. podman strict and krun standard: box stops the sandbox and will not start it again. No escapes on all three.While writing that check, the suite's earlier fork-bomb test turned out to leave the running VM unable to start anything, which made a naive version of the check pass without writing a byte. It now runs on a fresh VM and requires evidence of the write being stopped.