feat(jailer): bwrap sandbox improvements and PID namespace watchdog fix#275
Merged
DorianZheng merged 4 commits intomainfrom Feb 16, 2026
Merged
feat(jailer): bwrap sandbox improvements and PID namespace watchdog fix#275DorianZheng merged 4 commits intomainfrom
DorianZheng merged 4 commits intomainfrom
Conversation
…tics Port Chrome's CanCreateProcessInNewUserNS() and CheckCloneNewUserErrno() from sandbox/linux/services/credentials.cc. Dual-probe approach: 1. Raw clone(CLONE_NEWUSER) for kernel-level errno diagnosis 2. bwrap --unshare-user for actual bwrap capability (handles AppArmor per-binary profiles where bwrap may work even if our clone fails) When bwrap fails, build_diagnostic() combines Chrome errno + sysctl detection to provide targeted fix commands for each scenario: - AppArmor restrict_unprivileged_userns (Ubuntu 23.10+) - kernel.unprivileged_userns_clone (Debian/older distros) - user.max_user_namespaces (RHEL/CentOS)
When bundled bwrap fails on Ubuntu 23.10+ with kernel.apparmor_restrict_unprivileged_userns=1, generate an AppArmor profile at ~/.boxlite/apparmor/boxlite-bwrap and include the `sudo apparmor_parser -r` command in the diagnostic. - Add apparmor.rs with generate_bwrap_profile() and write_bwrap_profile() - Profile mirrors Ubuntu's bwrap-userns-restrict with unique names (boxlite_bwrap/boxlite_unpriv_bwrap) to avoid collision - Caller in bwrap.rs computes apparmor_dir (Minimal Knowledge)
The bwrap sandbox was missing two critical mount categories: 1. ~/.boxlite/rootfs (ro) - VM init rootfs (Alpine bootstrap) 2. User volume host_paths - from BoxOptions.volumes Without the rootfs mount, libkrun couldn't boot the VM inside bwrap, causing the shim to exit immediately.
796983b to
ecdb49a
Compare
Add explicit unsafe block in credentials.rs for unsafe-op-in-unsafe-fn compliance and fix cargo fmt formatting in bwrap.rs.
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.
Summary
Test plan
cargo check -p boxlitepasses