1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07: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:
Andreas Kling 2018-11-03 11:36:45 +01:00
parent aa6d06b47e
commit da13c9a264
4 changed files with 26 additions and 6 deletions

View file

@ -147,7 +147,7 @@ Region* Process::allocate_region(LinearAddress laddr, size_t size, String&& name
auto zone = MM.createZone(size);
ASSERT(zone);
m_regions.append(adopt(*new Region(laddr, size, move(zone), move(name))));
m_regions.append(adopt(*new Region(laddr, size, move(zone), move(name), is_readable, is_writable)));
MM.mapRegion(*this, *m_regions.last());
return m_regions.last().ptr();
@ -1260,11 +1260,13 @@ Process* Process::kernelProcess()
return s_kernelProcess;
}
Region::Region(LinearAddress a, size_t s, RetainPtr<Zone>&& z, String&& n)
Region::Region(LinearAddress a, size_t s, RetainPtr<Zone>&& z, String&& n, bool r, bool w)
: linearAddress(a)
, size(s)
, zone(move(z))
, name(move(n))
, is_readable(r)
, is_writable(w)
{
}