mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 05:58:11 +00:00
Map pages in read-only ELF sections as non-writable.
This is so cool! :^) Now you'll crash if you try to write into your .text or .rodata segments.
This commit is contained in:
parent
aa6d06b47e
commit
da13c9a264
4 changed files with 26 additions and 6 deletions
|
@ -304,8 +304,8 @@ void MemoryManager::map_region_at_address(PageDirectory* page_directory, Region&
|
|||
auto page_laddr = laddr.offset(i * PAGE_SIZE);
|
||||
auto pte = ensurePTE(page_directory, page_laddr);
|
||||
pte.setPhysicalPageBase(zone.m_pages[i].get());
|
||||
pte.setPresent(true);
|
||||
pte.setWritable(true);
|
||||
pte.setPresent(true); // FIXME: Maybe we could use the is_readable flag here?
|
||||
pte.setWritable(region.is_writable);
|
||||
pte.setUserAllowed(user_allowed);
|
||||
flushTLB(page_laddr);
|
||||
#ifdef MM_DEBUG
|
||||
|
@ -430,7 +430,7 @@ RetainPtr<Region> Region::clone()
|
|||
|
||||
// FIXME: Implement COW regions.
|
||||
auto clone_zone = MM.createZone(zone->size());
|
||||
auto clone_region = adopt(*new Region(linearAddress, size, move(clone_zone), String(name)));
|
||||
auto clone_region = adopt(*new Region(linearAddress, size, move(clone_zone), String(name), is_readable, is_writable));
|
||||
|
||||
// FIXME: It would be cool to make the src_alias a read-only mapping.
|
||||
byte* src_alias = MM.create_kernel_alias_for_region(*this);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue