perf_hooks: validate import normalization offset - #65950
Open
mcollina wants to merge 1 commit into
Open
Conversation
The CBOR importer accepts a normalizing_index_offset outside the range of the allocated counts array. normalize_index() in hdr_histogram.c applies at most one wrap adjustment of +/-counts_len, so an arbitrary offset can remain out of bounds and a later record() performs an out-of-bounds native write in counts_inc_normalised(). Reject offsets that are not representable as int32_t when reading the CBOR field, and reject offsets outside [0, counts_len) after the histogram is reconstructed. Add regression tests covering the boundary at counts_len, offsets beyond it, and values that cannot be represented as int32_t. Signed-off-by: Matteo Collina <hello@matteocollina.com> Assisted-by: pi
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #65950 +/- ##
==========================================
- Coverage 90.17% 90.17% -0.01%
==========================================
Files 770 771 +1
Lines 264483 265488 +1005
Branches 50262 50472 +210
==========================================
+ Hits 238491 239396 +905
- Misses 16981 17044 +63
- Partials 9011 9048 +37
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
perf_hooks: validate import normalization offset
The CBOR importer accepts a
normalizing_index_offsetoutside the rangeof the allocated counts array.
normalize_index()inhdr_histogram.capplies at most one wrap adjustment of +/-
counts_len, so an arbitraryoffset can remain out of bounds and a later
record()performs anout-of-bounds native write in
counts_inc_normalised().Reject offsets not representable as
int32_twhen reading the CBORfield, and reject offsets outside
[0, counts_len)after the histogramis reconstructed. Adds regression tests for the boundary at
counts_len, offsets beyond it, and non-int32_tvalues.