Repository navigation
Fix integer overflow in qc2w/qc4w requantization scale allocation - #10934
Merged
copybara-service[bot] merged 2 commits intoOct 6, 2026
Merged
copybara-service[bot] merged 2 commits into
copybara-service[bot] merged 2 commits into
Conversation
Contributor
Author
|
Hi Team, is there any update require from my side on this ? |
Contributor
|
Hi, we are waiting for internal approval. Nothing is required on your side. |
Contributor
Author
|
Hi @Aelphy , Just following up to check if this is ready to be merged. |
Contributor
|
Hm, could you please try rebase and push? |
setup_scale_params_qx8_qcyw computed the requantization-scale buffer size as an unguarded context->output_channels * sizeof(float), where output_channels is a direct parameter of the public API xnn_create_fully_connected_nc_qs8_qc2w (and its qc4w/qd8/qdu8 siblings that share this scale-params setup function). A caller supplying a large output_channels value overflows size_t, causing the allocation to wrap to a small value; the subsequent per-channel scale computation loop then reads and writes using the real, unwrapped output_channels, producing both a heap-buffer-overflow read (from the caller-supplied kernel_scale array) and a heap-buffer-overflow write (into the undersized requantization_scale allocation). Confirmed via ASan with output_channels = (1 << 62) + 16, which wraps the allocation to exactly 64 bytes. Applies xnn_safe_mul to the computation, consistent with the pattern already used for the main packed-weights allocation in this same file (line 264) and in convolution-nhwc.c / deconvolution-nhwc.c.
prasanna8585
force-pushed
the
fix/fc-qc2w-requant-scale-overflow
branch
from
September 9, 2026 17:50
b9315bc to
e0a9a56
Compare
Contributor
Author
|
Done rebased onto current master and pushed. Let me know if anything else needs adjusting. |
Contributor
Author
|
Hi Team, |
Contributor
Author
|
Hi @Aelphy , Just following up to check if this is ready to be merged. |
Contributor
|
Hi, sorry for long wait. PR was garbage collected in our internal system, could you please rebase again. |
Contributor
Author
|
Rebased onto master resolved the conflict, kept the overflow-checked version. Ready for another look. |
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.
setup_scale_params_qx8_qcyw computed the requantization-scale buffer size as an unguarded context-> output_channels * sizeof(float), where output_channels is a direct parameter of the public API xnn_create_fully_connected_nc_qs8_qc2w (and its qc4w/qd8/qdu8 siblings sharing this scale-params setup function). A caller supplying a large output_channels value overflows size_t, causing the allocation to wrap to a small value; the subsequent per-channel scale computation loop then reads and writes using the real, unwrapped output_channels.\n\nConfirmed via ASan (heap-buffer-overflow read and write) with output_channels = (1 << 62) + 16, which wraps the allocation to exactly 64 bytes.\n\nApplies xnn_safe_mul to the computation, consistent with the pattern already used for the main packed-weights allocation in this same file (line 264) and in convolution-nhwc.c / deconvolution-nhwc.c.