Procházet zdrojové kódy

Kernel: Limit the size of stack traces

Let's not allow infinitely long stack traces. Cap it at 4096 frames.
Andreas Kling před 4 roky
rodič
revize
b0b51c3955
1 změnil soubory, kde provedl 2 přidání a 1 odebrání
  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++;