Skip to content

Commit

Permalink
perf/core: Take over CAP_SYS_PTRACE creds to CAP_PERFMON capability
Browse files Browse the repository at this point in the history
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/7776fa40-6c65-2aa6-1322-eb3a01201000@linux.intel.com/

Signed-off-by: Alexey Budankov <alexey.budankov@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/6e8392ff-4732-0012-2949-e1587709f0f6@linux.intel.com
  • Loading branch information
Alexey Budankov authored and Ingo Molnar committed Aug 6, 2020
1 parent 2324d50 commit 45fd22d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/events/core.c
Original file line number Diff line number Diff line change
@@ -11689,15 +11689,15 @@ 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
* serialize against exec() altering our credentials (and the
* 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;
}

0 comments on commit 45fd22d

Please sign in to comment.