gguf, ggml : guard tensor type reads and size allocation against overflows #32761
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.36) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 183 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.312
Real PR Conversation Timeline
1 comments
"Review active on #32761"
general
weight: 0.35
jaredwy
Overview
Fixes remaining Undefined Behaviour and
size_toverflow paths in GGUF tensor parsing and tensor allocator across two commits:1. GGUF parsing:
- Read the 4-byte tensor type into
int32_tand validate0, GGML_TYPE_COUNT)before converting toenum ggml_type, avoiding C++ enum UB on malformed files.- Guards introduced against
SIZE_MAXso tensors with trailing zero dimensions (whereggml_nelements()is0) cannot silently wrapsize_tstrides.- Test
test_handcrafted_overflow_guards()added to verify both cases returnnullptr.2. Tensor Allocator:
- Avoid pointer wraparound in
aligned_offsetand assertoffset <= SIZE_MAX - align.- Check
raw_size <= SIZE_MAX - (align - 1)beforeGGML_PADand compare remaining capacity viasize > buf_size - talloc->offsetinstead oftalloc->offset + size > buf_size.- Test
test_tallocr_overflow_guards()added to verifyggml_tallocr_allocreturnsGGML_STATUS_SUCCESS.Additional information
test-ggufandtest-allocin Release mode on Windows (MSVC) and confirmed 2/2 pass underctest.Requirements