Skip to content

litert/xnnpack: guard against zero input dimension in ResizeNearestNeighborOperation::ToXnnpack() - #11055

Open
destro4evr-rgb wants to merge 1 commit into
google:masterfrom
destro4evr-rgb:fix/resize-nearest-neighbor-sigfpe
Open

litert/xnnpack: guard against zero input dimension in ResizeNearestNeighborOperation::ToXnnpack()#11055
destro4evr-rgb wants to merge 1 commit into
google:masterfrom
destro4evr-rgb:fix/resize-nearest-neighbor-sigfpe

Conversation

@destro4evr-rgb

@destro4evr-rgb destro4evr-rgb commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

ResizeNearestNeighborOperation::ToXnnpack() reads input_h and input_w directly from the flatbuffer shape field and uses them as integer divisors in modulo and division operations (lines 1483–1489) without checking for zero. A crafted model with an input tensor whose height or width is 0 triggers SIGFPE during XNNPACK subgraph compilation at model load time - before any inference runs.

The sibling ResizeBilinearOperation::ToXnnpack() passes dimensions directly to xnn_define_static_resize_bilinear_2d without any division and is not affected. This function uniquely computes an integer scale factor via division and had no guard for a zero divisor.

Fix: add an explicit non-zero check for input_h and input_w immediately after they are read, before the first modulo operation.

@destro4evr-rgb

Copy link
Copy Markdown
Contributor Author

Hi @qukhan, looks like #11055, #11056, and #11057 are all stuck on CI failures - is there anything needed from my end to get them moving?

@qukhan

qukhan commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Looks like there's a merge conflict internally. Can you try rebasing onto the main branch?

…ighbor

input_h and input_w are read directly from the flatbuffer shape field and
used as integer divisors in the modulo and division operations at lines
1483-1489. A crafted model with a zero height or width triggers SIGFPE
(integer divide-by-zero) during XNNPACK subgraph compilation at model load
time. Add an explicit non-zero check before the first use of either value.
@destro4evr-rgb
destro4evr-rgb force-pushed the fix/resize-nearest-neighbor-sigfpe branch from 53e041a to d37e157 Compare August 31, 2026 16:09
@destro4evr-rgb

Copy link
Copy Markdown
Contributor Author

Hi @qukhan, #11055 #11056 #11057 all three rebased.

copybara-service Bot pushed a commit to google-ai-edge/LiteRT that referenced this pull request Aug 31, 2026
--
d37e157a165998c9edf771d2692ce132c2a75086 by destro4evr-rgb <destro4evr@proton.me>:

litert/xnnpack: guard against zero input dimension in ResizeNearestNeighbor

input_h and input_w are read directly from the flatbuffer shape field and
used as integer divisors in the modulo and division operations at lines
1483-1489. A crafted model with a zero height or width triggers SIGFPE
(integer divide-by-zero) during XNNPACK subgraph compilation at model load
time. Add an explicit non-zero check before the first use of either value.

FUTURE_COPYBARA_INTEGRATE_REVIEW=google/XNNPACK#11055 from destro4evr-rgb:fix/resize-nearest-neighbor-sigfpe d37e157a165998c9edf771d2692ce132c2a75086
LiteRT-PiperOrigin-RevId: 971398177
copybara-service Bot pushed a commit that referenced this pull request Sep 1, 2026
--
d37e157 by destro4evr-rgb <destro4evr@proton.me>:

litert/xnnpack: guard against zero input dimension in ResizeNearestNeighbor

input_h and input_w are read directly from the flatbuffer shape field and
used as integer divisors in the modulo and division operations at lines
1483-1489. A crafted model with a zero height or width triggers SIGFPE
(integer divide-by-zero) during XNNPACK subgraph compilation at model load
time. Add an explicit non-zero check before the first use of either value.

FUTURE_COPYBARA_INTEGRATE_REVIEW=#11055 from destro4evr-rgb:fix/resize-nearest-neighbor-sigfpe d37e157
PiperOrigin-RevId: 971398177
copybara-service Bot pushed a commit to google-ai-edge/LiteRT that referenced this pull request Sep 1, 2026
--
d37e157a165998c9edf771d2692ce132c2a75086 by destro4evr-rgb <destro4evr@proton.me>:

litert/xnnpack: guard against zero input dimension in ResizeNearestNeighbor

input_h and input_w are read directly from the flatbuffer shape field and
used as integer divisors in the modulo and division operations at lines
1483-1489. A crafted model with a zero height or width triggers SIGFPE
(integer divide-by-zero) during XNNPACK subgraph compilation at model load
time. Add an explicit non-zero check before the first use of either value.

Reverts 71dd844

FUTURE_COPYBARA_INTEGRATE_REVIEW=google/XNNPACK#11055 from destro4evr-rgb:fix/resize-nearest-neighbor-sigfpe d37e157a165998c9edf771d2692ce132c2a75086
LiteRT-PiperOrigin-RevId: 971398177
@destro4evr-rgb

Copy link
Copy Markdown
Contributor Author

Hi @qukhan , just a friendly ping - #11057 got merged but #11055 and #11056 are still sitting. Could these need a rebase, or is something else blocking them?

@qukhan

qukhan commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

I'm still working towards getting them through.

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.

2 participants