Repository navigation
fix(minimald): raise guest inotify limits and restrict the kernel log at boot - #1940
Conversation
… at boot Every box on a microVM maps onto the daemon's one kernel uid, so the per-uid inotify counters and the kernel log are shared by every session on the VM. Raise the inotify ceilings to the common dev-machine values and set kernel.dmesg_restrict, best effort, from the microVM init only. Refs gominimal/inbox#824
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 5 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe guest module defines three kernel sysctl settings and writes them under ChangesMicroVM sysctl setup
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to MicroVM startup attempts to apply the inotify limits and restrict kernel-log access before serving boxes; individual write failures are warned and do not stop startup. No concrete merge-blocking risk was found. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
A rabbit checks the kernel’s list Comment |
|
Approved: no findings at Nothing to do. Clobber: none: |
Summary
Every box on a microVM maps onto the guest daemon's single kernel uid. Two VM-wide kernel defaults therefore weaken isolation and fairness between the sessions that share a VM:
tsc --watch, language servers) can use the whole allowance, and then watchers in every other session on the VM fail withEMFILE/ENOSPC.kernel.dmesg_restrictat 0, any box can read the VM's kernel log, and that log includes records about other sessions' processes.At boot, the microVM's init (and only it, never a host-native daemon) now writes:
fs.inotify.max_user_instancesfs.inotify.max_user_watcheskernel.dmesg_restrictThe inotify values are the common dev-machine settings. They are ceilings, not reservations. A watch costs about 1 KiB of kernel memory on 64-bit, but only while it exists, and the memory is charged to the memory cgroup of the box that holds it. The full 524288 (about 512 MiB) is reached only if boxes actually watch that many files. With
dmesg_restrictset, reading the kernel log needsCAP_SYSLOG, and no box holds it.The writes are best effort. A setting the kernel refuses is logged as a warning and boot carries on, because the kernel default is the previous behaviour. The settings live in a table,
guest::MICROVM_SYSCTLS, and the write helper takes the/proc/sysroot as a parameter, so both are unit-tested against a temp dir.Refs gominimal/inbox#824
Test plan
just ci(macOS scope): local PR gates greencross test -p minimald --lib --target aarch64-unknown-linux-musl --locked -- guest:::test result: ok. 16 passed; 0 failed, including the two new testscross clippy -p minimald --all-targets --target aarch64-unknown-linux-musl --locked -- -D warnings: clean8192,524288, and1from/proc/sys,dmesgfails as the box user withread kernel buffer failed: Operation not permitted, and the guest log has no sysctl warnings.Summary by CodeRabbit