fix: grant cap_sys_resource to the shim, log $PATH on setcap failure - #131
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cilium/ebpf'srlimit.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 raisingRLIMIT_MEMLOCK, which requiresCAP_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 withremove memlock: operation not permitted).cap_sys_resourceto the shim's capability set insetShimCapsas cheap, low-risk insurance against that fallback path — scoped to the shim binary via file capabilities, used for exactly onePrlimitcall.$PATHalongside 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 ./...andgo vet ./...pass./run_unit_tests.shpasseslibcap-progstest-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 oncesetcapitself is working.