fix(bpf): disable preemption during hook processing - #1569
Conversation
This prevents the hooks from being preempted and replaced by another hook that might overwrite the contents of the shared per-CPU maps before sending the event to the ringbuffer. A similar issue was found to be corrupting events in Falco and is addressed in this PR of our fork, see the discussion there for more details: stackrox/falcosecurity-libs#98 In order to call `bpf_preempt_enable/disable` aya needs to support ksyms, which is currently only supported on main, therefore we pin the dependency to a commit known to work. We will unpin this once a new aya release is created.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthroughThe PR pins ChangesAYA and LSM compatibility
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The PR updates BPF hook processing to prevent preemption and pins a compatible dependency version; no actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description explains the problem, solution, Aya dependency pin, macro changes, checklist status, and testing performed. The unchecked documentation and automated-test items are addressed by the stated scope and the note that CI is sufficient. ✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1569 +/- ##
=======================================
Coverage 33.96% 33.96%
=======================================
Files 22 22
Lines 3421 3421
Branches 3421 3421
=======================================
Hits 1162 1162
Misses 2254 2254
Partials 5 5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
These kfuncs where added in kernel version 6.12 and causes verifier issues on RHCOS 4.16 and 4.18 on our CI.
Description
This prevents the hooks from being preempted and replaced by another hook that might overwrite the contents of the shared per-CPU maps before sending the event to the ringbuffer. A similar issue was found to be corrupting events in Falco and is addressed in this PR of our fork, see the discussion there for more details: stackrox/falcosecurity-libs#98
In order to call
bpf_preempt_enable/disableaya needs to support ksyms, which is currently only supported on main, therefore we pin the dependency to a commit known to work. We will unpin this once a new aya release is created.As a final simplification, to prevent new hooks and branches in existing one from having to remember to re-enable preemption before exiting some macro magic is used. We can potentially leverage these macros to define some other common patterns in the future.
Checklist
Automated testing
If any of these don't apply, please comment below.
Testing Performed
CI should be enough.
Summary by CodeRabbit