solidigm: fix integer overflow in sldm_parse_cd_uart_log() - #3775
Open
sahmed-ibm wants to merge 1 commit into
Open
solidigm: fix integer overflow in sldm_parse_cd_uart_log()#3775sahmed-ibm wants to merge 1 commit into
sahmed-ibm wants to merge 1 commit into
Conversation
The sldm_parse_cd_uart_log() function computes a bit offset from @offset and the loop index @i, both of which are 32-bit unsigned integers. The expression (offset + i * 192) * 8 is evaluated entirely in 32-bit arithmetic before being assigned to the 64-bit @entry_offset_bit variable. For large telemetry buffers, this expression can exceed the 32-bit unsigned maximum, silently wrapping to a wrong value before the result is widened to 64 bits. This causes the subsequent entry parser to read data from an incorrect bit offset in the telemetry log. Cast @offset and @i to uint64_t before the multiplication so that the entire expression is computed in 64-bit arithmetic, preventing the overflow. Signed-off-by: Sarah Ahmed <sarah.ahmed@ibm.com>
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.
The sldm_parse_cd_uart_log() function computes a bit offset from offset and the loop index i, both of which are 32-bit unsigned integers. The expression (offset + i * 192) * 8 is evaluated entirely in 32-bit arithmetic before being assigned to the 64-bit entry_offset_bit variable.
For large telemetry buffers, this expression can exceed the 32-bit unsigned maximum, silently wrapping to a wrong value before the result is widened to 64 bits. This causes the subsequent entry parser to read data from an incorrect bit offset in the telemetry log.
Cast offset and i to uint64_t before the multiplication so that the entire expression is computed in 64-bit arithmetic, preventing the overflow.