← Back to Pull requests

linker: reject modules too small to hold a SPIR-V header #6977

Open
Hsnmohd opened this pull request with 21 lines diff across 2 files
View on GitHub
Hsnmohd Hsnmohd commented on Oct 18, 2026 12:43 UTC
Author

spvtools::Link (source/link/linker.cpp) reads binaries[i][SPV_INDEX_SCHEMA] (header word 4) for every input module before any check that the module is even five words long; binary_sizes[i] is only consulted later inside BuildModule. spirv-link builds each module with ReadBinaryFile, which happily returns a one-word vector for a 4-byte file (and a null/zero-length buffer for an empty one), so a module shorter than the SPIR-V header triggers a heap out-of-bounds read (empty input is a null-pointer deref). Reject inputs with fewer than SPV_INDEX_INSTRUCTION words up front, where the raw buffer is first touched.

ASan on spirv-link before the fix, with a 4-byte file (just the magic number):

==ERROR: AddressSanitizer: heap-buffer-overflow READ of size 4
  #0 spvtools::Link(...) linker.cpp:856

After: error: 1: Module 1 is too small to hold a SPIR-V header. (empty input likewise rejected). Added a regression test in test/link/binary_version_test.cpp that fails on the pre-fix tree.

Diff: 21 lines (+20 / -1) across 2 files Reviewer: dneto0 Review duration: 11280m
All Vouch review confidence checks passed
Residual risk 0.03 = Change Risk (0.23) × (1 − Review Confidence (0.89)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.23 · 21 lines diff across 2 files
0.23
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.89 · 1 substantive comment(s)
0.89
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
89%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Diff Size diff_size
0.185
Real PR Conversation Timeline
3 items
CLAassistant CLAassistant commented on Oct 18, 2026 12:43 UTC
Contributor

![CLA assistant check](https://cla-assistant.io/KhronosGroup/SPIRV-Tools?pullRequest=6977) <br/>Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.<br/><sub>You have signed the CLA already but the status is still pending? Let us recheck it.</sub>

dneto0 dneto0 approved these changes on Oct 24, 2026 16:45 UTC
Approved Reviewer

LGTM. Please sign the CLA

Reviewers
Assignees
Hsnmohd Hsnmohd
Labels
risk: low confidence: 89.1% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 22.9% (LOW) · Higher = larger blast radius
22.9%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 89.1% · Lower = rushed or shallow review
89.1%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 2.5% · Safe to merge
2.5%