Skip to content

fix(convolutiondepthwise): add group == 0 guard to prevent FPE - #6912

Open
beilzx wants to merge 1 commit into
Tencent:masterfrom
beilzx:fix-convolutiondepthwise-group-zero-check
Open

fix(convolutiondepthwise): add group == 0 guard to prevent FPE#6912
beilzx wants to merge 1 commit into
Tencent:masterfrom
beilzx:fix-convolutiondepthwise-group-zero-check

Conversation

@beilzx

@beilzx beilzx commented Aug 17, 2026

Copy link
Copy Markdown

Summary:

  • The Vulkan backend already has the correct group == 0 || num_output % group != 0 check.
  • CPU backend (convolutiondepthwise.cpp:46) and 1D variant (convolutiondepthwise1d.cpp:40) are missing the group == 0 guard.
  • When a malicious param file stores group as an array type, pd.get(7, 1) returns 0, triggering integer divide-by-zero.

Verification:

  • Built ncnn with AddressSanitizer (-fsanitize=address).
  • Reproduced FPE with the AFL++ generated crash sample.
  • Confirmed the patch gracefully rejects the invalid param with layer load_param failed instead of crashing.

Fixes #6911

Summary:
- The Vulkan backend already has the correct `group == 0 || num_output % group != 0` check.
- CPU backend (convolutiondepthwise.cpp:46) and 1D variant
  (convolutiondepthwise1d.cpp:40) are missing the `group == 0` guard.
- When a malicious param file stores group as an array type,
  `pd.get(7, 1)` returns 0, triggering integer divide-by-zero.

Verification:
- Built ncnn with AddressSanitizer (`-fsanitize=address`).
- Reproduced FPE with the AFL++ generated crash sample.
- Confirmed the patch gracefully rejects the invalid param with
  `layer load_param failed` instead of crashing.

Fixes Tencent#6911
@github-actions github-actions Bot added the layer label Aug 17, 2026
@tencent-adm

tencent-adm commented Aug 17, 2026

Copy link
Copy Markdown
Member

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: FPE (divide-by-zero) in ConvolutionDepthWise::load_param (src/layer/convolutiondepthwise.cpp:46)

2 participants