summaryrefslogtreecommitdiff
path: root/Kernel/VM/Region.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-11-17 12:11:43 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-17 12:15:43 +0100
commit794758df3ace052c1d2f0d90dc99e6154e90be9d (patch)
tree99fdc414d7a50bed086fed34260e41bd74b75810 /Kernel/VM/Region.h
parent197ed1bb2a56677c6311d440d6246c9cd4b0a767 (diff)
downloadserenity-794758df3ace052c1d2f0d90dc99e6154e90be9d.zip
Kernel: Implement some basic stack pointer validation
VM regions can now be marked as stack regions, which is then validated on syscall, and on page fault. If a thread is caught with its stack pointer pointing into anything that's *not* a Region with its stack bit set, we'll crash the whole process with SIGSTKFLT. Userspace must now allocate custom stacks by using mmap() with the new MAP_STACK flag. This mechanism was first introduced in OpenBSD, and now we have it too, yay! :^)
Diffstat (limited to 'Kernel/VM/Region.h')
-rw-r--r--Kernel/VM/Region.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/Kernel/VM/Region.h b/Kernel/VM/Region.h
index 50ea87ff04..5501e6b2e3 100644
--- a/Kernel/VM/Region.h
+++ b/Kernel/VM/Region.h
@@ -50,6 +50,9 @@ public:
bool is_shared() const { return m_shared; }
void set_shared(bool shared) { m_shared = shared; }
+ bool is_stack() const { return m_stack; }
+ void set_stack(bool stack) { m_stack = stack; }
+
bool is_user_accessible() const { return m_user_accessible; }
PageFaultResponse handle_fault(const PageFault&);
@@ -141,5 +144,6 @@ private:
u8 m_access { 0 };
bool m_shared { false };
bool m_user_accessible { false };
+ bool m_stack { false };
mutable OwnPtr<Bitmap> m_cow_map;
};