mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-11 06:52:31 -04:00
Refactor perf_cap__capable() to completely remove the used_root out-parameter
as requested by the maintainer. Relying on an explicit used_root boolean
poisoned sequential capability checks (e.g. failing CAP_SYS_ADMIN checks
poisoning the flag for subsequent CAP_PERFMON evaluations for unprivileged
users) and created redundant complexity across check_ftrace_capable(),
symbol__read_kptr_restrict(), and perf_event_paranoid_check().
Streamline the capability API to perform a pure true/false boolean
evaluation. The function checks the Effective set using SYS_capget; if
the syscall is missing or fails on legacy kernels, it cleanly falls back
to checking EUID == 0. This perfectly preserves modern capability-aware host
sessions, guarantees transparent fallback for older kernels, and correctly
rejects privileged operations for containerized root processes that have
explicitly dropped their capability bounding and permitted sets.
Fixes: e25ebda78e ("perf cap: Tidy up and improve capability testing")
Suggested-by: Namhyung Kim <namhyung@kernel.org>
Assisted-by: Antigravity:gemini-3.5-flash
Signed-off-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
24 lines
362 B
C
24 lines
362 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __PERF_CAP_H
|
|
#define __PERF_CAP_H
|
|
|
|
#include <stdbool.h>
|
|
#include <linux/capability.h>
|
|
|
|
/* For older systems */
|
|
#ifndef CAP_SYSLOG
|
|
#define CAP_SYSLOG 34
|
|
#endif
|
|
|
|
#ifndef CAP_PERFMON
|
|
#define CAP_PERFMON 38
|
|
#endif
|
|
|
|
#ifndef CAP_BPF
|
|
#define CAP_BPF 39
|
|
#endif
|
|
|
|
bool perf_cap__capable(int cap);
|
|
|
|
#endif /* __PERF_CAP_H */
|