mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-23 09:51:57 -05:00
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.
This commit is contained in:
parent
a0cbb9068b
commit
84b2d4c475
3 changed files with 6 additions and 0 deletions
|
@ -54,6 +54,7 @@ If the process later attempts to use any system functionality it has previously
|
|||
* `recvfd`: Receive file descriptors over a local socket
|
||||
* `ptrace`: The [`ptrace(2)`](ptrace.md) syscall (\*)
|
||||
* `prot_exec`: [`mmap(2)`](mmap.md) and [`mprotect(2)`](mprotect.md) with `PROT_EXEC`
|
||||
* `map_fixed`: [`mmap(2)`](mmap.md) with `MAP_FIXED` (\*)
|
||||
|
||||
Promises marked with an asterisk (\*) are SerenityOS specific extensions not supported by the original OpenBSD `pledge()`.
|
||||
|
||||
|
|
|
@ -82,6 +82,7 @@ void kgettimeofday(timeval&);
|
|||
__ENUMERATE_PLEDGE_PROMISE(sigaction) \
|
||||
__ENUMERATE_PLEDGE_PROMISE(setkeymap) \
|
||||
__ENUMERATE_PLEDGE_PROMISE(prot_exec) \
|
||||
__ENUMERATE_PLEDGE_PROMISE(map_fixed) \
|
||||
__ENUMERATE_PLEDGE_PROMISE(getkeymap)
|
||||
|
||||
enum class Pledge : u32 {
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue