Kernel: Always require read access when mmaping a file

POSIX says, "The file descriptor fildes shall have been opened with read
permission, regardless of the protection options specified."
This commit is contained in:
Sergey Bugaev 2020-05-28 17:46:24 +03:00 committed by Andreas Kling
parent 6af2418de7
commit f945d7c358

View file

@ -430,7 +430,8 @@ void* Process::sys$mmap(const Syscall::SC_mmap_params* user_params)
return (void*)-EBADF;
if (description->is_directory())
return (void*)-ENODEV;
if ((prot & PROT_READ) && !description->is_readable())
// Require read access even when read protection is not requested.
if (!description->is_readable())
return (void*)-EACCES;
if (map_shared) {
if ((prot & PROT_WRITE) && !description->is_writable())