Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
NEX-S
force-pushed
the
fix-circular-buffer-zero-num-slots-oob
branch
from
September 4, 2026 09:59
8664810 to
726ce45
Compare
CircularBufferEval computes the buffer shift size as (num_slots - 1) * depth, where num_slots is output->dims->data[1]. CircularBufferPrepare did not validate this dimension; with num_slots == 0 the size becomes negative and wraps to a huge size_t when passed to memmove, causing an out-of-bounds read/write on the output tensor. All dimensions come from the model file, so a crafted model can trigger this. Reject output slot counts < 1 in Prepare and add a regression test that fails without the fix and passes with it. BUG=tensorflow#3695
NEX-S
force-pushed
the
fix-circular-buffer-zero-num-slots-oob
branch
from
September 5, 2026 05:12
d58760a to
d06d60d
Compare
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.
BUG=#3695
What
CircularBufferEvalcomputes the buffer shift size as(num_slots - 1) * depth, wherenum_slots = output->dims->data[1].CircularBufferPreparevalidated the other dimensions but never checked that the output slot count is at least 1.Why
With
num_slots == 0,(num_slots - 1) * depthevaluates to-depthas anintand wraps to a hugesize_twhen passed tomemmoveinEvalInt8:This performs a large out-of-bounds read from
output + depthand a large out-of-bounds write starting atoutput. All tensor dimensions come from the model file, so a crafted.tflitemodel can trigger this (reproduced under ASan asnegative-size-param, see #3695). On microcontroller targets, which typically run without mitigations, this is an out-of-bounds write primitive.Fix
Reject slot counts < 1 in
CircularBufferPrepare:Testing
Added
CircularBufferTest.ZeroNumSlotsRejectedInPrepare:InitAndPreparereturnskTfLiteOkfor a[1,0,1,1]output, where it must fail).Preparerejects the shape).Existing tests (4) continue to pass.