mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #430] [MERGED] fix(overlaybd): bound layer index ranges by file size #432
Labels
No labels
bug
documentation
enhancement
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
kvcache-ai/AgentENV#432
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/kvcache-ai/AgentENV/pull/430
Author: @yingdi-shan
Created: 10/23/2026
Status: ✅ Merged
Merged: 10/26/2026
Merged by: @yingdi-shan
Base:
main← Head:fix/overlaybd-index-bounds📝 Commits (1)
d57b28bfix(overlaybd): bound layer index ranges by file size📊 Changes
3 files changed (+128 additions, -6 deletions)
View changed files
📝
storage/overlaybd/src/compression/zfile.rs(+86 -5)📝
storage/overlaybd/src/lsmt/file/helper.rs(+10 -1)📝
storage/overlaybd/src/lsmt/file/tests.rs(+32 -0)📄 Description
What
Harden index loading for sealed OverlayBD layers:
lsmt/file/helper.rsload_index: compute the index byte count withchecked_muland requireindex_offset + index_bytes <= file_sizebefore allocating the index buffer. This covers every caller (LSMTReadOnlyFile::open,open_files_rostacking,open_file_index, and the RW index reload).compression/zfile.rsload_jump_table: apply the sameindex_offset/index_bytesbound in the overwrite-header branch that the trailer branch already applies.compression/zfile.rsread_exact_chunks_at: usetry_collect, so the parallel chunk read stops at the first failed chunk instead of driving every remaining chunk to completion.Why
Both parsers trust the index size recorded in the layer's header or trailer and size allocations and reads from it, without checking it against the actual file length. A malformed layer should be rejected with an error at open time rather than consuming unbounded memory or CPU in the storage daemon.
Related issue
N/A (reported privately)
Scope and non-goals
CALC_DIGESTremains optional, matching upstream OverlayBD).Design and behavior changes
index range exceeds file size,index size overflow, orinvalid index_offset beyond file end/invalid index bytes.load_indexmakes one extrasize()call per open. This is not on the write hot path; the existing size-call hot-path tests still pass.Compatibility and operations
Validation
make fmtmake clippymake test-unitmake -C services test(required whenservices/changes)maketargetCommands and results:
New tests:
lsmt::file::tests::test_readonly_open_rejects_index_outside_filecompression::zfile::tests::test_overwrite_header_rejects_index_outside_file(includes a positive control on an unmodified overwrite-header zfile)compression::zfile::tests::test_read_exact_chunks_at_stops_after_first_errorThe LSMT and chunk-reader tests were confirmed to fail with the source changes reverted.
Skipped checks and reasons:
make test-unit/make test-ublk: require privileged ublk/KVM setup. The change is confined to theoverlaybdcrate, whose full test suite was run.services/, codegen, and docs: not touched.Risks and reviewer notes
storage/overlaybd/src/lsmt/file/helper.rs(load_index) andstorage/overlaybd/src/compression/zfile.rs(load_jump_table,read_exact_chunks_at).Checklist
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.