mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:58:13 +00:00
Kernel: Write-only regions should still be mapped as present
There is no real "read protection" on x86, so we have no choice but to map write-only pages simply as "present & read/write". If we get a read page fault in a non-readable region, that's still a correctness issue, so we crash the process. It's by no means a complete protection against invalid reads, since it's trivial to fool the kernel by first causing a write fault in the same region.
This commit is contained in:
parent
4b7a89911c
commit
4ebff10bde
1 changed files with 2 additions and 2 deletions
|
@ -259,7 +259,7 @@ void Region::map_individual_page_impl(size_t page_index)
|
|||
} else {
|
||||
pte.set_cache_disabled(!m_cacheable);
|
||||
pte.set_physical_page_base(physical_page->paddr().get());
|
||||
pte.set_present(is_readable());
|
||||
pte.set_present(true);
|
||||
if (should_cow(page_index))
|
||||
pte.set_writable(false);
|
||||
else
|
||||
|
@ -331,7 +331,7 @@ PageFaultResponse Region::handle_fault(const PageFault& fault)
|
|||
{
|
||||
auto page_index_in_region = page_index_from_address(fault.vaddr());
|
||||
if (fault.type() == PageFault::Type::PageNotPresent) {
|
||||
if (!is_readable()) {
|
||||
if (fault.is_read() && !is_readable()) {
|
||||
dbgprintf("NP(non-readable) fault in Region{%p}[%u]\n", this, page_index_in_region);
|
||||
return PageFaultResponse::ShouldCrash;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue