-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Use mutex to protect access to librpm #40525
Conversation
Pinging @elastic/sec-linux-platform (Team:Security-Linux Platform) |
This pull request does not have a backport label.
To fixup this pull request, you need to add the backport labels for the needed
|
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.
I see no other uses of openedLibrpm
. LGTM
@Mergifyio backport 8.15 |
✅ Backports have been created
|
* use mutex for access to librpm * add changelog (cherry picked from commit 46fd21c) # Conflicts: # x-pack/auditbeat/module/system/package/rpm_linux.go
* use mutex for access to librpm * add changelog (cherry picked from commit 46fd21c)
More Librpm shenanigans. Turns out that it's possible for a user to run two instances of a metricset at once, which I didn't even know was possible or supported. However, librpm has some not-great threadsafety in it, and it's also possible for a shutdown operation to call dlclose while another thread is in the middle of accessing the SO. This adds a global mutex so we can't have multiple threads stepping on each other during RPM operations. I tested this a bit, and I couldn't get it to crash while running multiple instances of the package metricset, but at this point librpm is so easy to break I would consider it more "best effort" than anything else. (cherry picked from commit 46fd21c) Co-authored-by: Alex K. <8418476+fearful-symmetry@users.noreply.github.com>
Proposed commit message
More Librpm shenanigans. Turns out that it's possible for a user to run two instances of a metricset at once, which I didn't even know was possible or supported. However, librpm has some not-great threadsafety in it, and it's also possible for a shutdown operation to call
dlclose
while another thread is in the middle of accessing the SO. This adds a global mutex so we can't have multiple threads stepping on each other during RPM operations.I tested this a bit, and I couldn't get it to crash while running multiple instances of the package metricset, but at this point librpm is so easy to break I would consider it more "best effort" than anything else.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
You'll need to get auditbeat to run two instances of the metricset. Easiest way I've found to this is to create two separate system integration configs
system-1.yml
andsystem-2.yml
with a basic config:Then set the file config in the main auditbeat config:
After you do that, just....repeatedly run auditbeat and send it random sigints.