diff options
| -rw-r--r-- | executor/executor.cc | 7 | ||||
| -rw-r--r-- | executor/executor_bsd.h | 5 | ||||
| -rw-r--r-- | executor/executor_darwin.h | 5 | ||||
| -rw-r--r-- | executor/executor_linux.h | 15 | ||||
| -rw-r--r-- | executor/executor_test.h | 5 |
5 files changed, 22 insertions, 15 deletions
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 diff --git a/executor/executor_bsd.h b/executor/executor_bsd.h index dc3ebbdd8..1af99f4fc 100644 --- a/executor/executor_bsd.h +++ b/executor/executor_bsd.h @@ -33,8 +33,9 @@ static void os_init(int argc, char** argv, void* data, size_t data_size) flags |= MAP_EXCL; #endif - if (mmap(data, data_size, prot, flags, -1, 0) != data) - fail("mmap of data segment failed"); + void* got = mmap(data, data_size, prot, flags, -1, 0); + if (data != got) + failmsg("mmap of data segment failed", "want %p, got %p", data, got); // Makes sure the file descriptor limit is sufficient to map control pipes. struct rlimit rlim; diff --git a/executor/executor_darwin.h b/executor/executor_darwin.h index 3742af8b9..aeba30a1d 100644 --- a/executor/executor_darwin.h +++ b/executor/executor_darwin.h @@ -22,8 +22,9 @@ static void os_init(int argc, char** argv, void* data, size_t data_size) int prot = PROT_READ | PROT_WRITE | PROT_EXEC; int flags = MAP_ANON | MAP_PRIVATE | MAP_FIXED; - if (mmap(data, data_size, prot, flags, -1, 0) != data) - fail("mmap of data segment failed"); + void* got = mmap(data, data_size, prot, flags, -1, 0); + if (data != got) + failmsg("mmap of data segment failed", "want %p, got %p", data, got); // Makes sure the file descriptor limit is sufficient to map control pipes. struct rlimit rlim; diff --git a/executor/executor_linux.h b/executor/executor_linux.h index 3f422f6f2..54246bda9 100644 --- a/executor/executor_linux.h +++ b/executor/executor_linux.h @@ -58,12 +58,15 @@ static void os_init(int argc, char** argv, char* data, size_t data_size) // One observed case before: executor had a mapping above the data mapping (output region), // while C repros did not have that mapping above, as the result in one case VMA had next link, // while in the other it didn't and it caused a bug to not reproduce with the C repro. - if (mmap(data - SYZ_PAGE_SIZE, SYZ_PAGE_SIZE, PROT_NONE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0) != data - SYZ_PAGE_SIZE) - fail("mmap of left data PROT_NONE page failed"); - if (mmap(data, data_size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0) != data) - fail("mmap of data segment failed"); - if (mmap(data + data_size, SYZ_PAGE_SIZE, PROT_NONE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0) != data + data_size) - fail("mmap of right data PROT_NONE page failed"); + void* got = mmap(data - SYZ_PAGE_SIZE, SYZ_PAGE_SIZE, PROT_NONE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); + if (data - SYZ_PAGE_SIZE != got) + failmsg("mmap of left data PROT_NONE page failed", "want %p, got %p", data - SYZ_PAGE_SIZE, got); + got = mmap(data, data_size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); + if (data != got) + failmsg("mmap of data segment failed", "want %p, got %p", data, got); + got = mmap(data + data_size, SYZ_PAGE_SIZE, PROT_NONE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); + if (data + data_size != got) + failmsg("mmap of right data PROT_NONE page failed", "want %p, got %p", data + data_size, got); } static intptr_t execute_syscall(const call_t* c, intptr_t a[kMaxArgs]) diff --git a/executor/executor_test.h b/executor/executor_test.h index 5984fc8f1..fb9b28add 100644 --- a/executor/executor_test.h +++ b/executor/executor_test.h @@ -9,8 +9,9 @@ static void os_init(int argc, char** argv, void* data, size_t data_size) { - if (mmap(data, data_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0) != data) - fail("mmap of data segment failed"); + void* got = mmap(data, data_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); + if (data != got) + failmsg("mmap of data segment failed", "want %p, got %p", data, got); } static intptr_t execute_syscall(const call_t* c, intptr_t a[kMaxArgs]) |
