From 2f1b4b8a815d1b8d2b9bec34ce0bb916c80f41b3 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Sun, 19 Dec 2021 01:07:16 +0100 Subject: 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. --- Kernel/Coredump.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'Kernel') diff --git a/Kernel/Coredump.cpp b/Kernel/Coredump.cpp index d2014a72f1..da5cf7e295 100644 --- a/Kernel/Coredump.cpp +++ b/Kernel/Coredump.cpp @@ -51,6 +51,9 @@ Coredump::Coredump(NonnullRefPtr process, NonnullRefPtraccess() == Memory::Region::Access::None) + continue; ++m_num_program_headers; } ++m_num_program_headers; // +1 for NOTE segment @@ -128,6 +131,9 @@ ErrorOr 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 Coredump::write_regions() continue; #endif + if (region->access() == Memory::Region::Access::None) + continue; + region->set_readable(true); region->remap(); @@ -254,6 +263,9 @@ ErrorOr 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; -- cgit v1.2.3