diff options
author | Andreas Kling <awesomekling@gmail.com> | 2020-01-02 20:49:21 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2020-01-02 20:51:31 +0100 |
commit | 32ec1e5aed6554d3ae2872a0a248bc959578c7e4 (patch) | |
tree | 30712dd97e62f2d7a1855c2420f82c9e207b63f6 /Kernel/FileSystem/ProcFS.cpp | |
parent | 8eb20bdfa2f6e00307a5e7b8243c7eaeac2d245d (diff) | |
download | serenity-32ec1e5aed6554d3ae2872a0a248bc959578c7e4.zip |
Kernel: Mask kernel addresses in backtraces and profiles
Addresses outside the userspace virtual range will now show up as
0xdeadc0de in backtraces and profiles generated by unprivileged users.
Diffstat (limited to 'Kernel/FileSystem/ProcFS.cpp')
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index b75db41862..a65c7031db 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -365,6 +365,7 @@ Optional<KBuffer> procfs$profile(InodeIdentifier) InterruptDisabler disabler; KBufferBuilder builder; JsonArraySerializer array(builder); + bool mask_kernel_addresses = !current->process().is_superuser(); Profiling::for_each_sample([&](auto& sample) { auto object = array.add_object(); object.add("pid", sample.pid); @@ -375,7 +376,10 @@ Optional<KBuffer> procfs$profile(InodeIdentifier) if (sample.frames[i] == 0) break; auto frame_object = frames_array.add_object(); - frame_object.add("address", JsonValue((u32)sample.frames[i])); + u32 address = (u32)sample.frames[i]; + if (mask_kernel_addresses && !is_user_address(VirtualAddress(address))) + address = 0xdeadc0de; + frame_object.add("address", address); frame_object.add("symbol", sample.symbolicated_frames[i]); frame_object.add("offset", JsonValue((u32)sample.offsets[i])); frame_object.finish(); |