Ver Fonte

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.
Andrew Kaster há 5 anos atrás
pai
commit
e594724b01
1 ficheiros alterados com 3 adições e 0 exclusões
  1. 3 0
      Kernel/Process.cpp

+ 3 - 0
Kernel/Process.cpp

@@ -336,6 +336,9 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* user_params)
             return (void*)-EINVAL;
         if (static_cast<size_t>(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;