From: Siddh Raman Pant <siddh.raman.pant@oracle.com>
To: stable@vger.kernel.org, Greg KH <gregkh@linuxfoundation.org>,
"Darrick J . Wong" <djwong@kernel.org>,
Dave Chinner <dchinner@redhat.com>
Cc: linux-kernel@vger.kernel.org, Mark Tinguely <mark.tinguely@oracle.com>
Subject: [PATCH 5.10 01/21] xfs: hoist recovered bmap intent checks out of xfs_bui_item_recover
Date: Thu, 1 Oct 2026 20:21:14 +0530 [thread overview]
Message-ID: <feeddf89debe273a2c9c0ca88980a65af0cc0053.1790866131.git.siddh.raman.pant@oracle.com> (raw)
In-Reply-To: <cover.1790866131.git.siddh.raman.pant@oracle.com>
From: "Darrick J. Wong" <darrick.wong@oracle.com>
When we recover a bmap intent from the log, we need to validate its
contents before we try to replay them. Hoist the checking code into a
separate function in preparation to refactor this code to use validation
helpers.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
(cherry picked from commit bc525cf455dac810d28f9edd379805dc249bc5a9)
Stable-dep-of: 7b5f775be14a ("xfs: fix unmount hang with unflushable inodes stuck in the AIL")
Signed-off-by: Siddh Raman Pant <siddh.raman.pant@oracle.com>
---
fs/xfs/xfs_bmap_item.c | 74 +++++++++++++++++++++++++++---------------
1 file changed, 47 insertions(+), 27 deletions(-)
diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index a3b350437db2..88d28a862f52 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -418,6 +418,49 @@ const struct xfs_defer_op_type xfs_bmap_update_defer_type = {
.cancel_item = xfs_bmap_update_cancel_item,
};
+/* Is this recovered BUI ok? */
+static inline bool
+xfs_bui_validate(
+ struct xfs_mount *mp,
+ struct xfs_bui_log_item *buip)
+{
+ struct xfs_map_extent *bmap;
+ xfs_fsblock_t startblock_fsb;
+ xfs_fsblock_t inode_fsb;
+
+ /* Only one mapping operation per BUI... */
+ if (buip->bui_format.bui_nextents != XFS_BUI_MAX_FAST_EXTENTS)
+ return false;
+
+ bmap = &buip->bui_format.bui_extents[0];
+ startblock_fsb = XFS_BB_TO_FSB(mp,
+ XFS_FSB_TO_DADDR(mp, bmap->me_startblock));
+ inode_fsb = XFS_BB_TO_FSB(mp, XFS_FSB_TO_DADDR(mp,
+ XFS_INO_TO_FSB(mp, bmap->me_owner)));
+
+ if (bmap->me_flags & ~XFS_BMAP_EXTENT_FLAGS)
+ return false;
+
+ switch (bmap->me_flags & XFS_BMAP_EXTENT_TYPE_MASK) {
+ case XFS_BMAP_MAP:
+ case XFS_BMAP_UNMAP:
+ break;
+ default:
+ return false;
+ }
+
+ if (startblock_fsb == 0 ||
+ bmap->me_len == 0 ||
+ inode_fsb == 0 ||
+ startblock_fsb >= mp->m_sb.sb_dblocks ||
+ bmap->me_len >= mp->m_sb.sb_agblocks ||
+ inode_fsb >= mp->m_sb.sb_dblocks ||
+ (bmap->me_flags & ~XFS_BMAP_EXTENT_FLAGS))
+ return false;
+
+ return true;
+}
+
/*
* Process a bmap update intent item that was recovered from the log.
* We need to update some inode's bmbt.
@@ -434,47 +477,24 @@ xfs_bui_item_recover(
struct xfs_mount *mp = lip->li_mountp;
struct xfs_map_extent *bmap;
struct xfs_bud_log_item *budp;
- xfs_fsblock_t startblock_fsb;
- xfs_fsblock_t inode_fsb;
xfs_filblks_t count;
xfs_exntst_t state;
unsigned int bui_type;
int whichfork;
int error = 0;
- /* Only one mapping operation per BUI... */
- if (buip->bui_format.bui_nextents != XFS_BUI_MAX_FAST_EXTENTS)
+ if (!xfs_bui_validate(mp, buip)) {
+ XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
+ &buip->bui_format, sizeof(buip->bui_format));
return -EFSCORRUPTED;
+ }
- /*
- * First check the validity of the extent described by the
- * BUI. If anything is bad, then toss the BUI.
- */
bmap = &buip->bui_format.bui_extents[0];
- startblock_fsb = XFS_BB_TO_FSB(mp,
- XFS_FSB_TO_DADDR(mp, bmap->me_startblock));
- inode_fsb = XFS_BB_TO_FSB(mp, XFS_FSB_TO_DADDR(mp,
- XFS_INO_TO_FSB(mp, bmap->me_owner)));
state = (bmap->me_flags & XFS_BMAP_EXTENT_UNWRITTEN) ?
XFS_EXT_UNWRITTEN : XFS_EXT_NORM;
whichfork = (bmap->me_flags & XFS_BMAP_EXTENT_ATTR_FORK) ?
XFS_ATTR_FORK : XFS_DATA_FORK;
bui_type = bmap->me_flags & XFS_BMAP_EXTENT_TYPE_MASK;
- switch (bui_type) {
- case XFS_BMAP_MAP:
- case XFS_BMAP_UNMAP:
- break;
- default:
- return -EFSCORRUPTED;
- }
- if (startblock_fsb == 0 ||
- bmap->me_len == 0 ||
- inode_fsb == 0 ||
- startblock_fsb >= mp->m_sb.sb_dblocks ||
- bmap->me_len >= mp->m_sb.sb_agblocks ||
- inode_fsb >= mp->m_sb.sb_dblocks ||
- (bmap->me_flags & ~XFS_BMAP_EXTENT_FLAGS))
- return -EFSCORRUPTED;
/* Grab the inode. */
error = xfs_iget(mp, NULL, bmap->me_owner, 0, 0, &ip);
--
2.53.0
next prev parent reply other threads:[~2026-10-01 14:52 UTC|newest]
Thread overview: 107+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2026090954-revisit-dowry-37ee@gregkh>
2026-10-01 14:50 ` [PATCH 6.12 0/6] Backport of XFS umount hang fixes Siddh Raman Pant
2026-10-01 14:50 ` [PATCH 6.12 1/6] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-01 14:50 ` [PATCH 6.12 2/6] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-01 14:50 ` [PATCH 6.12 3/6] xfs: avoid dquot buffer pin deadlock Siddh Raman Pant
2026-10-01 14:50 ` [PATCH 6.12 4/6] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-01 14:50 ` [PATCH 6.12 5/6] xfs: factor out stale buffer item completion Siddh Raman Pant
2026-10-01 14:50 ` [PATCH 6.12 6/6] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant
2026-10-02 14:19 ` [PATCH 6.12 0/6] Backport of XFS umount hang fixes Sasha Levin
2026-10-13 8:12 ` [PATCH 6.12 v2 " Siddh Raman Pant
2026-10-13 8:12 ` [PATCH 6.12 v2 1/6] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-13 8:12 ` [PATCH 6.12 v2 2/6] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-13 8:12 ` [PATCH 6.12 v2 3/6] xfs: avoid dquot buffer pin deadlock Siddh Raman Pant
2026-10-13 8:12 ` [PATCH 6.12 v2 4/6] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-13 8:12 ` [PATCH 6.12 v2 5/6] xfs: factor out stale buffer item completion Siddh Raman Pant
2026-10-13 8:12 ` [PATCH 6.12 v2 6/6] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant
2026-10-13 8:13 ` [PATCH 6.6 v2 0/5] Backport of XFS umount hang fixes Siddh Raman Pant
2026-10-13 8:13 ` [PATCH 6.6 v2 1/5] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-13 8:13 ` [PATCH 6.6 v2 2/5] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-13 8:13 ` [PATCH 6.6 v2 3/5] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-13 8:13 ` [PATCH 6.6 v2 4/5] xfs: factor out stale buffer item completion Siddh Raman Pant
2026-10-13 8:13 ` [PATCH 6.6 v2 5/5] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant
2026-10-13 8:13 ` [PATCH 6.1 v2 0/5] Backport of XFS umount hang fixes Siddh Raman Pant
2026-10-13 8:13 ` [PATCH 6.1 v2 1/5] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-13 8:13 ` [PATCH 6.1 v2 2/5] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-13 8:13 ` [PATCH 6.1 v2 3/5] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-13 8:13 ` [PATCH 6.1 v2 4/5] xfs: factor out stale buffer item completion Siddh Raman Pant
2026-10-13 8:13 ` [PATCH 6.1 v2 5/5] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.15 v2 0/9] Backport of XFS umount hang fixes Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.15 v2 1/9] xfs: log items should have a xlog pointer, not a mount Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.15 v2 2/9] xfs: aborting inodes on shutdown may need buffer lock Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.15 v2 3/9] xfs: fix super block buf log item UAF during force shutdown Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.15 v2 4/9] xfs: buffer pins need to hold a buffer reference Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.15 v2 5/9] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.15 v2 6/9] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.15 v2 7/9] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.15 v2 8/9] xfs: factor out stale buffer item completion Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.15 v2 9/9] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 00/19] Backport of XFS umount hang fixes Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 01/19] xfs: hoist recovered bmap intent checks out of xfs_bui_item_recover Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 02/19] xfs: improve the code that checks recovered bmap intent items Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 03/19] xfs: hoist recovered rmap intent checks out of xfs_rui_item_recover Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 04/19] xfs: improve the code that checks recovered rmap intent items Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 05/19] xfs: hoist recovered refcount intent checks out of xfs_cui_item_recover Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 06/19] xfs: improve the code that checks recovered refcount intent items Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 07/19] xfs: don't nest icloglock inside ic_callback_lock Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 08/19] xfs: convert XLOG_FORCED_SHUTDOWN() to xlog_is_shutdown() Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 09/19] xfs: log items should have a xlog pointer, not a mount Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 10/19] xfs: aborting inodes on shutdown may need buffer lock Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 11/19] xfs: remove xfs_buf_t typedef Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 12/19] xfs: fix super block buf log item UAF during force shutdown Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 13/19] xfs: fix intermittent hang during quotacheck Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 14/19] xfs: buffer pins need to hold a buffer reference Siddh Raman Pant
2026-10-13 8:14 ` [PATCH 5.10 v2 15/19] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-13 8:15 ` [PATCH 5.10 v2 16/19] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-13 8:15 ` [PATCH 5.10 v2 17/19] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-13 8:15 ` [PATCH 5.10 v2 18/19] xfs: factor out stale buffer item completion Siddh Raman Pant
2026-10-13 8:15 ` [PATCH 5.10 v2 19/19] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant
2026-10-13 8:46 ` [PATCH 6.1 v2 0/5] Backport of XFS umount hang fixes Greg KH
2026-10-13 9:10 ` Siddh Raman Pant
2026-10-01 14:50 ` [PATCH 6.6 0/6] " Siddh Raman Pant
2026-10-01 14:50 ` [PATCH 6.6 1/6] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-01 14:50 ` [PATCH 6.6 2/6] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 6.6 3/6] xfs: avoid dquot buffer pin deadlock Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 6.6 4/6] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 6.6 5/6] xfs: factor out stale buffer item completion Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 6.6 6/6] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 00/21] Backport of XFS umount hang fixes Siddh Raman Pant
2026-10-01 14:51 ` Siddh Raman Pant [this message]
2026-10-01 14:51 ` [PATCH 5.10 02/21] xfs: improve the code that checks recovered bmap intent items Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 03/21] xfs: hoist recovered rmap intent checks out of xfs_rui_item_recover Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 04/21] xfs: improve the code that checks recovered rmap intent items Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 05/21] xfs: hoist recovered refcount intent checks out of xfs_cui_item_recover Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 06/21] xfs: improve the code that checks recovered refcount intent items Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 07/21] xfs: don't nest icloglock inside ic_callback_lock Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 08/21] xfs: convert XLOG_FORCED_SHUTDOWN() to xlog_is_shutdown() Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 09/21] xfs: log items should have a xlog pointer, not a mount Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 10/21] xfs: aborting inodes on shutdown may need buffer lock Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 11/21] xfs: remove xfs_buf_t typedef Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 12/21] xfs: fix super block buf log item UAF during force shutdown Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 13/21] xfs: fix intermittent hang during quotacheck Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 14/21] xfs: dquot shrinker doesn't check for XFS_DQFLAG_FREEING Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 15/21] xfs: buffer pins need to hold a buffer reference Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 16/21] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 17/21] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 18/21] xfs: avoid dquot buffer pin deadlock Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 19/21] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 20/21] xfs: factor out stale buffer item completion Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.10 21/21] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 6.1 0/6] Backport of XFS umount hang fixes Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 6.1 1/6] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 6.1 2/6] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 6.1 3/6] xfs: avoid dquot buffer pin deadlock Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 6.1 4/6] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 6.1 5/6] xfs: factor out stale buffer item completion Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 6.1 6/6] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.15 00/11] Backport of XFS umount hang fixes Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.15 01/11] xfs: log items should have a xlog pointer, not a mount Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.15 02/11] xfs: aborting inodes on shutdown may need buffer lock Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.15 03/11] xfs: fix super block buf log item UAF during force shutdown Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.15 04/11] xfs: dquot shrinker doesn't check for XFS_DQFLAG_FREEING Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.15 05/11] xfs: buffer pins need to hold a buffer reference Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.15 06/11] xfs: xfs_ifree_cluster vs xfs_iflush_shutdown_abort deadlock Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.15 07/11] xfs: catch stale AGF/AGF metadata Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.15 08/11] xfs: avoid dquot buffer pin deadlock Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.15 09/11] xfs: rearrange code in xfs_buf_item.c Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.15 10/11] xfs: factor out stale buffer item completion Siddh Raman Pant
2026-10-01 14:51 ` [PATCH 5.15 11/11] xfs: fix unmount hang with unflushable inodes stuck in the AIL Siddh Raman Pant
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=feeddf89debe273a2c9c0ca88980a65af0cc0053.1790866131.git.siddh.raman.pant@oracle.com \
--to=siddh.raman.pant@oracle.com \
--cc=dchinner@redhat.com \
--cc=djwong@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.tinguely@oracle.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®