-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from p4zuu/insn_decoder_fuzzing
fuzz: add x86 instructions decoder harness
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#![no_main] | ||
|
||
use libfuzzer_sys::{fuzz_target, Corpus}; | ||
use svsm::cpu::insn::{Instruction, MAX_INSN_SIZE}; | ||
|
||
fuzz_target!(|input: &[u8]| -> Corpus { | ||
let Some(input) = input.get(..MAX_INSN_SIZE) else { | ||
return Corpus::Reject; | ||
}; | ||
|
||
let mut data = [0u8; MAX_INSN_SIZE]; | ||
data.copy_from_slice(input); | ||
|
||
let mut insn = Instruction::new(data); | ||
let _ = core::hint::black_box(insn.decode()); | ||
|
||
Corpus::Keep | ||
}); |