Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3719609
Syscall rewriter: interface changes, no_std support, and bug fixes
wdcui Apr 2, 2026
bcb8f98
Syscall rewriter: harden ELF rewrite edge cases
wdcui Apr 4, 2026
eeca867
Fix syscall rewriter formatting
wdcui Apr 4, 2026
5081c53
address review comments
wdcui Apr 7, 2026
98ea175
fixed a bug introduced in the last commit
wdcui Apr 7, 2026
9fc38e2
Remove fork-to-vfork patching from syscall rewriter
wdcui Apr 8, 2026
0446a21
Refactor syscall rewriter API: return skipped addrs, improve error va…
wdcui Apr 8, 2026
ec58ba7
Trampoline format: redzone reservation, R11 restart, RIP-relative re-…
wdcui Apr 2, 2026
6818dd7
Fix CI: 32-bit build, Windows redzone callback, rustfmt
wdcui Apr 2, 2026
adbfd9a
Runtime ELF patching and rtld_audit removal
wdcui Apr 2, 2026
0b2c432
Fix Windows CI: suppress dead_code warning for syscall_callback extern
wdcui Apr 2, 2026
d7ee8e8
Fix Windows CI: remove rtld_audit.so from Windows test (incompatible …
wdcui Apr 2, 2026
dc399b6
Windows: preserve guest R11 across syscall callback via TEB.Arbitrary…
wdcui Apr 2, 2026
0d3b29b
Remove rtld_audit, fix RFLAGS on Windows, simplify callback dispatch,…
wdcui Apr 2, 2026
68c634f
Clean up rewriter: remove unit tests, revert bun footer to suffix che…
wdcui Apr 3, 2026
231691d
Fix signal handler to check both callback entry points, add short-rea…
wdcui Apr 3, 2026
7e79881
Fix integration tests: replace OUT_DIR with CARGO_TARGET_TMPDIR
wdcui Apr 3, 2026
f1349cc
Run cargo fmt --all (comment alignment after rebase)
wdcui Apr 5, 2026
9d900b0
Address PR #739 review comments
wdcui Apr 8, 2026
8ea3756
Fix rebase conflicts: adapt pr1b code to pr1c API changes
wdcui Apr 8, 2026
4aaa78a
Cross-platform packager: remove Linux-only gates, add OCI symlink res…
wdcui Apr 3, 2026
dd357a8
Fix OCI whiteout symlink pruning and degenerate symlink target resolu…
wdcui Apr 3, 2026
5fbdeab
Remove no-op build.rs from litebox_packager (rtld_audit fully removed)
wdcui Apr 3, 2026
9ebf54f
Preserve tar header permissions for cross-platform OCI extraction
wdcui Apr 3, 2026
ca194cb
Fix path traversal in OCI extraction, root-level opaque whiteout bug,…
wdcui Apr 5, 2026
74b27eb
Address PR #741 review comments
wdcui Apr 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,20 @@ jobs:
tool: nextest@${{ env.NEXTEST_VERSION }}
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --locked --verbose --all-targets --all-features -p litebox_runner_linux_on_windows_userland
- run: cargo clippy --locked --verbose --all-targets --all-features -p litebox_packager
- run: cargo build --locked --verbose -p litebox_runner_linux_on_windows_userland
- run: cargo build --locked --verbose -p litebox_packager
- run: cargo nextest run --locked --profile ci -p litebox_runner_linux_on_windows_userland
- run: cargo nextest run --locked --profile ci -p litebox_packager
- run: cargo nextest run --locked --profile ci -p litebox_shim_linux --no-default-features --features platform_windows_userland
- run: |
cargo test --locked --verbose --doc -p litebox_runner_linux_on_windows_userland
cargo test --locked --verbose --doc -p litebox_packager
# We need to run `cargo test --doc` separately because doc tests
# aren't included in nextest at the moment. See relevant discussion at
# https://github.com/nextest-rs/nextest/issues/16
- name: Build documentation (fail on warnings)
run: cargo doc --locked --verbose --no-deps --all-features --document-private-items -p litebox_runner_linux_on_windows_userland
run: cargo doc --locked --verbose --no-deps --all-features --document-private-items -p litebox_runner_linux_on_windows_userland -p litebox_packager

build_and_test_snp:
name: Build and Test SNP
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dev_bench/unixbench/prepare_unixbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ def prepare_benchmark(
"""
Prepare a single benchmark using litebox_packager.
The packager discovers dependencies, rewrites all ELFs, and creates a tar
(including litebox_rtld_audit.so). The rewritten main binary is extracted
The packager discovers dependencies, rewrites all ELFs, and creates a tar.
The rewritten main binary is extracted
from the tar and placed alongside it.
Returns True on success.
Expand Down
1 change: 0 additions & 1 deletion dev_tests/src/boilerplate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ const SKIP_FILES: &[&str] = &[
"LICENSE",
"litebox/src/sync/mutex.rs",
"litebox/src/sync/rwlock.rs",
"litebox_rtld_audit/Makefile",
"litebox_runner_linux_on_windows_userland/tests/test-bins/hello_exec_nolibc",
"litebox_runner_linux_on_windows_userland/tests/test-bins/hello_thread",
"litebox_runner_linux_on_windows_userland/tests/test-bins/hello_thread_static",
Expand Down
1 change: 0 additions & 1 deletion dev_tests/src/ratchet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ fn ratchet_globals() -> Result<()> {
("litebox_platform_lvbs/", 23),
("litebox_platform_multiplex/", 1),
("litebox_platform_windows_userland/", 8),
("litebox_runner_linux_userland/", 1),
("litebox_runner_lvbs/", 5),
("litebox_runner_snp/", 1),
("litebox_shim_linux/", 1),
Expand Down
40 changes: 35 additions & 5 deletions litebox_common_linux/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ pub enum ElfParseError<E> {
BadTrampoline,
#[error("Invalid trampoline version")]
BadTrampolineVersion,
#[error("Binary not patched for syscall rewriting")]
UnpatchedBinary,
#[error("Unsupported ELF type")]
UnsupportedType,
#[error("Bad interpreter")]
Expand All @@ -141,6 +143,7 @@ impl<E: Into<Errno>> From<ElfParseError<E>> for Errno {
| ElfParseError::BadFormat
| ElfParseError::BadTrampoline
| ElfParseError::BadTrampolineVersion
| ElfParseError::UnpatchedBinary
| ElfParseError::BadInterp
| ElfParseError::UnsupportedType => Errno::ENOEXEC,
ElfParseError::Io(err) => err.into(),
Expand Down Expand Up @@ -218,6 +221,11 @@ impl ElfParsedFile {
})
}

/// Returns `true` if a trampoline was parsed and will be mapped by `load()`.
pub fn has_trampoline(&self) -> bool {
self.trampoline.is_some()
}

/// Parse the LiteBox trampoline data, if any.
///
/// The trampoline header is located at the end of the file (last 32/20 bytes).
Expand Down Expand Up @@ -251,7 +259,8 @@ impl ElfParsedFile {

// File must be large enough to contain the header
if file_size < header_size as u64 {
return Ok(());
// Too small for a trampoline header — binary is unpatched.
return Err(ElfParseError::UnpatchedBinary);
}

// Read the header from the end of the file
Expand All @@ -267,8 +276,9 @@ impl ElfParsedFile {
if &header_buf[0..7] == b"LITEBOX" {
return Err(ElfParseError::BadTrampolineVersion);
}
// No trampoline found, which is OK (not all binaries are rewritten)
return Ok(());
// No trampoline found. When using the syscall rewriter backend
// (syscall_entry_point != 0), all binaries must be patched.
return Err(ElfParseError::UnpatchedBinary);
}

let (file_offset, vaddr, trampoline_size) = if cfg!(target_pointer_width = "64") {
Expand All @@ -293,9 +303,11 @@ impl ElfParsedFile {
)
};

// Validate trampoline size
// trampoline_size == 0 means the rewriter checked this binary and found
// no syscall instructions. The magic header acts as a "checked" marker so
// the runtime skips eager code-segment patching. No trampoline to map.
if trampoline_size == 0 {
return Err(ElfParseError::BadTrampoline);
return Ok(());
}

// Verify the file offset is page-aligned (as required by the rewriter)
Expand Down Expand Up @@ -567,6 +579,24 @@ pub trait ReadAt {
fn size(&mut self) -> Result<u64, Self::Error>;
}

impl ReadAt for &[u8] {
type Error = Errno;

fn read_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<(), Self::Error> {
let offset: usize = offset.truncate();
let end = offset.checked_add(buf.len()).ok_or(Errno::EINVAL)?;
if end > self.len() {
return Err(Errno::EINVAL);
}
buf.copy_from_slice(&self[offset..end]);
Ok(())
}

fn size(&mut self) -> Result<u64, Self::Error> {
Ok(self.len() as u64)
}
}

pub trait MapMemory {
type Error;

Expand Down
43 changes: 0 additions & 43 deletions litebox_packager/build.rs

This file was deleted.

Loading
Loading