The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     45fd22da97c6125d8d0d35bd1791e7c0c4175279
Gitweb:        
https://git.kernel.org/tip/45fd22da97c6125d8d0d35bd1791e7c0c4175279
Author:        Alexey Budankov <[email protected]>
AuthorDate:    Wed, 05 Aug 2020 10:56:56 +03:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Thu, 06 Aug 2020 15:03:20 +02:00

perf/core: Take over CAP_SYS_PTRACE creds to CAP_PERFMON capability

Open access to per-process monitoring for CAP_PERFMON only
privileged processes [1]. Extend ptrace_may_access() check
in perf_events subsystem with perfmon_capable() to simplify
user experience and make monitoring more secure by reducing
attack surface.

[1] 
https://lore.kernel.org/lkml/[email protected]/

Signed-off-by: Alexey Budankov <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
Link: 
https://lore.kernel.org/r/[email protected]
---
 kernel/events/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 78e69e1..41e0cef 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -11689,7 +11689,7 @@ SYSCALL_DEFINE5(perf_event_open,
                        goto err_task;
 
                /*
-                * Reuse ptrace permission checks for now.
+                * Preserve ptrace permission check for backwards compatibility.
                 *
                 * We must hold exec_update_mutex across this and any potential
                 * perf_install_in_context() call for this new event to
@@ -11697,7 +11697,7 @@ SYSCALL_DEFINE5(perf_event_open,
                 * perf_event_exit_task() that could imply).
                 */
                err = -EACCES;
-               if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS))
+               if (!perfmon_capable() && !ptrace_may_access(task, 
PTRACE_MODE_READ_REALCREDS))
                        goto err_cred;
        }
 

Reply via email to