diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2025-02-04 12:13:23 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-02-04 14:54:37 +0000 |
| commit | 39e250d27f8ab094fbf992d5569eec06d5eb7a10 (patch) | |
| tree | 8042010882b865338e364b018fb1b64144a462fd /executor/executor.cc | |
| parent | 44c01590d11f09b1689d02f6c3e26ab9d1b9dbb2 (diff) | |
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.
Diffstat (limited to 'executor/executor.cc')
| -rw-r--r-- | executor/executor.cc | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/executor/executor.cc b/executor/executor.cc index 702f8c3b4..4ea40e0f2 100644 --- a/executor/executor.cc +++ b/executor/executor.cc @@ -484,6 +484,14 @@ static void parse_handshake(const handshake_req& req); #include "syscalls.h" #if GOOS_linux +#define MAP_FIXED_EXCLUSIVE MAP_FIXED_NOREPLACE +#elif GOOS_freebsd +#define MAP_FIXED_EXCLUSIVE (MAP_FIXED | MAP_EXCL) +#else +#define MAP_FIXED_EXCLUSIVE MAP_FIXED // The check is not supported. +#endif + +#if GOOS_linux #include "executor_linux.h" #elif GOOS_fuchsia #include "executor_fuchsia.h" |
