Validate output size in FILTER_BANK_LOG kernel#3603
Open
adilburaksen wants to merge 1 commit into
Open
Conversation
FilterBankLogEval derives num_channels from the input tensor and FilterbankLog writes that many elements to the output. FilterBankLogPrepare checked only the rank and type of the input and output, never that the output has at least as many elements as the input, so a model whose output tensor is smaller than its input caused an out-of-bounds write (confirmed with AddressSanitizer). Add an output-size check in FilterBankLogPrepare and a regression test.
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=out-of-bounds write in FILTER_BANK_LOG kernel from unchecked output size
What
FilterBankLogEvaltakesnum_channelsfrom the input tensor(
num_channels = input->dims->data[0]) andFilterbankLogwritesnum_channelselements to the output:
FilterBankLogPreparevalidated only the rank and type of the input and outputtensors — never that the output is at least as large as the input. A model whose
FILTER_BANK_LOGoutput tensor is smaller than its input therefore causes anout-of-bounds write (e.g. input of 32 elements, output of 1), confirmed with
AddressSanitizer:
Change
filter_bank_log.cc:FilterBankLogPreparenow requiresElementCount(output) >= ElementCount(input).filter_bank_log_test.cc: regression test that the mismatched model is rejected.No change for valid models.