Repository navigation
[Bug Bash] microVM: set containerd's default masked and read-only paths - #3249
Conversation
141aa70 to
f516aa1
Compare
Walter Fender (cheftako)
left a comment
There was a problem hiding this comment.
Before this change a uid 0 container could tune guest sysctls at runtime, such as sysctl -w vm.max_map_count=..., vm.overcommit_memory or net.core.somaxconn. Entrypoints that do this and exit on failure will now crash. So if we want this change we should get it in prior to GA.
a41525b to
9d5ee4a
Compare
That's fair. I added a note to the PR description for this. |
|
/lgtm |
626fdd2 to
276d6b6
Compare
Tim Hockin (thockin)
left a comment
There was a problem hiding this comment.
I am approving -- Benjamin Elder (@BenTheElder) do we wait for dirs, too or merge this and consider followup. This is a subtle area.
A uid 0 container is root in the guest kernel, and with no read-only paths it could write the guest's /proc/sys. Signed-off-by: Huy Pham <[email protected]>
Any error passed before, so the test could pass when the write failed for another reason. Signed-off-by: Huy Pham <[email protected]>
Also list the read-only paths one per line, like the masked paths. Signed-off-by: Huy Pham <[email protected]>
The gVisor write now has to fail with permission denied, so an error like ENOENT no longer passes. On microVM, /proc/interrupts has to read as empty, which shows the /dev/null mask is in force. Signed-off-by: Huy Pham <[email protected]>
Signed-off-by: Huy Pham <[email protected]>
Signed-off-by: Huy Pham <[email protected]>
276d6b6 to
8e16eda
Compare
Thanks for looking into this. I think we should just do dirs now; I've adjusted the PR. |
Benjamin Elder (BenTheElder)
left a comment
There was a problem hiding this comment.
Non-blocking follow-ups. Thanks!
Pass goarch into guestMaskedDirPaths so both arches are unit tested, and say ShapeMicroVM applies a subset of containerd's masked paths. Signed-off-by: Huy Pham <[email protected]>
…hs (#3249) <!-- The PR title becomes the release note. Write it for users. --> > Why is this needed? (Or link the issue. Open one first for features, API, install or CI changes.) On microVM, an actor’s container runs as uid 0 in the guest kernel. Before this PR, the worker sent kata-agent empty masked and read-only path lists. That left the guest’s `/proc/sys` writable: the kernel lets uid 0 write sysctls without any capability. The kata-agent skips masked paths that are directories. Of the five directories, only `/proc/acpi` and `/sys/firmware` exist in the kata 4.3.1 guest kernel. We mount read-only tmpfs similar to [runc](https://github.com/opencontainers/runc/blob/4ca628d1d4c974f92d24daccb901aa078aad748e/libcontainer/rootfs_linux.go#L1250-L1258). **Breaking change**: a uid 0 entrypoint can no longer write guest sysctls, such as `sysctl -w vm.max_map_count=...`. This already fails on gVisor. Goldens and checkpoints taken before this change keep a writable `/proc/sys` until they are re-taken. Part of #3226. <!-- e.g. "AI-assisted, I reviewed and tested it." No AI co-author trailers. --> AI use: AI-assisted, I reviewed and tested it. <!-- Breaking change? Describe what users must do on upgrade and ask for the `breaking-change` label. --> - [x] Tests pass - [ ] Docs updated --------- Signed-off-by: Huy Pham <[email protected]> (cherry picked from commit 4488a66) Signed-off-by: Eitan Yarmush <[email protected]>
On microVM, an actor’s container runs as uid 0 in the guest kernel. Before this PR, the worker sent kata-agent empty masked and read-only path lists. That left the guest’s
/proc/syswritable: the kernel lets uid 0 write sysctls without any capability.The kata-agent skips masked paths that are directories. Of the five directories, only
/proc/acpiand/sys/firmwareexist in the kata 4.3.1 guest kernel. We mount read-only tmpfs similar to runc.Breaking change: a uid 0 entrypoint can no longer write guest sysctls, such as
sysctl -w vm.max_map_count=.... This already fails on gVisor. Goldens and checkpoints taken before this change keep a writable/proc/sysuntil they are re-taken.Part of #3226.
AI use: AI-assisted, I reviewed and tested it.