Skip to content

kernel: Don't require /proc/kcore access when only kallsyms is used#1561

Merged
danielocfb merged 1 commit into
libbpf:mainfrom
josefbacik:kaslr-fix
May 21, 2026
Merged

kernel: Don't require /proc/kcore access when only kallsyms is used#1561
danielocfb merged 1 commit into
libbpf:mainfrom
josefbacik:kaslr-fix

Conversation

@josefbacik
Copy link
Copy Markdown
Contributor

KernelResolver::new() unconditionally queries the KASLR offset, which reads /proc/kcore. If that fails with EPERM (common in containers or for unprivileged processes), resolver creation hard-fails — even though kallsyms-only symbolization doesn't need the offset at all, since kallsyms addresses are already relocated.

This change only queries the KASLR offset when a vmlinux resolver is actually in use. The kallsyms-only path now works without /proc/kcore access; vmlinux based resolution still requires it since we can't correctly relocate addresses without the offset.

Also moves the "no symbol source" check above the offset query so we don't needlessly touch /proc/kcore when we're about to error out anyway.

KernelResolver::new() unconditionally queried the KASLR offset, which
reads /proc/kcore. If that fails with EPERM (common in containers or
unprivileged processes), resolver creation hard-fails -- even though
kallsyms-only symbolization doesn't need the offset at all, since
kallsyms addresses are already relocated.

Only query the KASLR offset when a vmlinux resolver is actually in use.
The kallsyms-only path now works without /proc/kcore access; vmlinux
based resolution still requires it since we can't correctly relocate
addresses without the offset.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.74%. Comparing base (d10198e) to head (248b104).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1561      +/-   ##
==========================================
- Coverage   95.75%   95.74%   -0.02%     
==========================================
  Files          56       56              
  Lines        9549     9550       +1     
==========================================
  Hits         9144     9144              
- Misses        405      406       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Collaborator

@danielocfb danielocfb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks!

@danielocfb danielocfb merged commit 987d36c into libbpf:main May 21, 2026
46 checks passed
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.

2 participants