Browse Source

Kernel: Limit the size of stack traces

Let's not allow infinitely long stack traces. Cap it at 4096 frames.
Andreas Kling 4 years ago
parent
commit
b0b51c3955
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Kernel/Arch/i386/CPU.cpp

+ 2 - 1
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++;