1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 19:38:12 +00:00

Kernel: Crash on memory access in non-readable regions

This patch makes it possible to make memory regions non-readable.
This is enforced using the "present" bit in the page tables.
A process that hits an not-present page fault in a non-readable
region will be crashed.
This commit is contained in:
Andreas Kling 2019-12-02 19:14:16 +01:00
parent ddd5411472
commit f41ae755ec
5 changed files with 41 additions and 2 deletions

View file

@ -306,6 +306,7 @@ int Process::sys$mprotect(void* addr, size_t size, int prot)
return -EINVAL;
if (!region->is_mmap())
return -EPERM;
region->set_readable(prot & PROT_READ);
region->set_writable(prot & PROT_WRITE);
region->remap();
return 0;