mirror of
https://github.com/kvcache-ai/AgentENV.git
synced 2026-11-05 01:17:36 +00:00
[PR #98] fix(overlaybd): validate index bounds before allocation #177
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#177
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/98
Author: @morluto
Created: 7/31/2026
Status: 🔄 Open
Base:
main← Head:fix/overlaybd-index-bounds📝 Commits (9)
11cb227fix(overlaybd): validate index bounds before loading12c6398test(overlaybd): cover combined index bounds9f09aaffix(overlaybd): separate trailer and index validationbf11ab0fix(overlaybd): bound index allocations97843b9fix(overlaybd): budget decoded index memoryd02f2f8fix(overlaybd): bound compact index construction0359b0efix(overlaybd): bound index allocation growth0d1b50ffix(overlaybd): bound compaction working memoryebffd4bfix(overlaybd): reject zero compaction buffers📊 Changes
6 files changed (+452 additions, -87 deletions)
View changed files
📝
storage/overlaybd/src/lsmt/file/helper.rs(+260 -52)📝
storage/overlaybd/src/lsmt/file/readonly.rs(+9 -6)📝
storage/overlaybd/src/lsmt/file/readwrite.rs(+14 -15)📝
storage/overlaybd/src/lsmt/file/stack.rs(+20 -13)📝
storage/overlaybd/src/lsmt/file/tests.rs(+147 -1)📝
storage/overlaybd/src/lsmt/file/types.rs(+2 -0)📄 Description
What
Validate OverlayBD index offsets and mapping counts against the backing file before allocating or reading an index.
The loader now:
u64until checked conversion;Why
At the affected base,
load_indexcalculatedcount * size_of::<DiskSegmentMapping>()and allocated that buffer before checking whether the trailer-described range existed in the file. A corrupted trailer could therefore drive excessive allocation or arithmetic failure before returning a malformed-layer error.Closes #97.
Scope and non-goals
This PR changes parser validation only. It does not change the OverlayBD wire format, valid layer layout, index ordering, compression, or remote backend behavior.
Design and behavior changes
For sealed data files, the valid range ends at the start of the 4 KiB trailer. For index-only writable files, it ends at the current file length.
Compatibility and operations
Validation
make fmtmake clippymake test-unitmake -C services test(required whenservices/changes)maketargetCommands and results:
The library suite is listed with one test thread because several tests share the process-global transient I/O worker; the parallel invocation can close that shared channel and cascade unrelated
channel closedfailures.Risks and reviewer notes
The main review point is
validate_index_boundsinstorage/overlaybd/src/lsmt/file/helper.rs. In particular, sealed files reserveHEADER_SIZEat the end for the trailer, while direct index-file loading intentionally validates against the full file length.Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.