fix: bounds-check tigris_mem_load_tile height window to fail closed on out-of-range rows - #36
Merged
Merged
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.
Summary
tigris_mem_load_tiledid not bounds-check its[h_start, h_end)row window against thesource tensor height, so a malformed or mis-tiled plan requesting rows outside
[0, H]would read past the tensor (an out-of-bounds read).
tigris_mem_load_tile_2dalready hasthis guard; this adds the matching one to the 1D primitive.
Defense-in-depth companion to the compiler fail-closed guard for a post-spatial strided
external skip: the runtime never OOB-reads even on a hand-built or future plan.
Change
tigris_mem_load_tile:if (h_start < 0 || h_end <= h_start || h_end > H) return TIGRIS_MEM_ERR_BAD_INDEX;, mirroringtigris_mem_load_tile_2d. The caller(
exec_stage_tiled) already propagates the error.test_load_tile_1d_rejects_bad_bounds: a validh_end == Hwindow still loads;negative
h_start,h_end == h_start, andh_end > Hare rejected. Without the guardthe negative case SIGSEGVs; with it, the test passes.
Testing
test_tile_2d: 409 passed. Runtime unit tests green. ASan/UBSan clean on the load_tile
exercisers (test_tile_2d, test_executor, test_row_offset). Stack-usage gate run locally.