]> git.itanic.dy.fi Git - linux-stable/commit
perf: Fix required permissions if sigtrap is requested
authorMarco Elver <elver@google.com>
Mon, 5 Jul 2021 08:44:52 +0000 (10:44 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Fri, 16 Jul 2021 16:46:38 +0000 (18:46 +0200)
commit9d7a6c95f62bc335b62aaf9d50590122bd03a796
tree793a71181113cab26c1fe6e23483de2e8372b484
parent7fef2edf7cc753b51f7ccc74993971b0a9c81eca
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: 97ba62b27867 ("perf: Add support for SIGTRAP on perf events")
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Dmitry Vyukov <dvyukov@google.com>
Cc: <stable@vger.kernel.org> # 5.13+
Link: https://lore.kernel.org/r/20210705084453.2151729-1-elver@google.com
kernel/events/core.c