summaryrefslogtreecommitdiff
path: root/Kernel/Arch
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-02-02 16:05:18 +0100
committerAndreas Kling <kling@serenityos.org>2021-02-02 18:58:26 +0100
commitb0b51c3955dab267670b48055cc419bc29c60c88 (patch)
treefc519585434ea2dc35b048c5288b467a758bbad9 /Kernel/Arch
parent7b50d3cda4ded2d371fb18a0dc6a8067c0cb87d6 (diff)
downloadserenity-b0b51c3955dab267670b48055cc419bc29c60c88.zip
Kernel: Limit the size of stack traces
Let's not allow infinitely long stack traces. Cap it at 4096 frames.
Diffstat (limited to 'Kernel/Arch')
-rw-r--r--Kernel/Arch/i386/CPU.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp
index 7dc7f082c6..e147a644e0 100644
--- a/Kernel/Arch/i386/CPU.cpp
+++ b/Kernel/Arch/i386/CPU.cpp
@@ -1161,9 +1161,10 @@ Vector<FlatPtr> Processor::capture_stack_trace(Thread& thread, size_t max_frames
auto walk_stack = [&](FlatPtr stack_ptr)
{
+ static constexpr size_t max_stack_frames = 4096;
stack_trace.append(eip);
size_t count = 1;
- while (stack_ptr) {
+ while (stack_ptr && stack_trace.size() < max_stack_frames) {
FlatPtr retaddr;
count++;