Skip to content

Copybara import of the project: - #11157

Open
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_977470632
Open

Copybara import of the project:#11157
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_977470632

Conversation

@copybara-service

Copy link
Copy Markdown
Contributor

Copybara import of the project:

--
e9d6b38 by destro4evr-rgb destro4evr@proton.me:

litert/tensor: guard AveragePool2D/MaxPool2D/Conv2D/DepthwiseConv2D against under-rank input in arithmetic.h

AveragePool2D, MaxPool2D, Conv2DImpl, and DepthwiseConv2DImpl all
access fixed shape indices (shape[1], shape[2], shape[3]) without
first checking that the input (and filter) shape vectors are large
enough. A crafted TFLite model with a rank-0 or rank-1 tensor on
any of these operators causes an out-of-bounds std::vector::operator[]
access at graph-construction time, before inference, resulting in
SIGSEGV.

PR #11057 added equivalent guards to the ToXnnpack() methods in
arithmetic.cc (graph-compilation time), but the earlier crash in
arithmetic.h (graph-construction time) was not covered. Add rank < 4
checks before the first shape subscript in each function.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#11154 from destro4evr-rgb:fix/litert-conv-pool-arithmetic-h-rank-checks e9d6b38

--
e9d6b38 by destro4evr-rgb <destro4evr@proton.me>:

litert/tensor: guard AveragePool2D/MaxPool2D/Conv2D/DepthwiseConv2D against under-rank input in arithmetic.h

AveragePool2D, MaxPool2D, Conv2DImpl, and DepthwiseConv2DImpl all
access fixed shape indices (shape[1], shape[2], shape[3]) without
first checking that the input (and filter) shape vectors are large
enough. A crafted TFLite model with a rank-0 or rank-1 tensor on
any of these operators causes an out-of-bounds std::vector::operator[]
access at graph-construction time, before inference, resulting in
SIGSEGV.

PR #11057 added equivalent guards to the ToXnnpack() methods in
arithmetic.cc (graph-compilation time), but the earlier crash in
arithmetic.h (graph-construction time) was not covered. Add rank < 4
checks before the first shape subscript in each function.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#11154 from destro4evr-rgb:fix/litert-conv-pool-arithmetic-h-rank-checks e9d6b38
PiperOrigin-RevId: 977470632
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant