mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
Kernel: Unmap non-readable pages
This was caught by running all crash tests with "crash -A". Basically, non-readable pages need to not be mapped *at all* so that a "page not present" exception is provoked on access. Unfortunately x86 does not support write-only mappings, so this is the best we can do. Fixes #1336.
This commit is contained in:
parent
af29dff224
commit
94f287b1c0
1 changed files with 5 additions and 2 deletions
|
@ -213,7 +213,7 @@ void Region::map_individual_page_impl(size_t page_index)
|
|||
auto page_vaddr = vaddr().offset(page_index * PAGE_SIZE);
|
||||
auto& pte = MM.ensure_pte(*m_page_directory, page_vaddr);
|
||||
auto& physical_page = vmobject().physical_pages()[first_page_index() + page_index];
|
||||
if (!physical_page) {
|
||||
if (!physical_page || !is_readable()) {
|
||||
pte.clear();
|
||||
} else {
|
||||
pte.set_cache_disabled(!m_cacheable);
|
||||
|
@ -291,7 +291,10 @@ PageFaultResponse Region::handle_fault(const PageFault& fault)
|
|||
dbg() << "NP(non-readable) fault in Region{" << this << "}[" << page_index_in_region << "]";
|
||||
return PageFaultResponse::ShouldCrash;
|
||||
}
|
||||
|
||||
if (fault.is_write() && !is_writable()) {
|
||||
dbg() << "NP(non-writable) write fault in Region{" << this << "}[" << page_index_in_region << "] at " << fault.vaddr();
|
||||
return PageFaultResponse::ShouldCrash;
|
||||
}
|
||||
if (vmobject().is_inode()) {
|
||||
#ifdef PAGE_FAULT_DEBUG
|
||||
dbg() << "NP(inode) fault in Region{" << this << "}[" << page_index_in_region << "]";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue