fix(vfs): saturate/checked XFS extent and inode-offset arithmetic#134
Merged
Conversation
Crafted XFS on-disk fields can overflow u64 (overflow-checks ON = ring-0 halt) in the inode/extent translation helpers: - XfsExtent/XfsInodeExtent::contains: startoff + blockcount, where startoff is an unmasked 64-bit on-disk value that can sit near u64::MAX. Use saturating_add. - XfsMount::inode_offset: ag * sb_agblocks * sb_blocksize (+ local * sb_inodesize) is a three-way product of parsed inode-number and superblock-geometry values. Use checked_mul/checked_add and reject with InvalidArgument on overflow. - XfsExtentRec::last_off: startoff + blockcount - 1 underflows for an empty extent (blockcount == 0). Use saturating_sub.
kernalix7
added a commit
that referenced
this pull request
Jun 23, 2026
…hmetic (#135) Sibling sites to #134 (same parsed-byte overflow class, found by a subsystem-wide sweep): - xfs.rs read_ag_headers: i * sb_agblocks * sb_blocksize (+ sb_sectsize) is the same three-way product of parsed superblock geometry as inode_offset; a crafted superblock overflows it during mount. Saturate so an out-of-range AG offset fails the read instead of panicking. - xfs_inode.rs XfsExtent::end_offset: startoff + blockcount mirrors the contains() overflow fixed in #134. Use saturating_add.
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.
Crafted XFS on-disk fields can overflow u64 (overflow-checks ON = ring-0 halt):
XfsExtent/XfsInodeExtent::contains:startoff + blockcountwith unmasked 64-bitstartoffnear u64::MAX → saturating_add.XfsMount::inode_offset:ag * sb_agblocks * sb_blocksize (+ local * sb_inodesize)three-way product of parsed values → checked_mul/checked_add, reject InvalidArgument on overflow.XfsExtentRec::last_off:startoff + blockcount - 1underflows for an empty extent → saturating_sub.Found by an opencode/glm-5.2 agentic lane; verified + sibling-swept by hand.