fix(fuse): reject overflowing write endpoints (#1393) - #1457
Open
RPG-Nia wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a potential integer overflow in the FUSE write path by ensuring the write endpoint (offset + data.len()) is computed with checked arithmetic and rejected early if it overflows, preventing corrupted cached file length updates and ensuring the error maps to EFBIG via FsError::InvalidFileSize.
Changes:
- Added
FuseWriter::checked_write_end(off, len)to computeoff + lensafely and returnFsError::InvalidFileSizeon overflow. - Validated write endpoints in
FuseWriter::write()before enqueueing, and reused the checked endpoint when updating cachedfile_len. - Added regression tests covering maximum valid endpoint, overflow rejection (
EFBIG), and ensuring rejected writes do not mutatewrite_veror cached length.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes overflowing FUSE write endpoint handling.
Issue Describe / Design
Closes #1393
Root cause:
FuseWriterdid not validateoffset + data.len()before enqueueing a write task.i64::MAX.Fix approach:
FuseWriter.EFBIGthrough the existingFsError::InvalidFileSizeto FUSE errno mapping.Changes
curvine-fuse/src/fs/fuse_writer.rsoffset + data.len()before enqueueing writes.curvine-fuse/src/fs/fuse_writer.rscurvine-fuse/src/fs/fuse_writer.rsEFBIGmapping and verifies rejected writes do not changewrite_veror cached file length.Test verified
cargo fmt --checkandgit diff --checksuccessfully.cargo test --offline -p curvine-fuse checked_write_end -- --nocapturesuccessfully.cargo test --offline -p curvine-fuse overflowing_write_endpoint_is_rejected_before_enqueue -- --nocapturesuccessfully.cargo test --offline -p curvine-fuse fuse_writer -- --nocapturesuccessfully.Dependencies