mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-04 07:09:47 +00: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
Notes:
sideshowbarker
2024-07-17 22:11:04 +09:00
Author: https://github.com/awesomekling
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
Add a link
Reference in a new issue