1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:48:14 +00:00

Kernel: Exclude PROT_NONE regions from coredumps

As PROT_NONE regions can't be accessed by processes, and their only real
use is for reserving ranges of virtual memory, there's no point in
including them in coredumps.
This commit is contained in:
Daniel Bertalan 2021-12-19 01:07:16 +01:00 committed by Brian Gianforcaro
parent ce1bf3724e
commit 2f1b4b8a81

View file

@ -51,6 +51,9 @@ Coredump::Coredump(NonnullRefPtr<Process> process, NonnullRefPtr<OpenFileDescrip
if (looks_like_userspace_heap_region(*region))
continue;
#endif
if (region->access() == Memory::Region::Access::None)
continue;
++m_num_program_headers;
}
++m_num_program_headers; // +1 for NOTE segment
@ -128,6 +131,9 @@ ErrorOr<void> Coredump::write_program_headers(size_t notes_size)
continue;
#endif
if (region->access() == Memory::Region::Access::None)
continue;
ElfW(Phdr) phdr {};
phdr.p_type = PT_LOAD;
@ -177,6 +183,9 @@ ErrorOr<void> Coredump::write_regions()
continue;
#endif
if (region->access() == Memory::Region::Access::None)
continue;
region->set_readable(true);
region->remap();
@ -254,6 +263,9 @@ ErrorOr<void> Coredump::create_notes_regions_data(auto& builder) const
continue;
#endif
if (region->access() == Memory::Region::Access::None)
continue;
ELF::Core::MemoryRegionInfo info {};
info.header.type = ELF::Core::NotesEntryHeader::Type::MemoryRegionInfo;