Commit 9d7a6c9
perf: Fix required permissions if sigtrap is requested
If perf_event_open() is called with another task as target and
perf_event_attr::sigtrap is set, and the target task's user does not
match the calling user, also require the CAP_KILL capability or
PTRACE_MODE_ATTACH permissions.
Otherwise, with the CAP_PERFMON capability alone it would be possible
for a user to send SIGTRAP signals via perf events to another user's
tasks. This could potentially result in those tasks being terminated if
they cannot handle SIGTRAP signals.
Note: The check complements the existing capability check, but is not
supposed to supersede the ptrace_may_access() check. At a high level we
now have:
capable of CAP_PERFMON and (CAP_KILL if sigtrap)
OR
ptrace_may_access(...) // also checks for same thread-group and uid
Fixes: 97ba62b ("perf: Add support for SIGTRAP on perf events")
Reported-by: Dmitry Vyukov <[email protected]>
Signed-off-by: Marco Elver <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Acked-by: Dmitry Vyukov <[email protected]>
Cc: <[email protected]> # 5.13+
Link: https://lore.kernel.org/r/[email protected]1 parent 7fef2ed commit 9d7a6c9
1 file changed
+24
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12158 | 12158 | | |
12159 | 12159 | | |
12160 | 12160 | | |
| 12161 | + | |
| 12162 | + | |
| 12163 | + | |
12161 | 12164 | | |
12162 | 12165 | | |
12163 | 12166 | | |
12164 | 12167 | | |
| 12168 | + | |
| 12169 | + | |
| 12170 | + | |
| 12171 | + | |
| 12172 | + | |
| 12173 | + | |
| 12174 | + | |
| 12175 | + | |
| 12176 | + | |
| 12177 | + | |
| 12178 | + | |
| 12179 | + | |
| 12180 | + | |
| 12181 | + | |
| 12182 | + | |
| 12183 | + | |
| 12184 | + | |
| 12185 | + | |
| 12186 | + | |
| 12187 | + | |
12165 | 12188 | | |
12166 | 12189 | | |
12167 | 12190 | | |
| |||
12171 | 12194 | | |
12172 | 12195 | | |
12173 | 12196 | | |
12174 | | - | |
| 12197 | + | |
12175 | 12198 | | |
12176 | 12199 | | |
12177 | 12200 | | |
| |||
0 commit comments