diff options
author | Andreas Kling <kling@serenityos.org> | 2021-02-21 01:08:48 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-02-21 01:08:48 +0100 |
commit | 84b2d4c4758e52b9509c6fe7ea317b23d1ec86d2 (patch) | |
tree | de6c7fbb23d100663d2445317b942d78ea087550 /Kernel/Syscalls/mmap.cpp | |
parent | a0cbb9068b96a825db7e91697ab3d1c3ff94e2fd (diff) | |
download | serenity-84b2d4c4758e52b9509c6fe7ea317b23d1ec86d2.zip |
Kernel: Add "map_fixed" pledge promise
This is a new promise that guards access to mmap() with MAP_FIXED.
Fixed-address mappings are rarely used, but can be useful if you are
trying to groom the process address space for malicious purposes.
None of our programs need this at the moment, as the only user of
MAP_FIXED is DynamicLoader, but the fixed mappings are constructed
before the process has had a chance to pledge anything.
Diffstat (limited to 'Kernel/Syscalls/mmap.cpp')
-rw-r--r-- | Kernel/Syscalls/mmap.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Kernel/Syscalls/mmap.cpp b/Kernel/Syscalls/mmap.cpp index a18dc1d4d5..fa39188769 100644 --- a/Kernel/Syscalls/mmap.cpp +++ b/Kernel/Syscalls/mmap.cpp @@ -157,6 +157,10 @@ void* Process::sys$mmap(Userspace<const Syscall::SC_mmap_params*> user_params) REQUIRE_PROMISE(prot_exec); } + if (prot & MAP_FIXED) { + REQUIRE_PROMISE(map_fixed); + } + if (alignment & ~PAGE_MASK) return (void*)-EINVAL; |