perf_event_paranoid controls observability privilege, not process trust
Performance monitoring can expose more than instruction counts. It can sample execution, collect stack traces, observe kernel behavior, and provide timing information that helps an attacker understand a target. Linux exposes a system-wide knob that limits what an unprivileged process may measure: perf_event_paranoid.
The kernel documentation defines a useful scale. At -1, almost all events are open to all users. At 0 or higher, unprivileged users cannot use ftrace function tracepoints or raw tracepoints without CAP_PERFMON. At 1 or higher, CPU event access is restricted. At 2 or higher, kernel profiling is disallowed. The default is 2. A privileged process can still bypass the checks, so the setting is not a substitute for controlling who receives administrative capability.
CAP_PERFMON is the narrow privilege
The kernel's performance-security documentation presents CAP_PERFMON as the least-privilege capability for performance monitoring. CAP_SYS_ADMIN remains a compatibility path, but its broad authority should not be granted merely to make a profiler work. A container host, build worker, or observability agent should receive only the capability and namespace access it needs, and the capability should be scoped to a dedicated process.
Raw tracepoint access and kernel profiling can reveal pointers, paths, process activity, or memory-derived data. A team that gives every shell user access because profiling is useful has moved a diagnostic facility into a general data-access path. The same reasoning applies to shared build machines and CI runners that execute untrusted code.
Measure the operational effect
Inventory profilers, eBPF tools, tracing agents, and monitoring sidecars. Record whether each runs as root, holds CAP_PERFMON, is allowed in a user namespace, or shares the host's perf namespace. Test an unprivileged user, a container with the intended capability, and the host with the intended policy. A test that only runs as root cannot prove the production boundary.
Watch for configuration drift and for the common exception where a debugging session leaves a broad capability attached to a long-lived service. Keep the policy reviewed when a platform upgrade changes the default or when a new observability feature starts requesting kernel events.
Performance data is security data
The setting influences what a logged-in user can learn about other workloads. It is useful to treat perf access as a sensitive read interface and to log changes to the effective policy. A process that can sample the host may infer secrets through timing or observe code paths that should remain isolated. The control is not perfect, but it is a clear boundary that can be made explicit.
References
[1] Linux Kernel documentation, sysctl kernel parameters: perf_event_paranoid. https://docs.kernel.org/admin-guide/sysctl/kernel.html
[2] Linux Kernel documentation, Perf events and tool security. https://docs.kernel.org/admin-guide/perf-security.html
Top comments (0)