[8.19](backport #51520) osquerybeat: fix data race on osquery runner cancel function#51564
Conversation
osquerybeat: fix data race on osquery runner cancel function The `process` closure in `osqueryRunner.Run` reads the `cn` (context cancel function) variable without holding the mutex, while the goroutine running osqueryd can concurrently set `cn = nil` through `cancel()`. This is a data race that can cause a nil-pointer crash when osquery restarts after a configuration change. Fix by guarding every read and write of `cn` in `process` with the existing mutex (cherry picked from commit ecb9455) # Conflicts: # x-pack/osquerybeat/beater/osquery_runner.go
|
Cherry-pick of ecb9455 has failed: To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally |
🤖 GitHub commentsJust comment with:
|
|
Pinging @elastic/sec-windows-platform (Team:Security-Windows Platform) |
TL;DRThe Remediation
Investigation detailsRoot CauseThis is an unresolved backport/cherry-pick conflict, not an infrastructure failure. The PR diff for Evidence
Verification
What is this? | From workflow: PR Buildkite Detective Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not. |
|
This pull request has not been merged yet. Could you please review and merge it @orestisfl? 🙏 |
e127dfb to
e9fd5f6
Compare
Resolve merge conflicts from the cherry-pick of ecb9455 by adapting the race fix to the 8.19 branch: keep the simpler flags-only restart condition (no logLevel), drop the logLevel variable (not present on 8.19), and use sync.WaitGroup.Go (available since Go 1.24).
e9fd5f6 to
147e57a
Compare
TL;DR
Remediation
Investigation detailsRoot CauseThe backport conflict was resolved by storing the This is a different failure from the previous detective comment on this PR: that earlier report covered unresolved merge-conflict markers in Buildkite pre-commit, while this workflow fails after conflict resolution in GitHub Actions Evidence
Validation
Follow-up
What is this? | From workflow: PR Actions Detective Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not. |
Proposed commit message
Checklist
I have made corresponding changes to the documentationI have made corresponding change to the default configuration filesstresstest.shscript to run them under stress conditions and race detector to verify their stability../changelog/fragmentsusing the changelog tool.How to test this PR locally
script/stresstest.sh --race ./x-pack/osquerybeat/beater '^TestOsqueryRunner'This is an automatic backport of pull request #51520 done by [Mergify](https://mergify.com).