Repository navigation
Conversation
PadOp indexes the padding tensor's buffer using the operand rank, in both map_bounds (padding(0, d)) and execute (padding_buf(0/1, idx)), guarded only by assert(). In a release build a .tflite model whose PAD padding tensor is not shaped [2, rank] reads past the padding buffer, which points directly at the model's flatbuffer bytes. Check the padding shape and the input/output ranks in the PadOp constructor, so both the tflite parser and the delegate are covered. Well-formed models are unaffected.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9716 +/- ##
==========================================
+ Coverage 73.25% 73.27% +0.02%
==========================================
Files 266 266
Lines 83749 83749
Branches 20572 20572
==========================================
+ Hits 61352 61371 +19
+ Misses 15845 15822 -23
- Partials 6552 6556 +4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
PadOpreads the padding tensor's buffer using the operand rank:padding(0, d)fordin[0, output rank)inmap_bounds, andpadding_buf(0/1, idx)foridxin[0, input rank)inexecute. Both are only guarded byassert(), which is compiled out of release builds. The padding tensor is model data, and when it is constant its buffer points straight at the model's flatbuffer bytes, so a.tflitewhose PAD padding tensor is not shaped[2, rank]reads past that buffer. On a-DNDEBUG -fsanitize=addressbuild, a[2, 2]padding tensor with a rank-4 operand gives a heap-buffer-overflow READ 0 bytes past the 16-byte region.This op was not among the ones covered by #9704 (Concatenation/Split/Gather/Transpose). Those check an axis attribute against a tensor's own rank; here a separate parameter tensor's shape must match the operand rank. The check goes in the
PadOpconstructor so both the tflite parser and the delegate are covered, matching the constructor-side checks #9704 added. Well-formed models construct and run exactly as before.hannk has no unit-test harness for individual ops, so I verified this standalone against
HalideBuffer.h: thepadding(0, d)read trips ASan before the change, and after it the constructor rejects a[2, 2]padding tensor for a rank-4 operand while a valid[2, 4]tensor still constructs.Checklist