Repository navigation
Fix SEC shard count integer overflow (#2892) - #2967
Merged
Merged
Conversation
Limit hpa_sec_nshards and experimental_pac_sec_nshards to 255 to prevent uint8_t overflow and multiplication overflow during initialization.
guangli-dai
approved these changes
Jul 28, 2026
Contributor
|
Thank you for the patch! @NITIN9181 |
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.
Fixes #2892
Description:
The Small Extent Cache (SEC) configuration allowed the
nshardsto be configured with anysize_tvalue. However, the internal functions that select and cache shard identifiers (likesec_shard_pick) use auint8_t. Ifnshardsexceeded 255, the shard IDs silently wrapped around. Furthermore, an unboundednshardstriggered a multiplication integer overflow when allocating the internal SEC metadata arrays.This PR introduces two safety nets:
hpa_sec_nshardsandexperimental_pac_sec_nshardsinsrc/conf.cnow useCONF_CHECK_MAXwith a maximum limit of 255. Any configuration values greater than 255 will automatically be clipped safely.sec_init()insrc/sec.cnow assertsopts->nshards <= 255to guarantee no oversized configurations can trigger a buffer overflow or wrap-around programmatically.