mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 02:12:09 -05:00
Kernel: Set NX bit on expanded kmalloc memory mappings if supported
We never want to execute kmalloc memory.
This commit is contained in:
parent
da5c257e2e
commit
4d585cdb82
1 changed files with 4 additions and 0 deletions
|
@ -127,6 +127,8 @@ struct KmallocGlobalData {
|
||||||
|
|
||||||
expansion_data->next_virtual_address = expansion_data->next_virtual_address.offset(new_subheap_size);
|
expansion_data->next_virtual_address = expansion_data->next_virtual_address.offset(new_subheap_size);
|
||||||
|
|
||||||
|
auto cpu_supports_nx = Processor::current().has_feature(CPUFeature::NX);
|
||||||
|
|
||||||
SpinlockLocker mm_locker(Memory::s_mm_lock);
|
SpinlockLocker mm_locker(Memory::s_mm_lock);
|
||||||
SpinlockLocker pd_locker(MM.kernel_page_directory().get_lock());
|
SpinlockLocker pd_locker(MM.kernel_page_directory().get_lock());
|
||||||
|
|
||||||
|
@ -146,6 +148,8 @@ struct KmallocGlobalData {
|
||||||
pte->set_global(true);
|
pte->set_global(true);
|
||||||
pte->set_user_allowed(false);
|
pte->set_user_allowed(false);
|
||||||
pte->set_writable(true);
|
pte->set_writable(true);
|
||||||
|
if (cpu_supports_nx)
|
||||||
|
pte->set_execute_disabled(true);
|
||||||
pte->set_present(true);
|
pte->set_present(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue