瀏覽代碼

Kernel: Return one kernel frame from procfs$tid_stack for normal users.

Previously we would return a 0xdeadc0de frame for every kernel frame
in the real kernel stack when an non super-user issued the request.
This isn't useful, and just produces visual clutter in tools which
attempt to symbolize stacks.
Brian Gianforcaro 4 年之前
父節點
當前提交
35bb8ab4db
共有 1 個文件被更改,包括 6 次插入1 次删除
  1. 6 1
      Kernel/FileSystem/ProcFS.cpp

+ 6 - 1
Kernel/FileSystem/ProcFS.cpp

@@ -599,9 +599,14 @@ static bool procfs$tid_stack(InodeIdentifier identifier, KBufferBuilder& builder
 
 
     JsonArraySerializer array { builder };
     JsonArraySerializer array { builder };
     bool show_kernel_addresses = Process::current()->is_superuser();
     bool show_kernel_addresses = Process::current()->is_superuser();
+    bool kernel_address_added = false;
     for (auto address : Processor::capture_stack_trace(*thread, 1024)) {
     for (auto address : Processor::capture_stack_trace(*thread, 1024)) {
-        if (!show_kernel_addresses && !is_user_address(VirtualAddress { address }))
+        if (!show_kernel_addresses && !is_user_address(VirtualAddress { address })) {
+            if (kernel_address_added)
+                continue;
             address = 0xdeadc0de;
             address = 0xdeadc0de;
+            kernel_address_added = true;
+        }
         array.add(JsonValue(address));
         array.add(JsonValue(address));
     }
     }