

Petrel: A Userspace Linux Kernel for Unrooted OCI Containers
Named after the storm petrel — the smallest pelagic seabird, built to walk across rough ocean waves without sinking and desalinate toxic seawater through its dorsal tubenose. Petrel runs official docker (v27.5.1), docker compose (v2.32.4), and unmodified Linux/ARM64 OCI containers natively on unrooted Android Termux with zero VM and zero root.
- Hot-Path Pipe I/O
- 1.67M ops/s ~1.0× native · SECCOMP_RET_ALLOW
- Valkey / Postgres
- 59.2K / 2,692 req/s & pgbench TPS on phone
- Upstream Test Pass
- 140,000+ GCC · Go · Python · PG · Node · Zig
- QCOW2 Compaction
- 12.4 → 1.5 GiB Lossless SHA-256 atomic repack
Why Petrel: skimming the host kernel without sinking into a VM
Earlier efforts to run Linux containers on unrooted phones either sank into heavy QEMU virtual machines or wrapped processes in proot/udocker layers that trap every syscall twice and crash under Android 12+ SELinux rules. Every biological trait of the storm petrel maps directly to an architectural invariant across our ~32.5k-line Rust engine:
Skims Android's Linux kernel at ~1.0× speed (SECCOMP_RET_ALLOW) without sinking into a heavy VM or needing root.
Lifts unmodified Linux/ARM64 OCI containers via a #![no_std] loader while heavy bloat stays submerged.
Distills hostile Zygote SIGSYS traps (accept4, memfd SysV SHM, PF_X stack pivot) into clean POSIX in flight.
Survives GCC 3-stage bootstrap, Postgres, Go, and CPython inside one crash-safe ~/.docker/data/data.qcow image.
Every binary, Unix socket ($PREFIX/var/run/docker.sock), CoW materialization cache, and ~/.docker/data/data.qcow image stays strictly inside /data/data/com.termux/ with zero bundled host glibc.
Five Rust crates & official Docker CLI integration
Compiled cBPF router (RET_ALLOW / RET_ERRNO / RET_TRACE / RET_USER_NOTIF), 4-worker unotify pool, Zygote SIGSYS catcher, SA_RESTART dedup, VFS, /proc + /sys + cgroup v2, virtual inotify, memfd SysV SHM/SEM, and embedded 127.0.0.11 DNS + bridge networking.
Static binary linked at 0x20_0000_0000 inside Android's 39-bit VA space. Receives backing FDs via sentinel openat calls, maps guest PT_LOAD + ld-linux, builds Linux auxv, and pivots SP onto an 8 MiB RWX stack when PT_GNU_STACK requests PF_X.
64 KiB clusters (64 GiB default up to 4 TiB), FALLOC_FL_PUNCH_HOLE discard, dual-slot CRC32 ping-pong superblocks, Zstd+bincode catalog, (layer_idx << 48) | ino xino encoding, SHA-256 RO materialization cache, and crash-safe startup orphan GC.
Native rustls OCI puller, multi-stage classic Dockerfile builder, Hyper HTTP/1.1 + TCP upgrade framing over $PREFIX/var/run/docker.sock, lossless setup-disk compaction CLI, and minimal path patches for official Go docker v27.5.1 & docker-compose v2.32.4.
4-tier cBPF routing + static ELF handoff at 0x20_0000_0000
Before execve, every container root installs a compiled cBPF filter and hands its listener FD to the supervisor over SCM_RIGHTS. Guest binaries whose PT_INTERP points to /lib/ld-linux-aarch64.so.1 are loaded via a sentinel-driven #![no_std] stub linked high at 128 GiB so guest PIE/ET_EXEC mappings never collide:
# 1. Static AArch64 Loader @ 0x20_0000_0000 (inside Android's 39-bit 0x00..0x7f_ffff_ffff VA space)
openat("/\x01td_exec_meta") -> memfd ExecMeta (544 B: magic 0x5444455845430001, uid/gid, guest_exe)
openat("/\x01td_exec_bin") -> materialized guest ELF64 (PT_LOAD mmap + sub-page .bss zeroing)
openat("/\x01td_exec_interp") -> guest PT_INTERP (ld-linux-aarch64.so.1 / ld-musl-aarch64.so.1)
# If PT_GNU_STACK has PF_X (blocked on kernel [stack] by SELinux): pivot SP -> 8 MiB RWX + guard page
# 2. Sparse data.qcow ("TFS1" Ping-Pong Superblocks in Guest Clusters 0 & 1)
superblock = [magic "TFS1" | ver=1 | gen (u64) | catalog_ext | zstd_len | CRC32]
virtual_ino(layer, ino) = ((layer_idx as u64) << 48) | (raw_ino & 0x0000_FFFF_FFFF_FFFF) // xinoZero userspace context switches on the data plane — steady-state servers & databases run at ~1.0× native speed.
Forces Node.js 22 / libuv onto mediated epoll and prevents Android SELinux EACCES on POSIX copyfile reflinks.
Executes non-idempotent state transitions atomically, immune to Linux < 5.19 EINTR races under Go's 10 ms SIGURG.
Virtualizes VFS paths, permissions, short AF_UNIX sockets (<108B), and recovers Android-blocked glibc/Postgres syscalls.
| cBPF Tier | Execution Path | Representative Syscalls | Engineering Purpose |
|---|---|---|---|
| Tier 1 · SECCOMP_RET_ALLOW | 0-overhead host kernel | read, write, pread64, pwrite64, mmap, futex, epoll_*, pipe2, accept4, connected TCP sendto/recvfrom | Zero userspace context switches on the data plane — steady-state servers & databases run at ~1.0× native speed. |
| Tier 2 · SECCOMP_RET_ERRNO | In-kernel fast fail | io_uring_* (425..427) → -ENOSYS · ioctl(FICLONE / FICLONERANGE / FIDEDUPERANGE) → -EOPNOTSUPP | Forces Node.js 22 / libuv onto mediated epoll and prevents Android SELinux EACCES on POSIX copyfile reflinks. |
| Tier 3 · SECCOMP_RET_TRACE | Atomic ptrace stop | execve*, clone*, bind, connect, getsockname, mkdirat, unlinkat, renameat*, linkat, close, dup*, getpid, kill | Executes non-idempotent state transitions atomically, immune to Linux < 5.19 EINTR races under Go's 10 ms SIGURG. |
| Tier 4 · USER_NOTIF + SIGSYS | 4-worker pool + trap recovery | openat* (ADDFD), statx, getcwd, chmod/chown, inotify_*, AF_NETLINK, plus Zygote SIGSYS (accept→accept4, sem*, shmat) | Virtualizes VFS paths, permissions, short AF_UNIX sockets (<108B), and recovers Android-blocked glibc/Postgres syscalls. |
Battle-tested across 140,000+ upstream Linux tests
Hardware: Unrooted Android 12 · Linux 5.10.236 aarch64 · 8-core ARMv9 (Cortex-X2 / A710 / A510, 6.9 GiB RAM)
| Upstream Workload | Build & Suite Scope | Measured Result | Subsystems Verified |
|---|---|---|---|
| Go 1.24.2 | Self-bootstrap (./make.bash) + full stdlib/toolchain (./run.bash -k) | 351 / 351 pkgs (100%) | 10 ms SIGURG preemption, runtime/TestEINTR, cgo nptl_setxid, multi-threaded execve de_thread |
| CPython 3.13.2 | Native source build + full regrtest across 445 modules | 44,148 / 44,148 (100%) | /dev/shm POSIX semaphores, O_PATH, virtual HostBind hardlinks, PEP-383 non-UTF-8 paths, PTYs |
| GCC 14.2.0 | Full native 3-stage C/C++ bootstrap + official compiler testsuite | >71,000 pass (stage2 == stage3) | Bit-identical stage2/stage3 object code, OverlayFS xino, PT_GNU_STACK PF_X 8 MiB RWX pivot, LTO |
| PostgreSQL 17.12 | core + isolation + contrib + ecpg + multi-container pgbench (300K rows) | 613 / 613 suites · 2,692 TPS | Multi-process memfd SysV SHM (shmat/shmdt), SO_PEERCRED via sp-128 native connect, QCOW2 durability |
| Valkey 9.2.0 | TLS + jemalloc + LTO build · unit + 20-node cluster + Sentinel | 7,327 / 7,329 · 59,171 req/s | Live CoW fork() BGSAVE/AOF, /proc/self/smaps, ptrace group-stop, 100% Sentinel failover |
| Git 2.56.1 | Native build + C unit suite + shell waves (OverlayFS & HostBind) | 261 / 261 C + 12,500+ shell | Packfile mmap, async blocking FIFOs, shebang raw $0, virtualized PR_SET_DUMPABLE for ssh-agent |
| libuv v1.53.0 | Full official C event-loop & OS syscall suite (non-root tester) | 527 / 527 tests (100%) | sendmmsg, SO_REUSEPORT refcounting, IPv4/IPv6 multicast, inotify, /proc/uptime, DAC checks |
| Zig 0.17.1 | zig cc musl + 11 std groups + raw AArch64 svc #0 (-mcpu=baseline) | 1,177 / 1,177 std (100%) | Libc-free raw syscalls, io_uring → ENOSYS fallback, raw clone + futex threads |
| Node.js 22.23 + Vite 8.4 | 1,930 upstream tests (HTTP/HTTP2/TLS, sequential, PTY) + live HMR | 883/883 HTTP/TLS · 0 ukernel fails | HostBind kernel inotify bridge triggering sub-second container Vite HMR on phone edits |
Security model, metadata latency & active roadmap
- Compatibility Layer, Not a Hostile-Tenant Sandbox: Because Petrel runs unprivileged inside Termux's single Android UID (
untrusted_app) without a hypervisor, userspace mediation protects developer workflows against host clutter and syscall incompatibilities, not adversarial kernel-escape workloads (which require hardware VMs such as AVF/pKVM). - Data Plane vs. Metadata Storms: Compute, pipes (
0.60 µs/op), and connected TCP (8.87 µs/RTT) run at ~1.0× native speed onSECCOMP_RET_ALLOW, whereas metadata-heavy storms (stat/openat) incurseccomp_unotifyround-trips (~500–840 µs). - Platform Scope & Next Milestones: Targets unrooted Android 12+
aarch64devices (Linux >= 5.10). Active roadmap items includedocker save/load,docker login/push, step-level Dockerfile layer caching, and read-only metadata fast-path caching.