Repository navigation
fix(ecstore): bound compressed GetObject range reads - #9639
Conversation
Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com>
|
CLA requirements are satisfied for this pull request. |
Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com>
Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com>
Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com>
overtrue
left a comment
There was a problem hiding this comment.
Reviewed 854dd7d1eaad...420e022e1f4b (high risk tier; two-perspective review covering correctness, security, compatibility, concurrency/cancellation, and performance).
Findings
No findings.
Lens Verdicts
- Correctness:
compressed_storage_windowcomputes stored block windows strictly within validatedpart.sizeandpart.actual_sizebounds usingcheckpoint_at_or_before/checkpoint_at_or_after, falling back cleanly to(0, oi.size, req_off)on missing/invalid indexes or mismatched part bounds. Bothrustfs_rio::DecompressReaderandrustfs_rio_v2::DecompressReader(S2Decoder) terminate cleanly at block/chunk boundaries, andRangedDecompressReadernow fails closed withUnexpectedEofon premature stream truncation while preserving whole-objectHardLimitReader+StreamConsumerchecks. - Security: Checked arithmetic guards offset and prediction decoding against signed overflow in both
crates/rio/src/compress_index.rsandcrates/rio-v2/src/s2_index.rs,read_uvarintrejectsidx == 9 && byte > 1before any shift overflow, and trailing bytes are rejected in both legacy and S2 index decoders. - Compatibility: Legacy framed (
0x50) indexes, framed S2 (0x99) indexes, headerless S2 indexes, multipart ranges across part boundaries, and encrypted+compressed DARE offsets (get_encrypted_compressed_offsets) are preserved and covered by regression tests. - Concurrency & Performance:
SkipReaderyields cooperatively viatokio::task::coop::poll_proceedduring large unindexed skips,RangedDecompressReaderstreams directly into caller buffers without an 8 KiB intermediate copy and drops the source immediately on range completion (unlessnew_drainingis requested), and headerless S2 decoding borrows the payload without allocating a reframed buffer.
Verification & Check State
- Fresh CI on rebased head
420e022e1f4bis currently running (CLA Checkpassed;Quick ChecksandTest and Lintpending). Not merged yet because branch protection requires greenQuick ChecksandTest and Lint.
Verdict: Approve (ready for merge queue once CI completes).
Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com>
overtrue
left a comment
There was a problem hiding this comment.
Reviewed 854dd7d1eaad...edb2689f801a (high risk tier; re-reviewed delta 420e022e1f4b..edb2689f801a reusing unaffected evidence from the prior pass).
Findings
No findings.
Delta Review (edb2689f801a)
rustfs_utils::compress::decompress_block_intoclearsouton entry and again on error so unverified bytes never survive a failed decode while preserving buffer capacity for reuse;decompress_block_with_limitdelegates to it with unchanged semantics.rustfs_rio::DecompressReaderdelegates block verification todecode_block, validating the varint prefix,MAX_BLOCK_PLAINTEXT_LEN, non-empty length match, and CRC32 before exposing decoded plaintext (and before copying uncompressed blocks intooutput), clearingthis.bufferand settingthis.poisoned = trueon any error.- Unit tests verify buffer reuse across equal-sized blocks, sticky poisoning on bad CRC, and clearing
outon over-limit errors across codecs.
Verification & Check State
- Fresh CI on
edb2689f801ais currently running (CLA Checkpassed;Quick ChecksandTest and Lintpending). Will merge once CI is green.
Verdict: Approve.
Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com>
overtrue
left a comment
There was a problem hiding this comment.
Reviewed 854dd7d1eaad...a9d9a75edf3b (high risk tier; re-reviewed delta edb2689f801a..a9d9a75edf3b reusing unaffected evidence from the prior passes).
Findings
No findings.
Delta Review (a9d9a75edf3b)
rustfs/src/server/ssec_transport.rsreplaces.collect()plus.len()with.count()inpost_object_ssec_without_tls_increments_metric_and_warns_onceto resolve theclippy::needless_collectlint onmainwithout changing test semantics. Note that this 2-line test change overlaps with PR #9648 and PR #9637.
Verification & Check State
- Fresh CI on
a9d9a75edf3bis currently running (CLA Checkpassed;Quick ChecksandTest and Lintpending). Will merge once CI is green.
Verdict: Approve.
Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com>
Co-Authored-By: heihutu <heihutu@gmail.com> Co-Authored-By: zhi22915 <qiuzgang@gmail.com> Co-Authored-By: qunjiazhu <qunjiazhu@gmail.com>
overtrue
left a comment
There was a problem hiding this comment.
Re-reviewing 6ae3dadab3542f2bcc0bfdd5048972ff557e9e6d after merging main (4b0d6736d6f6): No findings.
Verification Summary
- The net diff against
mainretains the previously reviewed compressed range-read changes cleanly, and the test update inrustfs/src/admin/handlers/account_permissions.rsstrengthens IAM explicit-deny vs bucket-grant coverage without weakening any assertions.
Related Issues
Fixes #9582. Follow-up is tracked in rustfs/backlog#3372.
Summary of Changes
A legacy compression index could select a checkpoint after a valid early offset when it had more than 200 entries. Its reported total could also stop before the actual part end, causing some tail requests to scan from the start of a large part.
Plan unencrypted compressed ranges in logical bytes and read only the stored blocks between usable checkpoints or part boundaries. Encrypted and unencrypted compressed reads use the same response reader. It discards the remaining prefix in bounded, cooperatively scheduled chunks, streams the requested bytes into the caller buffer, and releases the source as soon as the range completes. Whole-object reads retain their strict length, checksum, and producer completion checks. Complete legacy index frames go directly to the legacy decoder. Framed and headerless S2 indexes share one payload decoder over borrowed bytes, avoiding reconstruction of a byte buffer for each headerless index. The legacy block decoder reuses its plaintext buffer across blocks. It applies the bounded codec and verifies decoded lengths and CRC before delivering bytes.
Verification
62026aa83d, pushed identically asedb2689f80),cargo test --locked --offline -p rustfs-ecstore --lib object_api::readerspassed 76 tests, and the same selection with--features rio-v2,test-utilpassed 82. The affected Rio and Utils compression selectors passed 17 and 13 tests. Producer terminal and cancellation selectors passed 10 and 14 tests, and the three transitioned-compression and restore tests passed. Strict package Clippy, workspace formatting, the logging guard, the error ratchet andgit diff --checkpassed.381a56f2fbreproduced both reported HTTP 416s against official 1.0.6 and verified 22 byte-exact HTTP 206 responses and one expected 416 on the fix. The latest merged tree has fresh Rio and ECStore integration evidence. End-to-end throughput and tail latency were not remeasured.auto-testing regression coverage STOR-136 merged in rustfs/auto-testing#170, covering real status, response headers, byte content, and bounded reads on one disk.
Impact
Valid compressed ranges use bounded storage reads when their indexes allow it. The CPU path skips without depending on the size of the response buffer and avoids an intermediate copy of returned bytes. Existing stored formats are supported. If an index is missing or invalid, the covering part can still be read sequentially.
Additional Notes
Reviewed logical range and storage coordinates, historical index compatibility, codec and AEAD verification, producer cancellation, short reads, and tier fetching. The physical read window and codec validation rules are preserved by the reader refactor. The operation-count comparison measures reader work on a controlled source.