From e594724b019a2ab9eb9866f90c87fc0eedf67efc Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Wed, 8 Jan 2020 21:28:11 -0700 Subject: [PATCH] Kernel: mmap(..., MAP_PRIVATE, fd, offset) is not supported Make mmap return -ENOTSUP in this case to make sure users don't get confused and think they're using a private mapping when it's actually shared. It's currenlty not possible to open a file and mmap it MAP_PRIVATE, and change the perms of the private mapping to ones that don't match the permissions of the underlying file. --- Kernel/Process.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 16b168145f..4b953f5e4a 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -336,6 +336,9 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* user_params) return (void*)-EINVAL; if (static_cast(offset) & ~PAGE_MASK) return (void*)-EINVAL; + // FIXME: Implement MAP_PRIVATE for FileDescription-backed mmap + if (map_private) + return (void*)-ENOTSUP; auto description = file_description(fd); if (!description) return (void*)-EBADF;