Prechádzať zdrojové kódy

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 rokov pred
rodič
commit
35bb8ab4db
1 zmenil súbory, kde vykonal 6 pridanie a 1 odobranie
  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 };
     bool show_kernel_addresses = Process::current()->is_superuser();
+    bool kernel_address_added = false;
     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;
+            kernel_address_added = true;
+        }
         array.add(JsonValue(address));
     }