[PATCH v2 0/3] btrfs: add basic alignment checks for extent_state

Qu Wenruo <[email protected]> Tue, 28 Jul 2026 18:41:21 +0930
Newsgroups org.kernel.vger.linux-btrfs
Message-ID <[email protected]>
[CHANGELOG]
v2:
- Fix a crash caught by generic/136
  Since btrfs allow reflinking the last block until EOF, the range
  passed for btrfs_clone() can be unaligned.

  Fix it by passing aligned range end into btrfs_lock_extent().
  This won't affect the btrfs_clone() call as it doesn't use inclusive
  end.

- Slightly rewords the first patch
  To explain it more clearly that the fix is for btrfs_lock_extent().

Commit 3f255ece2f1e ("btrfs: introduce extra sanity checks for extent
maps") introduced sanity checks for extent maps, but for extent state we
do not have any extra sanity checks.

This series will introduce the check in the 2nd patch, meanwhile the
first one is to fix an exposed unaligned access in extent_fiemap().

Qu Wenruo (3):
  btrfs: use aligned range for locking in extent_fiemap()
  btrfs: use aligned range for locking in reflink
  btrfs: add validation for extent states

 fs/btrfs/extent-io-tree.c | 21 +++++++++++++++++++++
 fs/btrfs/fiemap.c         |  8 ++++----
 fs/btrfs/reflink.c        |  4 ++--
 3 files changed, 27 insertions(+), 6 deletions(-)

-- 
2.54.0