[PR #43] [MERGED] fix(overlaybd): reject truncated mapped reads #135

Closed
opened 2026-10-29 14:20:04 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/kvcache-ai/AgentENV/pull/43
Author: @morluto
Created: 7/28/2026
Status: ✅ Merged
Merged: 7/30/2026
Merged by: @huajq

Base: main ← Head: fix/overlaybd-truncated-mapped-reads


📝 Commits (2)

  • def3fbc fix(overlaybd): reject truncated mapped reads
  • c8c5317 fix(overlaybd): verify short-read retry offsets

📊 Changes

3 files changed (+91 additions, -36 deletions)

View changed files

📝 storage/overlaybd/src/lsmt/file/readonly.rs (+8 -11)
📝 storage/overlaybd/src/lsmt/file/readwrite.rs (+10 -11)
📝 storage/overlaybd/src/lsmt/file/tests.rs (+73 -14)

📄 Description

Problem

Mapped LSMT reads currently zero-fill the remainder of the destination buffer when a backing layer returns fewer bytes than requested. A truncated mapped extent can therefore be returned as apparently valid filesystem or VM-memory data.

Explicit holes and zero mappings are handled separately and should continue to produce zeros.

mapping lookup
  +-- hole / zero mapping ------------> fill with zeros
  |
  `-- mapped extent
          |
          v
      read remaining bytes <----------+
          |                           |
          +-- bytes, range incomplete +
          +-- range complete --------> return data
          `-- early EOF -------------> return error

Changes

  • Use the existing exact-read helper for mapped physical reads in both readonly and readwrite LSMT files.
  • Retry legal partial reads until the requested mapped range is filled.
  • Return unexpected EOF when the backing extent ends early.
  • Preserve zero-filling for explicit holes and zero mappings.

Validation

  • Added regression coverage for legal short-read retries and premature EOF in both readonly and writable LSMT stacks.
  • Against the previous implementation, the retry test observed a zero-filled tail and the truncation test incorrectly succeeded.
  • cargo test -p overlaybd --lib — 303 passed, 1 ignored.
  • cargo clippy -p overlaybd --all-targets -- -D warnings
  • cargo fmt --all

Closes #40.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/kvcache-ai/AgentENV/pull/43 **Author:** [@morluto](https://github.com/morluto) **Created:** 7/28/2026 **Status:** ✅ Merged **Merged:** 7/30/2026 **Merged by:** [@huajq](https://github.com/huajq) **Base:** `main` ← **Head:** `fix/overlaybd-truncated-mapped-reads` --- ### 📝 Commits (2) - [`def3fbc`](https://github.com/kvcache-ai/AgentENV/commit/def3fbc72057b08b3e630fb597195c6ec9329465) fix(overlaybd): reject truncated mapped reads - [`c8c5317`](https://github.com/kvcache-ai/AgentENV/commit/c8c53170f3e04678e0732b391c897d083ed66242) fix(overlaybd): verify short-read retry offsets ### 📊 Changes **3 files changed** (+91 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `storage/overlaybd/src/lsmt/file/readonly.rs` (+8 -11) 📝 `storage/overlaybd/src/lsmt/file/readwrite.rs` (+10 -11) 📝 `storage/overlaybd/src/lsmt/file/tests.rs` (+73 -14) </details> ### 📄 Description ## Problem Mapped LSMT reads currently zero-fill the remainder of the destination buffer when a backing layer returns fewer bytes than requested. A truncated mapped extent can therefore be returned as apparently valid filesystem or VM-memory data. Explicit holes and zero mappings are handled separately and should continue to produce zeros. ```text mapping lookup +-- hole / zero mapping ------------> fill with zeros | `-- mapped extent | v read remaining bytes <----------+ | | +-- bytes, range incomplete + +-- range complete --------> return data `-- early EOF -------------> return error ``` ## Changes - Use the existing exact-read helper for mapped physical reads in both readonly and readwrite LSMT files. - Retry legal partial reads until the requested mapped range is filled. - Return `unexpected EOF` when the backing extent ends early. - Preserve zero-filling for explicit holes and zero mappings. ## Validation - Added regression coverage for legal short-read retries and premature EOF in both readonly and writable LSMT stacks. - Against the previous implementation, the retry test observed a zero-filled tail and the truncation test incorrectly succeeded. - `cargo test -p overlaybd --lib` — 303 passed, 1 ignored. - `cargo clippy -p overlaybd --all-targets -- -D warnings` - `cargo fmt --all` Closes #40. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-29 14:20:04 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kvcache-ai/AgentENV#135
No description provided.