public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCHSET 2/3] xfs: fix problems in the attr leaf freemap code
@ 2026-01-21  6:34 Darrick J. Wong
  2026-01-21  6:37 ` [PATCH 1/6] xfs: delete attr leaf freemap entries when empty Darrick J. Wong
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Darrick J. Wong @ 2026-01-21  6:34 UTC (permalink / raw)
  To: djwong, cem; +Cc: stable, linux-xfs

Hi all,

Running generic/753 for hours revealed data corruption problems in the
attr leaf block space management code.  Under certain circumstances,
freemap entries are left with zero size but a nonzero offset.  If that
offset happens to be the same offset as the end of the entries array
during an attr set operation, the leaf entry table expansion will push
the freemap record offset upwards without checking for overlap with any
other freemap entries.  If there happened to be a second freemap entry
overlapping with the newly allocated leaf entry space, then the next
attr set operation might find that space and overwrite the leaf entry,
thereby corrupting the leaf block.

Fix this by zeroing the freemap offset any time we set the size to zero.
If a subsequent attr set operation finds no space in the freemap, it
will compact the block and regenerate the freemaps.

If you're going to start using this code, I strongly recommend pulling
from my git trees, which are linked below.

With a bit of luck, this should all go splendidly.
Comments and questions are, as always, welcome.

--D

kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=attr-leaf-freemap-fixes

xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=attr-leaf-freemap-fixes
---
Commits in this patchset:
 * xfs: delete attr leaf freemap entries when empty
 * xfs: fix freemap adjustments when adding xattrs to leaf blocks
 * xfs: refactor attr3 leaf table size computation
 * xfs: strengthen attr leaf block freemap checking
 * xfs: fix the xattr scrub to detect freemap/entries array collisions
 * xfs: fix remote xattr valuelblk check
---
 fs/xfs/libxfs/xfs_da_format.h |    2 -
 fs/xfs/libxfs/xfs_attr_leaf.c |  157 ++++++++++++++++++++++++++++++++---------
 fs/xfs/scrub/attr.c           |   59 ++++++++-------
 3 files changed, 155 insertions(+), 63 deletions(-)


^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCHSET 1/3] xfs: fix problems in the attr leaf freemap code
@ 2026-01-23  7:00 Darrick J. Wong
  2026-01-23  7:02 ` [PATCH 5/6] xfs: fix the xattr scrub to detect freemap/entries array collisions Darrick J. Wong
  0 siblings, 1 reply; 10+ messages in thread
From: Darrick J. Wong @ 2026-01-23  7:00 UTC (permalink / raw)
  To: djwong, cem; +Cc: hch, stable, linux-xfs

Hi all,

Running generic/753 for hours revealed data corruption problems in the
attr leaf block space management code.  Under certain circumstances,
freemap entries are left with zero size but a nonzero offset.  If that
offset happens to be the same offset as the end of the entries array
during an attr set operation, the leaf entry table expansion will push
the freemap record offset upwards without checking for overlap with any
other freemap entries.  If there happened to be a second freemap entry
overlapping with the newly allocated leaf entry space, then the next
attr set operation might find that space and overwrite the leaf entry,
thereby corrupting the leaf block.

Fix this by zeroing the freemap offset any time we set the size to zero.
If a subsequent attr set operation finds no space in the freemap, it
will compact the block and regenerate the freemaps.

If you're going to start using this code, I strongly recommend pulling
from my git trees, which are linked below.

With a bit of luck, this should all go splendidly.
Comments and questions are, as always, welcome.

--D

kernel git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfs-linux.git/log/?h=attr-leaf-freemap-fixes

xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=attr-leaf-freemap-fixes
---
Commits in this patchset:
 * xfs: delete attr leaf freemap entries when empty
 * xfs: fix freemap adjustments when adding xattrs to leaf blocks
 * xfs: refactor attr3 leaf table size computation
 * xfs: strengthen attr leaf block freemap checking
 * xfs: fix the xattr scrub to detect freemap/entries array collisions
 * xfs: fix remote xattr valuelblk check
---
 fs/xfs/libxfs/xfs_da_format.h |    2 -
 fs/xfs/libxfs/xfs_attr_leaf.c |  157 ++++++++++++++++++++++++++++++++---------
 fs/xfs/scrub/attr.c           |   59 ++++++++-------
 3 files changed, 155 insertions(+), 63 deletions(-)


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-01-23  7:02 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-21  6:34 [PATCHSET 2/3] xfs: fix problems in the attr leaf freemap code Darrick J. Wong
2026-01-21  6:37 ` [PATCH 1/6] xfs: delete attr leaf freemap entries when empty Darrick J. Wong
2026-01-21 15:05   ` Christoph Hellwig
2026-01-21  6:38 ` [PATCH 2/6] xfs: fix freemap adjustments when adding xattrs to leaf blocks Darrick J. Wong
2026-01-21 15:06   ` Christoph Hellwig
2026-01-21  6:38 ` [PATCH 5/6] xfs: fix the xattr scrub to detect freemap/entries array collisions Darrick J. Wong
2026-01-21 15:08   ` Christoph Hellwig
2026-01-21  6:39 ` [PATCH 6/6] xfs: fix remote xattr valuelblk check Darrick J. Wong
2026-01-21 15:08   ` Christoph Hellwig
  -- strict thread matches above, loose matches on Subject: below --
2026-01-23  7:00 [PATCHSET 1/3] xfs: fix problems in the attr leaf freemap code Darrick J. Wong
2026-01-23  7:02 ` [PATCH 5/6] xfs: fix the xattr scrub to detect freemap/entries array collisions Darrick J. Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox