Repository navigation
fix(transfer): clamp window_len to remaining file bytes in load_window - #5569
Merged
oferchen merged 2 commits intoJun 11, 2026
Merged
Conversation
This was referenced Jun 10, 2026
oferchen
added a commit
that referenced
this pull request
Jun 10, 2026
Locks coverage of the UTS-18.f / UTS-18.g panic class in `transfer::map_file::BufferedMap` closed by PR #5566 (fail-loud `copy_within` + slice guards) and PR #5569 (`window_len` clamp at the source). Future regressions in `load_window` overlap-shrink or `map_ptr` slice bounds surface as nightly fuzz-coverage findings instead of waiting on a real crash report. - New libFuzzer target `fuzz/fuzz_targets/buffered_map.rs` drives both panic sites through the public `MapStrategy::map_ptr` entry. Six u64 LE words at the head of each input parametrize `(file_size, window_size, request_start/len, second_start/len)`; remaining bytes tile the synthetic basis file. Two `map_ptr` calls per input cover the empty-cache load path and the forward-overlap branch of `load_window`. - Three deterministic corpus seeds under `fuzz/corpus/buffered_map/`: `uts_18_overlap_shrink.bin` mirrors the production crash math (file=48128, MAX_MAP_SIZE=262144); `uts_18_truncated.bin` covers the 48-byte header boundary; `uts_18_zero_len.bin` covers the `len == 0` short-circuit. - `buffered_map` wired into `.github/workflows/fuzz-coverage-report.yml` matrix so the nightly run uploads lcov for the new target. - Audit note at `docs/audits/edg-panic-4-buffered-fuzz.md`.
4 tasks
oferchen
merged commit Jun 11, 2026
c2e178b
into
fix/uts-18-buffered-bounds-fail-loud
70 checks passed
2 tasks
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…loss PR #5569 review flagged a data-loss path in `BufferedMap::load_window`: `Vec::resize(window_size, 0)` truncates the buffer when a smaller window is requested. Under the overlap-shrink branch (new window near EOF after a full-size load), the bytes the overlap branch is about to relocate via `copy_within` are dropped before the copy runs, leading to either an out-of-bounds panic on the source range or silent corruption of the reused suffix once PR #5566's guard converts the panic to InvalidData. Upstream `fileio.c:236` `realloc_array` only grows the backing buffer. Mirror that invariant by replacing `buffer.resize(window_size, 0)` with `buffer.resize(window_size.max(buffer.len()), 0)`. The buffer becomes monotonically non-decreasing (capped at MAX_MAP_SIZE peak); `window_len` continues to bound the valid region so callers never see stale tail bytes. Picked the never-shrink fix over file-boundary-only shrink or shrink-and-reload because it is the smallest delta, matches upstream exactly, and has negligible memory cost in practice.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
Locks coverage of the UTS-18.f / UTS-18.g panic class in `transfer::map_file::BufferedMap` closed by PR #5566 (fail-loud `copy_within` + slice guards) and PR #5569 (`window_len` clamp at the source). Future regressions in `load_window` overlap-shrink or `map_ptr` slice bounds surface as nightly fuzz-coverage findings instead of waiting on a real crash report. - New libFuzzer target `fuzz/fuzz_targets/buffered_map.rs` drives both panic sites through the public `MapStrategy::map_ptr` entry. Six u64 LE words at the head of each input parametrize `(file_size, window_size, request_start/len, second_start/len)`; remaining bytes tile the synthetic basis file. Two `map_ptr` calls per input cover the empty-cache load path and the forward-overlap branch of `load_window`. - Three deterministic corpus seeds under `fuzz/corpus/buffered_map/`: `uts_18_overlap_shrink.bin` mirrors the production crash math (file=48128, MAX_MAP_SIZE=262144); `uts_18_truncated.bin` covers the 48-byte header boundary; `uts_18_zero_len.bin` covers the `len == 0` short-circuit. - `buffered_map` wired into `.github/workflows/fuzz-coverage-report.yml` matrix so the nightly run uploads lcov for the new target. - Audit note at `docs/audits/edg-panic-4-buffered-fuzz.md`.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
UTS-18.j: extend URV-1 attestation with the basis-window panic chain discovered after the original codec-only audit cleared the file. Document the three follow-on regressions (window_len overstatement, buffer.resize overlap-shrink, bare slice index on misaligned chunk requests) and the remediation PRs (#5566, #5569, #5588, #5590, #5627). UTS-18.i: keep `compress-zlib-insert` out of the upstream-testsuite known-failures list so the workflow's wildcard run surfaces any regression as an UNEXPECTED FAIL. The cell already iterates `$suitedir/*.test`, so explicit wiring is the explanatory comment in `tools/ci/upstream_testsuite_known_failures.conf` plus the attestation-doc cross-reference.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
BufferedMap(copy_withininload_window, slice indexing inmap_ptr) so a malformed zlib delta turnsSIGABRTintoInvalidData. Those guards stop the abort but reject legitimate transfers whose cached window state is internally consistent yet pessimistically rejected by the bounds check.window_lenassignment site.load_windownow recordswindow_len = window_size.min(file_size - window_start), making the invariant "window_len <= buffer.len()andwindow_len <= file_size - window_start" locally provable at the source. All four untrusted callers (transfer_ops/token_loop.rs:179,transfer_ops/response.rs:254,receiver/transfer/sync.rs:572,delta_apply/applicator.rs:358) inherit the fix because they share the same load path.MAX_MAP_SIZE = 262144(the production crash ratio) now completes successfully end-to-end:window_lenclamps to 48128 instead of inheriting the requested max, and the subsequent full-filemap_ptrreturnsOkwith all 48128 bytes - not the "exceeds buffer length"ErrPR fix(transfer): turn buffered map_file out-of-range panic into Err #5566's guard would otherwise surface.Test plan
load_window_clamps_window_len_to_remaining_file_bytesmirrors the production crash math (file=48128 bytes,MAX_MAP_SIZE=262144):map_ptr(0, 48128)(the public entry shared by all four untrusted callers).window_len == 48128(the file size), not 262144.window_len <= buffer.len()(the load-path invariant).map_ptrhits the cached window and returns the same bytes.map_ptr_slice_out_of_range_returns_err_not_panic,load_window_overlap_shrink_returns_err_not_panic) continue to pass: this PR does not relax the fail-loud guards, it only widens the legitimate-input path that reaches them.cargo fmt --all -- --check(verified by CI fmt+clippy gate).cargo clippy --workspace --all-targets --all-features --no-deps -- -D warnings(verified by CI).cargo nextest run -p transfer --all-featurescoversmap_file::buffered::tests(verified by CI nextest matrix).