Skip to content

Commit 75fe51a

Browse files
committed
Kernel: Stop trying to write unmapped Process regions into CoreDumps
If we crashed in the middle of mapping in Regions, some of the regions may not have a page directory yet, and will result in a crash when Region::remap() is called.
1 parent 57bce8a commit 75fe51a

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Kernel/Coredump.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ ErrorOr<void> Coredump::write_regions()
186186
if (region->access() == Memory::Region::Access::None)
187187
continue;
188188

189+
// If we crashed in the middle of mapping in Regions, they do not have a page directory yet, and will crash on a remap() call
190+
if (!region->is_mapped())
191+
continue;
192+
189193
region->set_readable(true);
190194
region->remap();
191195

Kernel/Memory/Region.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ class Region final
188188

189189
void remap();
190190

191+
[[nodiscard]] bool is_mapped() const { return m_page_directory != nullptr; }
192+
191193
void clear_to_zero();
192194

193195
[[nodiscard]] bool is_syscall_region() const { return m_syscall_region; }

0 commit comments

Comments
 (0)