crosvm/fuzz/fuzzers/fuzz_zimage.rs
Dylan Reid 2b2a7d4d76 Add kernel_loader fuzzing
Add a top level fuzz directory. Other fuzz tests will be added here in
subsequent commits.

For now fuzzing must be run manually. Soon there will be a way to
extract the fuzz artifacts and upload them to cluster fuzz.

Change-Id: Iddfb55af78af6f412927b2221f22acb882069d36
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/850851
Reviewed-by: Zach Reizner <zachr@chromium.org>
2018-01-12 22:37:48 -08:00

15 lines
448 B
Rust

#![no_main]
#[macro_use] extern crate libfuzzer_sys;
extern crate kernel_loader;
extern crate libc;
extern crate sys_util;
use sys_util::{GuestAddress, GuestMemory};
use std::io::Cursor;
fuzz_target!(|data: &[u8]| { // fuzzed code goes here
let mut kimage = Cursor::new(data);
let mem = GuestMemory::new(&[(GuestAddress(0), data.len() + 0x1000)]).unwrap();
let _ = kernel_loader::load_kernel(&mem, GuestAddress(0), &mut kimage);
});