From b960f108b3f88019e196293e2d507a9bf9d0e132 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 21 Oct 2022 09:56:39 +0200 Subject: executor: better errors for failed mmaps A fixed-address mmap can fail completely or return a different address. Log what it was. Based on: https://groups.google.com/g/syzkaller/c/lto00RwlDIQ --- executor/executor.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'executor/executor.cc') diff --git a/executor/executor.cc b/executor/executor.cc index efd072a75..61e669f39 100644 --- a/executor/executor.cc +++ b/executor/executor.cc @@ -460,8 +460,9 @@ int main(int argc, char** argv) current_thread = &threads[0]; #if SYZ_EXECUTOR_USES_SHMEM - if (mmap(&input_data[0], kMaxInput, PROT_READ, MAP_PRIVATE | MAP_FIXED, kInFd, 0) != &input_data[0]) - fail("mmap of input file failed"); + void* got = mmap(&input_data[0], kMaxInput, PROT_READ, MAP_PRIVATE | MAP_FIXED, kInFd, 0); + if (&input_data[0] != got) + failmsg("mmap of input file failed", "want %p, got %p", &input_data[0], got); mmap_output(kInitialOutput); // Prevent test programs to mess with these fds. @@ -580,7 +581,7 @@ static void mmap_output(int size) void* result = mmap(mmap_at, size - output_size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, kOutFd, output_size); if (result != mmap_at) - fail("mmap of output file failed"); + failmsg("mmap of output file failed", "want %p, got %p", mmap_at, result); output_size = size; } #endif -- cgit mrf-deployment