Repository navigation
Copybara import of the project: - #11586
Closed
copybara-service[bot] wants to merge 1 commit into
Closed
copybara-service[bot] wants to merge 1 commit into
copybara-service[bot] wants to merge 1 commit into
Conversation
-- 1d17f75 by prasanna8585 <65734642+prasanna8585@users.noreply.github.com>: Fix integer overflow in fully-connected-nc.c bias/kernel buffer sizing output_channels * sizeof(xnn_float16) (xnn_create_fully_connected_nc_f16, xnn_create_fully_connected_nc_pf16) and input_channels * output_channels * sizeof(float) / output_channels * sizeof(float) (xnn_create_fully_connected_nc_f32_f16, xnn_create_fully_connected_nc_pf32_f16) were used directly as allocation sizes and write-loop bounds with no overflow check, before any other parameter validation runs. On 32-bit size_t targets this allows a caller-supplied channel count to wrap the allocation size to a few bytes while the loop still writes/reads the real, unwrapped count: heap-buffer-overflow write, plus an out-of-bounds read of the caller-supplied bias array in the f16-bias case. Guard all four sites with the existing xnn_safe_mul() helper, matching the pattern already used for the main packed-weights buffer allocation elsewhere in this file, returning xnn_status_invalid_parameter on overflow instead of allocating an undersized buffer. FUTURE_COPYBARA_INTEGRATE_REVIEW=#10935 from prasanna8585:fix/fully-connected-nc-output-channels-overflow fbb6b0d PiperOrigin-RevId: 993240027
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.
Copybara import of the project:
--
1d17f75 by prasanna8585 65734642+prasanna8585@users.noreply.github.com:
Fix integer overflow in fully-connected-nc.c bias/kernel buffer sizing
output_channels * sizeof(xnn_float16) (xnn_create_fully_connected_nc_f16,
xnn_create_fully_connected_nc_pf16) and input_channels * output_channels *
sizeof(float) / output_channels * sizeof(float)
(xnn_create_fully_connected_nc_f32_f16, xnn_create_fully_connected_nc_pf32_f16)
were used directly as allocation sizes and write-loop bounds with no
overflow check, before any other parameter validation runs. On 32-bit
size_t targets this allows a caller-supplied channel count to wrap the
allocation size to a few bytes while the loop still writes/reads the real,
unwrapped count: heap-buffer-overflow write, plus an out-of-bounds read of
the caller-supplied bias array in the f16-bias case.
Guard all four sites with the existing xnn_safe_mul() helper, matching the
pattern already used for the main packed-weights buffer allocation
elsewhere in this file, returning xnn_status_invalid_parameter on overflow
instead of allocating an undersized buffer.
FUTURE_COPYBARA_INTEGRATE_REVIEW=#10935 from prasanna8585:fix/fully-connected-nc-output-channels-overflow fbb6b0d