From 39e250d27f8ab094fbf992d5569eec06d5eb7a10 Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Tue, 4 Feb 2025 12:13:23 +0100 Subject: executor: favor MAP_FIXED_NOREPLACE over MAP_FIXED MAP_FIXED_NOREPLACE allows to fail early if we happened to overlap with an existing memory mapping. It should help detects bugs #5674 at an earlier stage, before it led to memory corruptions. MAP_FIXED_NOREPLACE is supported from Linux 4.17, which is okay for all syzkaller use cases on syzbot. There's no such option for some of the supported OSes, so set it depending on the configuration we're building for. --- executor/executor_test.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'executor/executor_test.h') diff --git a/executor/executor_test.h b/executor/executor_test.h index c94de09a2..e2a2002bb 100644 --- a/executor/executor_test.h +++ b/executor/executor_test.h @@ -22,7 +22,7 @@ static void os_init(int argc, char** argv, void* data, size_t data_size) if (getppid() == 1) exitf("the parent process was killed"); #endif - void* got = mmap(data, data_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0); + void* got = mmap(data, data_size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED_EXCLUSIVE, -1, 0); if (data != got) failmsg("mmap of data segment failed", "want %p, got %p", data, got); is_kernel_64_bit = sizeof(unsigned long) == 8; -- cgit mrf-deployment