Fix uninitialized memory disclosure in WASM CropAndResize#8730
Open
Alearner12 wants to merge 1 commit into
Open
Fix uninitialized memory disclosure in WASM CropAndResize#8730Alearner12 wants to merge 1 commit into
Alearner12 wants to merge 1 commit into
Conversation
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.
WASM CropAndResize: handle invalid
boxIndoutputs deterministicallySummary
This updates the WASM
CropAndResizekernel to handle out-of-rangeboxIndvalues deterministically. When a crop references an invalid batch index, the
kernel now zero-fills that crop's output slice, advances the
boxIndpointer,and skips the geometric transform for that crop.
This keeps invalid-index handling local to the crop being processed. Valid crop
entries continue to use the existing interpolation path unchanged.
Bug
The WASM kernel previously skipped positive out-of-range
boxIndvalues withoutwriting the corresponding output slice:
It also did not reject negative
boxIndvalues before using the value in anoffset calculation. This could leave the output tensor in a backend-dependent
state for invalid indices, and made the WASM behavior less predictable than the
rest of the op's validation model.
There is a second correctness issue in the early-continue path: because the
kernel manually walks
box_ind_buf, returning before incrementing that pointercan desynchronize later crops from their intended batch indices.
Fix
boxIndvalues.box_ind_bufbefore continuing so later crops stay synchronized.size_tonly after the bounds check.Test
Adds a WASM backend regression test that calls
tf.image.cropAndResize()withtwo invalid indices (
999and-1) and verifies that the full output isdeterministically zero-filled.
The test covers both sides of the invalid range:
999verifies positive out-of-range handling.-1verifies negative indices are rejected before conversion tosize_t.box_ind_bufstayssynchronized across crops.