Thanks for your interest in contributing! BoxKernel is a clean-room Rust implementation of the user-space rootfs and syscall translation features of Termux PRoot. BoxKernel prioritizes correctness, memory safety and measured performance. Intentional differences from C PRoot are supported when they are tested and documented.
Requirements:
- Linux (the tool instruments
ptrace,seccomp,process_vm_*) - Rust 1.85 or newer — pinned via
rust-toolchain.toml(rustfmtandclippycomponents are pulled automatically) - No other dependencies;
libcis the only crate dependency
$ git clone https://github.com/BoxOSLab/BoxKernel.git
$ cd BoxKernel
$ cargo build # debug build: target/debug/proot
$ cargo build --release # release build
$ cargo test # unit testssrc/ files carry comments naming the C function each one ports
(e.g. // port of translate_sysenter_end()). When fixing a bug:
- Reproduce first — write a shell/C reproducer, or better, run the relevant test from the upstream suite (see below).
- Consult the C reference to understand existing behavior. It is a reference implementation, rather than a requirement for identical outputs, internal design or edge cases.
- Preserve kernel FFI contracts and memory safety. Document deliberate changes to guest-visible behavior, including cache freshness, process layout or compatibility workarounds; add focused regression tests.
- Re-run the reproducer and Rust suite. Performance changes need a repeatable before/after measurement and must state their tradeoffs.
The C implementation's integration suite provides compatibility coverage. To run it against the Rust binary:
$ cd ../proot/tests # the C reference checkout
$ make -C . check PROOT=/path/to/BoxKernel/target/release/prootRecord the reference commit (git rev-parse HEAD) with the result:
test counts change as upstream adds coverage. Compare failures with the
baseline and distinguish intentional differences from accidental bugs.
Reference-suite parity is not a release gate; the Rust tests and the
quality gates below must pass. Current compatibility gaps and benchmark
results are recorded in the performance report.
CI runs all of these; run them locally before pushing:
$ cargo fmt --all -- --check
$ cargo clippy --all-targets --locked -- -D warnings
$ cargo test --locked
$ cargo deny check # license + advisory audit
$ cargo build --release --locked- Edition 2024, MSRV 1.85 — do not use APIs stabilized after 1.85.
unsafe_op_in_unsafe_fn = "deny"is set crate-wide.
unsafe is confined to the FFI boundary and to a few documented
islands:
| Location | Rule |
|---|---|
src/sys.rs |
The only place raw libc calls may appear. Every wrapper is a small safe function with a // SAFETY: comment. Callers keep C-style status/errno semantics. |
src/execve/elf.rs |
Union accessors (as32/as64/as32_mut/as64_mut) — ELF-class-validated, all-POD structs. |
src/tracee/event.rs |
Kernel-provided siginfo_t/utsname reads. |
loader/ |
Freestanding no_std naked functions and asm! — inherently unsafe, kept minimal. |
Rules for new code:
- No
static mut. Use atomics orthread_local!. - No
transmute/transmute_copy. Serialize POD structs throughsys::as_bytes/sys::as_bytes_mut; cross-field reads viaoffset_of!. - No raw pointers in safe function signatures. Machine words
(
usize) represent addresses/data insys::ptraceand friends. - Every remaining
unsafeblock needs a// SAFETY:comment stating the invariant it relies on. - If a safe
stdAPI exists with identical semantics, use it (e.g.std::os::unix::fs::MetadataExtinstead of re-readingstatfields) — but keep C-visible error semantics throughsys::wrappers when errno identity matters.
- Small, focused commits — one logical change each, following the
existing history (
Isolate unsafe…,Fix SIGTRAP re-delivery…). - Commit message: imperative subject line, why in the body when it is not obvious.
- Do not commit build artifacts or secrets;
target/is gitignored.
- Bugs: use the bug report template
and include
proot -v 9 …output where relevant. - Features: describe the intended behavior, performance evidence where relevant, and any differences from C PRoot.
Participation is governed by the Contributor Covenant.