summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Bertalan <dani@danielbertalan.dev>2021-12-19 01:07:16 +0100
committerBrian Gianforcaro <b.gianfo@gmail.com>2021-12-22 00:02:36 -0800
commit2f1b4b8a815d1b8d2b9bec34ce0bb916c80f41b3 (patch)
treefdfe1de2f3b10a68ef6c605a571bd2057080fdee
parentce1bf3724e30e1ea5669ed7fe9fcbf5e9d423493 (diff)
downloadserenity-2f1b4b8a815d1b8d2b9bec34ce0bb916c80f41b3.zip
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.
-rw-r--r--Kernel/Coredump.cpp12
1 files changed, 12 insertions, 0 deletions
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> 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;