Expand description
Loop summarization with widening+narrowing (DF-10).
Build a loop-summary Program:
use weir::loop_sum::loop_summarize;
let program = loop_summarize("prev", "next", "out");DF-10 - loop summarization (stratified fixpoint acceleration).
Widening + narrowing over loops so range / taint analyses terminate in finitely many iterations on unbounded loops. Required for decode-chain detection (C10 decompression bomb, C11 parser differential, C15 path traversal decode chain) where the vuln only manifests after N iterations of a loop that reads a length-prefixed field.
§Implementation
Standard Cousot widening on the interval lattice: at a loop
header, the new summary is widen(prev, new) where
widen(⟨a, b⟩, ⟨c, d⟩) keeps a if it was finite and reduced
else jumps to -∞, and keeps b if it was finite and grew
else jumps to +∞. The u32 lattice uses 0 as -∞ sentinel
and u32::MAX as +∞ sentinel.
Each invocation handles one variable’s [lo, hi] pair,
identical buffer layout to DF-7 range.
Soundness: MayOver under the standard
widening-narrowing correctness argument.
Structs§
- LoopSum
- Marker type for the loop-summarization dataflow primitive.
- Loop
Summarize Scratch - Caller-owned staging for repeated loop-summary dispatches.
Functions§
- loop_
summarize - One widening step.
cfg_inholds the previous-iteration intervals[prev_lo_v, prev_hi_v, …];ranges_inholds the new iteration’s intervals;summary_outreceives the widened result per variable. - loop_
summarize_ borrowed_ into_ result_ with_ scratch_ via - GPU loop summarization using caller-owned staging/output scratch and caller-owned decoded result storage.
- loop_
summarize_ borrowed_ into_ via - GPU loop summarization using borrowed dispatch inputs and caller-owned output storage.
- loop_
summarize_ borrowed_ via - GPU loop summarization using borrowed dispatch inputs.
- loop_
summarize_ borrowed_ with_ scratch_ via - GPU loop summarization using borrowed dispatch inputs and caller-owned staging/output scratch.
- loop_
summarize_ via - try_
loop_ summarize_ with_ count - Checked version of [
loop_summarize_with_count] for production GPU wrappers.