Skip to content

feat: replace b-prefixed Rust coreutils with BusyBox#234

Merged
ryanbreen merged 1 commit intomainfrom
feat/busybox-coreutils-replacement
Feb 19, 2026
Merged

feat: replace b-prefixed Rust coreutils with BusyBox#234
ryanbreen merged 1 commit intomainfrom
feat/busybox-coreutils-replacement

Conversation

@ryanbreen
Copy link
Owner

Summary

  • Replace 14 hand-rolled Rust coreutils (bcat, bls, becho, bhead, btail, bwc, bcp, bmv, brm, bmkdir, brmdir, btrue, bfalse, bwhich) with BusyBox 1.37.0 cross-compiled as a static musl binary
  • Fix aarch64 struct stat layout — x86_64 uses a 144-byte layout while aarch64 uses a 128-byte asm-generic layout with different field order and widths. The mismatch caused a 16-byte stack buffer overflow corrupting saved x29/x30 registers, resulting in INSTRUCTION_ABORT at ELR=0x0
  • Fix ELF loader buffer overflow for non-page-aligned segments on both architectures
  • BusyBox provides 60+ utilities (cat, ls, sed, awk, find, sort, vi, ash shell, etc.) in a single ~1MB binary

Test plan

  • x86_64 kernel builds with zero warnings
  • aarch64 kernel builds with zero warnings
  • Compile-time size assertions verify struct Stat is 144 bytes (x86_64) and 128 bytes (aarch64)
  • x86_64 boot test passes
  • aarch64 boot test passes (no more INSTRUCTION_ABORT crashes)
  • BusyBox applets (cat, ls, etc.) accessible via symlinks in /bin

🤖 Generated with Claude Code

…uct stat

Replace 14 hand-rolled Rust coreutils (bcat, bls, becho, etc.) with
BusyBox 1.37.0 cross-compiled as a static musl binary. BusyBox provides
cat, ls, head, tail, wc, grep, cp, mv, rm, mkdir, rmdir, echo, true,
false, which, plus sed, awk, find, sort, vi, ash shell, and 40+ more
utilities in a single ~1MB binary.

Key changes:
- Add scripts/build-busybox.sh for cross-compiling BusyBox (x86_64/aarch64)
- Update ext2 disk script to install BusyBox with symlinks instead of
  b-prefixed binaries
- Delete 14 Rust coreutil sources and their Cargo.toml [[bin]] entries
- Update all test programs to reference unprefixed paths (/bin/cat vs /bin/bcat)
- Fix aarch64 struct stat layout: x86_64 uses 144-byte layout while
  aarch64 uses 128-byte asm-generic layout with different field order
  (mode/nlink swapped) and widths (nlink u32, blksize i32). The mismatch
  caused a 16-byte stack buffer overflow corrupting saved x29/x30,
  resulting in INSTRUCTION_ABORT at ELR=0x0.
- Fix ELF loader buffer overflow for non-page-aligned segments on both
  architectures

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@ryanbreen ryanbreen merged commit adaa98c into main Feb 19, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant