Repository navigation
fuzz(flatbuf): add fuzz harness for FunctionCall/FunctionCallResult decode - #1878
Devendrakumarsinha wants to merge 1 commit into
Conversation
23dfa02 to
5d2b524
Compare
…ecode Add a libfuzzer-based fuzz target that directly exercises the FlatBuffers decode path for FunctionCall and FunctionCallResult — the host-side parsing of guest-controlled wire data arriving via the G2H virtqueue. Previously these decode paths had no direct fuzz coverage; existing fuzzers (guest_call, host_call) exercise them only indirectly through a full sandbox. This harness isolates the parsing logic without requiring a hypervisor. Uses a BoundedSource that mirrors RecvChain semantics: take_bytes/take_chunks reject reads beyond available data, matching production behavior. Initial run (~1M iterations): - Coverage: ~960 branch points - exec/s: ~110,000 - No crashes found Signed-off-by: Devendra Kumar Sinha <devendrasinha.me@gmail.com>
5d2b524 to
4c0441d
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The harness does not currently reproduce production control and external-payload boundaries or trailing-byte validation.
3 open findings
What changed in this PR
Adds a fast fuzz target for FlatBuffers function call decoding without a hypervisor.
Changes:
- Adds bounded external-value fuzzing.
- Registers the fuzz target and dependencies.
- Updates fuzz-generated file exclusions.
| File | Description |
|---|---|
fuzz/fuzz_targets/flatbuf_decode.rs |
Implements the decode harness. |
fuzz/Cargo.toml |
Registers the target and dependencies. |
fuzz/.gitignore |
Updates fuzz output exclusions. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| fn finish(&mut self) -> anyhow::Result<()> { | ||
| Ok(()) |
| fuzz_target!(|data: &[u8]| { | ||
| let _ = FunctionCall::decode(data, &mut BoundedSource::new(data)); | ||
| let _ = FunctionCallResult::decode(data, &mut BoundedSource::new(data)); | ||
| }); |
| coverage | ||
| corpus/ | ||
| artifacts/ | ||
| *.log |
|
Hey @Devendrakumarsinha , thanks for the contribution! This looks very reasonable although those few comments from copilot about mirroring production code is worth addressing 🙂 |
Benchmark ResultsMeasured commit: kvm / amd (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
kvm / intel (Linux) (❌ 2.05x)Top regressions
Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
mshv3 / amd (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
mshv3 / intel (Linux) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
hyperv-ws2025 / amd (Windows) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
hyperv-ws2025 / intel (Windows) (➖ stable)No benchmark improved or regressed. Benchmark Resultsfunction_call_codec
payload_allocation
sandboxes
slot_pool
snapshot_files
virtq_readonly
virtq_readwrite
Reported by |


Summary
Adds a libfuzzer-based fuzz target that directly exercises the FlatBuffers
decode path for
FunctionCallandFunctionCallResult— the host-sideparsing of guest-controlled wire data arriving via the G2H virtqueue.
Motivation
Existing fuzzers (
guest_call,host_call) exercise these decode pathsonly indirectly through a full sandbox with a running hypervisor. This
harness isolates the parsing logic without requiring KVM or Hyper-V,
enabling faster iteration and broader input coverage.
Design
BoundedSourcemirrorsRecvChainsemantics:take_bytes/take_chunksreject reads beyond available data, matching production behavior and
avoiding false OOM positives from unbounded test allocators.
Results
Testing