Skip to content

fix(vfs): saturate/checked XFS extent and inode-offset arithmetic#134

Merged
kernalix7 merged 1 commit into
mainfrom
fix/xfs-extent-inode-arith
Jun 23, 2026
Merged

fix(vfs): saturate/checked XFS extent and inode-offset arithmetic#134
kernalix7 merged 1 commit into
mainfrom
fix/xfs-extent-inode-arith

Conversation

@kernalix7

Copy link
Copy Markdown
Owner

Crafted XFS on-disk fields can overflow u64 (overflow-checks ON = ring-0 halt):

  • XfsExtent/XfsInodeExtent::contains: startoff + blockcount with unmasked 64-bit startoff near 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 - 1 underflows for an empty extent → saturating_sub.

Found by an opencode/glm-5.2 agentic lane; verified + sibling-swept by hand.

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 kernalix7 merged commit 966c019 into main Jun 23, 2026
2 checks passed
@kernalix7 kernalix7 deleted the fix/xfs-extent-inode-arith branch June 23, 2026 02:41
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.
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.

1 participant