From 35e72fe5b80ea823034d7aa88b8f5f7647a8821f Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Thu, 6 Jan 2022 14:13:21 -0800 Subject: [PATCH] xfs_db: warn about suspicious finobt trees when metadumping We warn about suspicious roots and btree heights before metadumping the inode btree, so do the same for the free inode btree. Signed-off-by: Darrick J. Wong --- db/metadump.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/db/metadump.c b/db/metadump.c index cc7a4a550..af8b67d5a 100644 --- a/db/metadump.c +++ b/db/metadump.c @@ -2664,6 +2664,21 @@ copy_inodes( root = be32_to_cpu(agi->agi_free_root); levels = be32_to_cpu(agi->agi_free_level); + if (root == 0 || root > mp->m_sb.sb_agblocks) { + if (show_warnings) + print_warning("invalid block number (%u) in " + "finobt root in agi %u", root, + agno); + return 1; + } + + if (levels > XFS_BTREE_MAXLEVELS) { + if (show_warnings) + print_warning("invalid level (%u) in finobt " + "root in agi %u", levels, agno); + return 1; + } + finobt = 1; if (!scan_btree(agno, root, levels, TYP_FINOBT, &finobt, scanfunc_ino)) -- 2.47.3