mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:57:44 +00:00
Kernel: Don't include kmalloc perf events in JSON for non-superuser
These events contain sensitive kernel information and should not be available to regular users.
This commit is contained in:
parent
8ef9b003ad
commit
369c7a7e9f
1 changed files with 8 additions and 1 deletions
|
@ -196,10 +196,17 @@ ErrorOr<void> PerformanceEventBuffer::to_json_impl(Serializer& object) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool show_kernel_addresses = Process::current().is_superuser();
|
||||||
auto array = object.add_array("events");
|
auto array = object.add_array("events");
|
||||||
bool seen_first_sample = false;
|
bool seen_first_sample = false;
|
||||||
for (size_t i = 0; i < m_count; ++i) {
|
for (size_t i = 0; i < m_count; ++i) {
|
||||||
auto& event = at(i);
|
auto const& event = at(i);
|
||||||
|
|
||||||
|
if (!show_kernel_addresses) {
|
||||||
|
if (event.type == PERF_EVENT_KMALLOC || event.type == PERF_EVENT_KFREE)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto event_object = array.add_object();
|
auto event_object = array.add_object();
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case PERF_EVENT_SAMPLE:
|
case PERF_EVENT_SAMPLE:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue