From 6f6cba7c1684c794778d5af259c2410c1a3a18b0 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Thu, 4 Jul 2019 16:41:36 -0400 Subject: [PATCH] kernel/system_profiler: Do not allow non-root users access. The single-team profiler can still be used without root access. Part of #14961. --- src/system/kernel/debug/system_profiler.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/system/kernel/debug/system_profiler.cpp b/src/system/kernel/debug/system_profiler.cpp index 4902ec7d95..bab5d10b02 100644 --- a/src/system/kernel/debug/system_profiler.cpp +++ b/src/system/kernel/debug/system_profiler.cpp @@ -1543,6 +1543,9 @@ stop_system_profiler() status_t _user_system_profiler_start(struct system_profiler_parameters* userParameters) { + if (geteuid() != 0) + return B_PERMISSION_DENIED; + // copy params to the kernel struct system_profiler_parameters parameters; if (userParameters == NULL || !IS_USER_ADDRESS(userParameters) @@ -1606,6 +1609,9 @@ _user_system_profiler_start(struct system_profiler_parameters* userParameters) status_t _user_system_profiler_next_buffer(size_t bytesRead, uint64* _droppedEvents) { + if (geteuid() != 0) + return B_PERMISSION_DENIED; + if (_droppedEvents != NULL && !IS_USER_ADDRESS(_droppedEvents)) return B_BAD_ADDRESS; @@ -1633,6 +1639,9 @@ _user_system_profiler_next_buffer(size_t bytesRead, uint64* _droppedEvents) status_t _user_system_profiler_stop() { + if (geteuid() != 0) + return B_PERMISSION_DENIED; + team_id team = thread_get_current_thread()->team->id; InterruptsSpinLocker locker(sProfilerLock); @@ -1652,6 +1661,9 @@ _user_system_profiler_stop() status_t _user_system_profiler_recorded(system_profiler_parameters* userParameters) { + if (geteuid() != 0) + return B_PERMISSION_DENIED; + if (userParameters == NULL || !IS_USER_ADDRESS(userParameters)) return B_BAD_ADDRESS; if (sRecordedParameters == NULL)