-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(libscap): use the correct memory barrier for ARM64 #2067
fix(libscap): use the correct memory barrier for ARM64 #2067
Conversation
Please double check driver/API_VERSION file. See versioning. /hold |
Signed-off-by: Andrea Terzolo <andreaterzolo3@gmail.com>
fb32f02
to
7375fc8
Compare
Perf diff from master - unit tests
Heap diff from master - unit tests
Heap diff from master - scap file
Benchmarks diff from master
|
#endif | ||
|
||
// This is defined by us | ||
#if defined(__x86_64__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is used by the scap_kmod and scap_bpf engines and it uses the same primitive of smp_store
/smp_load
LGTM label has been added. Git tree hash: 5a1104014ab3043c18da50fbcf6b1f96d3032a20
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great fix!
Than you very much for digging into it!
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Andreagit97, FedeDP The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2067 +/- ##
=======================================
Coverage 73.58% 73.58%
=======================================
Files 253 253
Lines 31867 31867
Branches 5648 5633 -15
=======================================
Hits 23449 23449
+ Misses 8398 8388 -10
- Partials 20 30 +10
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
What type of PR is this?
/kind bug
Any specific area of the project related to this PR?
/area libscap-engine-bpf
/area libscap-engine-kmod
/area libpman
Does this PR require a change in the driver versions?
No
What this PR does / why we need it:
This PR should fix #2061.
Today
smp_load_acquire
andsmp_store_release
use the synchronization primitives of x86 also on other architectures... but thanks to the nature of our code we never noticed it until this PR #2009.More detail in the addition of
caused the
g_state.prod_pos[pos]
value to be used immediately after the fetch. So if it was a wrong value we might end up reading some junk from the buffer... And this is exactly what is happening here #2061. This is for the modern ebpf.the other drivers also used the wrong primitives, but again, probably due to some luck and rare race conditions we never faced any issues...btw I tried to fix them
The fix is to use the right synchronization primitives! Unfortunately, the definitions of these primitives are in the kernel headers so to avoid the constraint of having the headers when building libscap engines, I decided to copy the needed definitions, not sure if we want to take other directions here...
Which issue(s) this PR fixes:
Fixes #2061
Special notes for your reviewer:
Does this PR introduce a user-facing change?: