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_darwin.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'executor/executor_darwin.h') 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; -- cgit mrf-deployment