Add CodeQL sanitizers for Buffer pool operations to eliminate false positives #4739
+186
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CodeQL reports false positives when Buffers are reused from the pool. A Buffer receives tainted data, gets returned to the pool via
buf_pool_release()(which callsbuf_reset()→memset()), then laterbuf_pool_get()returns it. CodeQL incorrectly flags the reused Buffer as still tainted.Changes
Custom CodeQL query pack (
.github/codeql-custom-queries/):CustomSanitizers.qll- DefinesBufferPoolSanitizerclass recognizing these functions clear taint:buf_reset(buf)- clears with memsetbuf_pool_release(&buf)- calls buf_reset internallymemset(ptr, 0, size)- explicit zeroingbuf_pool_get()- returns sanitized bufferTaintWithBufferSanitizers.ql- Taint tracking query using the sanitizersqlpack.yml- Query pack definitionREADME.md- Documents the false positive patternCodeQL configuration:
.github/codeql.ymlto include custom query packThe GitHub Actions workflow automatically picks up these queries on next run.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.