mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 05:03:05 +00:00
f50029e071
This interprets the p_paddr field of ELF program headers as an offset into physical RAM on aarch64 systems, which is a change in behavior. We pass an offset of 0 on x86-64, so it makes no difference there. BUG=b:254601048 BUG=b:255697205 TEST=cargo test -p kernel_loader Change-Id: I9ebaa285c4cde1f70cb7752e91ff4520e06dc82f Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4035738 Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
29 lines
858 B
Rust
29 lines
858 B
Rust
// Copyright 2019 The ChromiumOS Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#![no_main]
|
|
|
|
use std::fs::File;
|
|
use std::io::Write;
|
|
|
|
use cros_fuzz::fuzz_target;
|
|
use vm_memory::GuestAddress;
|
|
use vm_memory::GuestMemory;
|
|
|
|
const MEM_SIZE: u64 = 256 * 1024 * 1024;
|
|
|
|
fn make_elf_bin(elf_bytes: &[u8]) -> File {
|
|
let mut elf_bin = tempfile::tempfile().expect("failed to create tempfile");
|
|
elf_bin
|
|
.write_all(elf_bytes)
|
|
.expect("failed to write elf to tempfile");
|
|
elf_bin
|
|
}
|
|
|
|
fuzz_target!(|bytes| {
|
|
let mut kimage = make_elf_bin(bytes);
|
|
let mem = GuestMemory::new(&[(GuestAddress(0), MEM_SIZE)]).unwrap();
|
|
let _ = kernel_loader::load_elf32(&mem, GuestAddress(0), &mut kimage, 0);
|
|
let _ = kernel_loader::load_elf64(&mem, GuestAddress(0), &mut kimage, 0);
|
|
});
|