-
Notifications
You must be signed in to change notification settings - Fork 29
issue: 4347777 Replace thread-local dummy lock with global one #326
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
Conversation
02361d9 to
ab41c35
Compare
The thread-local dummy locker in ring_slave could cause use-after-free issues during XLIO shutdown when one thread attempts to access a socket's locker that was created by a terminated thread. This occurs because the thread-local object is freed when its creator thread terminates. Replace the thread-local dummy locker with a global one to prevent this issue. To maintain data path performance, optimize the dummy lock for a different cache-line to prevent false sharing by aligning the lock on a 64-byte boundary. Signed-off-by: Tomer Cabouly <[email protected]>
|
bot:retest |
|
/review |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
@tomerdbz , please move to Fix/closed |
Description
This change replaces a thread-local dummy locker with a global one in ring_slave.cpp to fix a use-after-free issue.
What
Replace thread-local dummy locker with a global one in ring_slave.
Why ?
During XLIO shutdown, when one thread attempts to access a socket's locker that was created by a terminated thread, a use-after-free issue occurs because the thread-local dummy locker object is freed when its creator thread terminates. This can lead to segmentation faults during cleanup.
How ?
The solution is straightforward:
This change ensures the dummy locker remains valid throughout the program's lifetime, regardless of thread termination status.
Performance considerations
Pros of global implementation:
The global was aligned to be in a different cache line to prevent false-sharing - thus not introducing perf hit,
Tests
added a system-test (gtest) that discovered same issue occured on src/core/sock/sockinfo_tcp.cpp.
Applied the same fix there as well for the test to pass.
Change type
What kind of change does this PR introduce?
Check list