ebpf_core (//src/starnix/lib/ebpf)This package formally specifies and verifies the Starnix eBPF core crate (//src/starnix/lib/ebpf/core) using Charon, Aeneas, and Lean 4.
See //build/testing/formal_verification/README.md for the general verification architecture, spec/ vs. proof/ separation, spec/RISK.md / proof/RISK.md / REVIEW.md governance, and local toolchain setup.
spec/Assumptions.lean - External Host & Callback Assumptions:HostLayout and ValidHostLayout: 64-bit host virtual address assignment for the 512-byte eBPF stack, context/packet buffers, map descriptors, and array-map value buffers (ValidHostLayout enforces canonical (0, CANONICAL_USER_MAX] bounds on object bases and non-null handles for map descriptors, rather than non-overlapping ranges).CoreCallingContext and EntryStatesConform: entry-state preconditions on %r1..%r5, %r10 (frame pointer at stack offset 512), and uninitialized stack/register bits.ValidVerifierLogger: totality of the external CoreVerifierLogger trait (is_enabled, log_instruction, log_error).LinkageConformsLayout: correspondence between ProgramLinkageInfo.maps addresses (map_addr, data_addr) and HostLayout.mapAddr / HostLayout.mapDataAddr.spec/Spec.lean - eBPF VM Operational Semantics & Safety Properties:SafetyViolation: complete catalog of stuck states covering invalid PCs/jumps, invalid registers, writes to read-only %r10, out-of-bounds, stale-epoch (staleArrayPointer), or misaligned stack/memory/packet accesses, uninitialized stack reads, partial overwrite of spilled capabilities, pointer leaks to memory or return values, use-after-release, double-release, resource leaks on exit, and helper contract violations.step and runSteps: reference small-step and bounded-step operational semantics of decoded eBPF programs.SafeAndTerminating and NonInterfering: single-run memory/control-flow/resource safety and relational 2-safety non-interference (guaranteeing that neither KASLR pointer layouts nor uninitialized stack/register bytes leak into the return value or observable world state).ConcretizesRange64, ConcretizesScalar64, and ConcretizesScalar64Rel2: concretization predicates for the 64-bit and 32-bit abstract scalar domains.BackendSimulatesProgram and LinkedCodeMatchesProg (with StructAccessesWellFormed, findStructFieldTargetOffset, and LinkedInsnMatches): linking correspondence and simulation contract assumed of the host EbpfMachineBackend implementation (load_memory, store_memory, atomic_rmw32/64, atomic_cmpxchg32/64, call_helper, load_from_packet).spec/Contract.lean - Top-Level Verified Theorems:verify_program_core (verify_program_core_implies_safe_and_terminating, verify_program_core_implies_non_interfering, verify_program_core_struct_accesses_well_formed): these theorems currently prove partial correctness (= .ok (.Ok verified, logger') -> ...), guaranteeing safety, bounded termination, non-interference, and StructAccessesWellFormed metadata for any accepted program; they do not yet prove verifier panic-freedom, arithmetic-overflow-freedom, or termination (tracked in https://fxbug.dev/589873254).execute_core_loop1 (execute_core_simulates_run_steps) and joint satisfiability of the simulation contract (backend_simulates_program_satisfiable).link_instructions (link_instructions_preserves_length, link_instructions_matches_prog) and cbpf_to_ebpf_core (cbpf_to_ebpf_core_nonempty_on_ok), which also prove partial correctness (taking = .ok (.Ok ...) as a hypothesis rather than proving .ok in their conclusions).u64_range_add_sound, u64_scalar_add_sound, u64_scalar_bitand_sound, ebpf_instruction_set_code_roundtrip, apply_endianness_be_involutive).proof/Proof.lean & proof/Proof/ - Engineer-Editable Proofs:spec/Contract.lean with zero sorrys.:ebpf_verification_testSee //build/testing/formal_verification/TOOLCHAIN_SETUP.md for pinned Charon, Aeneas, Lean 4, mathlib, and nightly Rust setup instructions. After exporting LEAN_BIN_DIR, AENEAS_BIN_DIR, AENEAS_LEAN_DIR, and CHARON_RUST_TOOLCHAIN_DIR, run with the full Bazel label (works in any build directory without fx add-host-test):
fx test --host //src/starnix/lib/ebpf/verification:ebpf_verification_test
Without toolchains configured locally, fx test runs static Lean construct checks and reports SKIPPED (exit code 77).