Skip to content

fix: grant cap_sys_resource to the shim, log $PATH on setcap failure - #131

Merged
ilmanzo merged 1 commit into
mainfrom
fix/shim-cap-sys-resource
Aug 9, 2026
Merged

fix: grant cap_sys_resource to the shim, log $PATH on setcap failure#131
ilmanzo merged 1 commit into
mainfrom
fix/shim-cap-sys-resource

Conversation

@ilmanzo

@ilmanzo ilmanzo commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • cilium/ebpf's rlimit.RemoveMemlock() is a no-op on kernels with memcg-based BPF memory accounting (the norm on kernel >=6.6, required here), but its own accounting-support probe can misfire under BPF memory pressure and fall back to raising RLIMIT_MEMLOCK, which requires CAP_SYS_RESOURCE. Without it that fallback hard-fails the whole tracer instead of the no-op it's meant to be (observed: curl's shim exiting before exec'ing real curl with remove memlock: operation not permitted).
  • Adds cap_sys_resource to the shim's capability set in setShimCaps as cheap, low-risk insurance against that fallback path — scoped to the shim binary via file capabilities, used for exactly one Prlimit call.
  • Also logs $PATH alongside setcap failures, to help root-cause a separate class of "setcap: executable file not found in $PATH" failures seen in some coverage runs.

Test plan

  • go build ./... and go vet ./... pass
  • ./run_unit_tests.sh passes
  • Verified live against a real openQA coverage run with the new capability applied and the PATH diagnostic firing as expected
  • Note: in the run where this was tested, the actual root cause of the curl_https failure turned out to be a missing libcap-progs test-infra dependency (fixed separately, out of scope for this repo) rather than the capability gap this PR closes — but the extra capability and diagnostic logging are still worth keeping as defense-in-depth once setcap itself is working.

cilium/ebpf's rlimit.RemoveMemlock() is a no-op on kernels with memcg-based
BPF memory accounting (the norm on kernel >=6.6, required here), but its own
accounting-support probe can misfire under BPF memory pressure and fall back
to raising RLIMIT_MEMLOCK, which requires CAP_SYS_RESOURCE. Without it that
fallback hard-fails the whole tracer instead of the no-op it's meant to be
(observed: curl's shim exiting before exec'ing real curl with "remove
memlock: operation not permitted").

Also logs $PATH alongside setcap failures, to help root-cause the separate
"setcap: executable file not found in $PATH" failures seen for a chunk of
the install list in some coverage runs.
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 43.73%. Comparing base (10d21a8) to head (f2f3603).
⚠️ Report is 2 commits behind head on main.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #131   +/-   ##
=======================================
  Coverage   43.73%   43.73%           
=======================================
  Files          11       11           
  Lines        1525     1525           
=======================================
  Hits          667      667           
  Misses        762      762           
  Partials       96       96           

☔ View full report in Codecov by Harness.
📢 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.

@ilmanzo
ilmanzo merged commit e35a8f3 into main Aug 9, 2026
2 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