summaryrefslogtreecommitdiff
path: root/Kernel/Syscalls/mmap.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-08-21 16:02:24 +0200
committerAndreas Kling <kling@serenityos.org>2022-08-21 16:02:24 +0200
commitc3351d4b9fc83c731f122de21adf52ef015aecb1 (patch)
tree003ab8dd231db1469f807d5c9cdd2bb33303ac50 /Kernel/Syscalls/mmap.cpp
parent9744dedb5008ee4c20e01166b46bc56fcbdcbd12 (diff)
downloadserenity-c3351d4b9fc83c731f122de21adf52ef015aecb1.zip
Kernel: Make VirtualFileSystem functions take credentials as input
Instead of getting credentials from Process::current(), we now require that they be provided as input to the various VFS functions. This ensures that an atomic set of credentials is used throughout an entire VFS operation.
Diffstat (limited to 'Kernel/Syscalls/mmap.cpp')
-rw-r--r--Kernel/Syscalls/mmap.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/Kernel/Syscalls/mmap.cpp b/Kernel/Syscalls/mmap.cpp
index aab05f47c2..c5afee7b7b 100644
--- a/Kernel/Syscalls/mmap.cpp
+++ b/Kernel/Syscalls/mmap.cpp
@@ -105,15 +105,16 @@ ErrorOr<void> Process::validate_mmap_prot(int prot, bool map_stack, bool map_ano
ErrorOr<void> Process::validate_inode_mmap_prot(int prot, Inode const& inode, bool map_shared) const
{
+ auto credentials = this->credentials();
auto metadata = inode.metadata();
- if ((prot & PROT_READ) && !metadata.may_read(*this))
+ if ((prot & PROT_READ) && !metadata.may_read(credentials))
return EACCES;
if (map_shared) {
// FIXME: What about readonly filesystem mounts? We cannot make a
// decision here without knowing the mount flags, so we would need to
// keep a Custody or something from mmap time.
- if ((prot & PROT_WRITE) && !metadata.may_write(*this))
+ if ((prot & PROT_WRITE) && !metadata.may_write(credentials))
return EACCES;
if (auto shared_vmobject = inode.shared_vmobject()) {
if ((prot & PROT_EXEC) && shared_vmobject->writable_mappings())