Skip to content

Commit 45fd22d

Browse files
Alexey BudankovIngo Molnar
authored andcommitted
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]
1 parent 2324d50 commit 45fd22d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/events/core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11689,15 +11689,15 @@ SYSCALL_DEFINE5(perf_event_open,
1168911689
goto err_task;
1169011690

1169111691
/*
11692-
* Reuse ptrace permission checks for now.
11692+
* Preserve ptrace permission check for backwards compatibility.
1169311693
*
1169411694
* We must hold exec_update_mutex across this and any potential
1169511695
* perf_install_in_context() call for this new event to
1169611696
* serialize against exec() altering our credentials (and the
1169711697
* perf_event_exit_task() that could imply).
1169811698
*/
1169911699
err = -EACCES;
11700-
if (!ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS))
11700+
if (!perfmon_capable() && !ptrace_may_access(task, PTRACE_MODE_READ_REALCREDS))
1170111701
goto err_cred;
1170211702
}
1170311703

0 commit comments

Comments
 (0)