Skip to content

Detect perf capabilities for kernel tracing#380

Open
Abhishek21g wants to merge 3 commits into
janestreet:masterfrom
Abhishek21g:abhishek/perf-kernel-capabilities
Open

Detect perf capabilities for kernel tracing#380
Abhishek21g wants to merge 3 commits into
janestreet:masterfrom
Abhishek21g:abhishek/perf-kernel-capabilities

Conversation

@Abhishek21g

@Abhishek21g Abhishek21g commented Jul 4, 2026

Copy link
Copy Markdown

Summary

  • detect effective cap_perfmon / cap_sys_admin file capabilities on the configured perf executable
  • keep root as the fast path for kernel tracing permissions
  • fall back to the previous root-only behavior when getcap is unavailable or cannot inspect perf
  • update the kernel tracing permission error to mention file capabilities
  • update the README wording around kernel tracing permissions
  • add expect tests for getcap output parsing

Fixes #94.

Notes

This keeps the existing capability detection structure and only broadens the kernel-tracing permission check. If getcap is unavailable or cannot inspect the configured perf, magic-trace keeps the previous root-only behavior.

Validation

Optional non-root capability smoke test on a disposable Linux machine:

sudo setcap cap_perfmon,cap_sys_ptrace,cap_syslog=ep "$(command -v perf)"
getcap "$(command -v perf)"

MAGIC_TRACE_PERF_PATH="$(command -v perf)" \
  ./_build/default/bin/magic_trace_bin.exe run -trace-include-kernel true

Signed-off-by: Abhishek Enaguthi <enaguthiabhishek@gmail.com>
@Abhishek21g Abhishek21g marked this pull request as ready for review July 4, 2026 01:35
@Abhishek21g

Copy link
Copy Markdown
Author

I noticed the older related PR #254 after opening this. Since that PR appears stale and #94 is still open, I put together a smaller version that keeps the existing capability detection structure, falls back to the current root-only behavior when getcap is unavailable, and adds focused expect tests for the parser. Happy to adjust direction if maintainers prefer reviving #254.

Signed-off-by: Abhishek Enaguthi <enaguthiabhishek@gmail.com>
Signed-off-by: Abhishek Enaguthi <enaguthiabhishek@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better capability checking for if we can trace the kernel

1 participant