Skip to content

fix: correctly check bounds on read_at#22

Merged
blinsay merged 1 commit into
mainfrom
benl/read-at
Nov 14, 2025
Merged

fix: correctly check bounds on read_at#22
blinsay merged 1 commit into
mainfrom
benl/read-at

Conversation

@blinsay
Copy link
Copy Markdown
Member

@blinsay blinsay commented Nov 14, 2025

We're incorrectly checking bounds on read_at calls. The kernel happens to be calling us correctly through FUSE but nothing was actually stopping us from reading beyond the bounds of a file.

The bug is a one-line fix: actually take into account the read offset when calculating read length:

-                let read_len = std::cmp::min(range.len, buf.len() as u64);
+                let read_len = std::cmp::min(range.len.saturating_sub(offset), buf.len() as u64);

The problem was masked by object store implementations happily returning partial ranges and the kernel doing bookeeping correctly. All of our fuzz tests at the moment are mediated through the kernel's FUSE driver, so they didn't turn this up.

I added a simple test for this that would have caught the original bug with an out-of-bounds. It might be worth adding a direct volume fuzz just for this.

@blinsay blinsay merged commit f00f8c1 into main Nov 14, 2025
4 checks passed
@blinsay blinsay deleted the benl/read-at branch November 14, 2025 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants