docs: document overflow risks in bulk-op fuel and bounds prologues - #176
docs: document overflow risks in bulk-op fuel and bounds prologues#176dmitry123 wants to merge 1 commit into
Conversation
|
Warning Review limit reached
Next review available in: 56 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Criterion results (vs baseline)Heads-up: runner perf is noisy; treat deltas as a smoke check. |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Summary
Documents the integer-overflow risks in the compiler-injected bulk-op prologues, per the direction on FLU-1104 — no behavior change, comments only.
The audit finding is that two patterns in the injected guards do not do what they were written to do:
op_memory_grow_checked,op_memory_init_checked,op_table_grow_checkedandop_table_init_checkedcomparesize + delta(orn + s) against a limit withi32.gt_sover a wrappingi32.add. An operand neari32::MAXmakes the sum negative, so the guard passes.(n + PER_FUEL - 1) >> PER_FUEL_LOG2; the add wraps fornnearu32::MAX, yielding (almost) zero fuel for a nominally multi-gigabyte operation.Neither is exploitable at the current limits — every input large enough to wrap is rejected by the runtime bounds check behind the guard before any memory or table element is touched, so no undercharged work is ever performed. The point is that the safety rests entirely on that bounds check, and a future change to the limits could make it exploitable with no visible change to the prologue code.
Changes
src/types/mod.rs—# Safetynotes onN_MAX_ALLOWED_MEMORY_PAGESandN_MAX_TABLE_SIZEexplaining that the injected guards depend on these limits staying far belowi32::MAX, and what must change first if they are raised.src/isa/memory.rs— file-level SAFETY NOTE on theMEMORY_BYTES_PER_FUELround-up, a# Safetynote onop_memory_grow_checked, a note on thememory.initguard, and pointers at each wrapping site.src/isa/table.rs— equivalent file-level SAFETY NOTE covering both the signed compares and theTABLE_ELEMS_PER_FUELround-up, with pointers at each site.Also replaces the stale comment in
op_memory_grow_checked— "overflow is impossible here (we pass max pages in trustless mode)" — which asserted exactly the invariant the signed compare above it fails to establish.Verification
Claims about the runtime backstops were checked against the code rather than assumed:
GlobalMemory::growuseschecked_addplus the page cap,Pages::newrejects oversized deltas,TableEntity::grow_untypeduseschecked_addplusN_MAX_TABLE_SIZE, and the bulk ops go through slice bounds checks.cargo build,cargo test --lib(75 passed), andcargo doc --no-depsall clean — the new intra-doc links resolve, and the only warning in the touched files is the pre-existing[addr]one atsrc/isa/memory.rs:41.