summaryrefslogtreecommitdiff
path: root/Kernel/Process.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-12-02 19:14:16 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-12-02 19:18:52 +0100
commitf41ae755ecbe3a17140e53b1cf6f839da41d343b (patch)
tree1838469cc90310088d5b09c095213519b52043c5 /Kernel/Process.cpp
parentddd54114724f5c2adefa2f4c5249c1af13295327 (diff)
downloadserenity-f41ae755ecbe3a17140e53b1cf6f839da41d343b.zip
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.
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r--Kernel/Process.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index fc2946b13e..074e96896a 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -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;