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.
This commit is contained in:
Andrew Kaster 2020-01-08 21:28:11 -07:00 committed by Andreas Kling
parent 56974f76be
commit e594724b01
Notes: sideshowbarker 2024-07-19 10:15:08 +09:00

View file

@ -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;