mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +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 page_vaddr = vaddr().offset(page_index * PAGE_SIZE);
|
||||||
auto& pte = MM.ensure_pte(*m_page_directory, page_vaddr);
|
auto& pte = MM.ensure_pte(*m_page_directory, page_vaddr);
|
||||||
auto& physical_page = vmobject().physical_pages()[first_page_index() + page_index];
|
auto& physical_page = vmobject().physical_pages()[first_page_index() + page_index];
|
||||||
if (!physical_page) {
|
if (!physical_page || !is_readable()) {
|
||||||
pte.clear();
|
pte.clear();
|
||||||
} else {
|
} else {
|
||||||
pte.set_cache_disabled(!m_cacheable);
|
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 << "]";
|
dbg() << "NP(non-readable) fault in Region{" << this << "}[" << page_index_in_region << "]";
|
||||||
return PageFaultResponse::ShouldCrash;
|
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()) {
|
if (vmobject().is_inode()) {
|
||||||
#ifdef PAGE_FAULT_DEBUG
|
#ifdef PAGE_FAULT_DEBUG
|
||||||
dbg() << "NP(inode) fault in Region{" << this << "}[" << page_index_in_region << "]";
|
dbg() << "NP(inode) fault in Region{" << this << "}[" << page_index_in_region << "]";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue