diff options
author | Andreas Kling <awesomekling@gmail.com> | 2020-01-10 06:57:18 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2020-01-10 10:57:06 +0100 |
commit | 197e73ee311db09c50e3a48d1e6c0b1e15512664 (patch) | |
tree | d1b383ffad1bf95f681dd7f63a368ff929dcb81c /Kernel/VM | |
parent | 66b0002acbedea9ecbb36917e1c4525524ed3840 (diff) | |
download | serenity-197e73ee311db09c50e3a48d1e6c0b1e15512664.zip |
Kernel+LibELF: Enable SMAP protection during non-syscall exec()
When loading a new executable, we now map the ELF image in kernel-only
memory and parse it there. Then we use copy_to_user() when initializing
writable regions with data from the executable.
Note that the exec() syscall still disables SMAP protection and will
require additional work. This patch only affects kernel-originated
process spawns.
Diffstat (limited to 'Kernel/VM')
-rw-r--r-- | Kernel/VM/Region.cpp | 7 | ||||
-rw-r--r-- | Kernel/VM/Region.h | 1 |
2 files changed, 8 insertions, 0 deletions
diff --git a/Kernel/VM/Region.cpp b/Kernel/VM/Region.cpp index 85e84bd92e..5a0917d44c 100644 --- a/Kernel/VM/Region.cpp +++ b/Kernel/VM/Region.cpp @@ -189,6 +189,13 @@ NonnullOwnPtr<Region> Region::create_kernel_only(const Range& range, const Strin return region; } +NonnullOwnPtr<Region> Region::create_kernel_only(const Range& range, NonnullRefPtr<VMObject> vmobject, size_t offset_in_vmobject, const StringView& name, u8 access) +{ + auto region = make<Region>(range, move(vmobject), offset_in_vmobject, name, access); + region->m_user_accessible = false; + return region; +} + bool Region::should_cow(size_t page_index) const { if (m_shared) diff --git a/Kernel/VM/Region.h b/Kernel/VM/Region.h index ddf7c4d194..3af580af79 100644 --- a/Kernel/VM/Region.h +++ b/Kernel/VM/Region.h @@ -30,6 +30,7 @@ public: static NonnullOwnPtr<Region> create_user_accessible(const Range&, NonnullRefPtr<VMObject>, size_t offset_in_vmobject, const StringView& name, u8 access); static NonnullOwnPtr<Region> create_user_accessible(const Range&, NonnullRefPtr<Inode>, const StringView& name, u8 access); static NonnullOwnPtr<Region> create_kernel_only(const Range&, const StringView& name, u8 access); + static NonnullOwnPtr<Region> create_kernel_only(const Range&, NonnullRefPtr<VMObject>, size_t offset_in_vmobject, const StringView& name, u8 access); ~Region(); |