Guard packed weights size against integer overflow in batch matrix multiply - #10842
Merged
copybara-service[bot] merged 1 commit intoJul 24, 2026
Conversation
…ltiply create_batch_matrix_multiply_nc_const_weights computes the packed weights buffer size as a raw multiplication: packed_size = batch_size_b * n_stride * weights_stride with no overflow protection. Uses xnn_safe_mul, matching the pattern already used elsewhere in this file and in convolution-nhwc.c.
copybara-service Bot
pushed a commit
that referenced
this pull request
Jul 24, 2026
-- ce7cce0 by prasanna8585 <prasanna8585@users.noreply.github.com>: Guard packed weights size against integer overflow in batch matrix multiply create_batch_matrix_multiply_nc_const_weights computes the packed weights buffer size as a raw multiplication: packed_size = batch_size_b * n_stride * weights_stride with no overflow protection. Uses xnn_safe_mul, matching the pattern already used elsewhere in this file and in convolution-nhwc.c. FUTURE_COPYBARA_INTEGRATE_REVIEW=#10842 from prasanna8585:fix-batch-matmul-packed-size-overflow ce7cce0 PiperOrigin-RevId: 953455603
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.
create_batch_matrix_multiply_nc_const_weights computes the packed weights buffer size as:
with no overflow protection, unlike reshape_batch_matrix_multiply_nc in the same file which already uses xnn_safe_mul for its own workspace size computation.
This uses xnn_safe_mul for the same computation here, consistent with that existing pattern.