-
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.
fuzz: add x86 instructions decoder harness
The x86 instructions decoder is very convenient attack surface. For the moment, the decoder code is only reachable from CPL-0, but it will be reachable from less privileged code when CPL-3 will be supported. The decoder is currently reachable from a #VC exception. Signed-off-by: Thomas Leroy <thomas.leroy@suse.com>
- 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 | ||
}); |