[PATCH] Check block magic number so we scan only valid blocks.
Peter Watkins
treestem at gmail.com
Wed Jul 7 10:09:11 CDT 2010
Hello,
Occasionally I've hit a SEGV while querying free space in xfs_db on a mounted
file system. In scanfunc_bno, block->bb_numrecs has crazy values. And bb_magic
is not XFS_ABTB_MAGIC.
Does a check like this, similiar to other places, make sense?
Should scanfunc_cnt make a similiar check?
Signed-off-by: Peter Watkins <treestem at gmail.com>
---
db/freesp.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/db/freesp.c b/db/freesp.c
index e1902c6..7825628 100644
--- a/db/freesp.c
+++ b/db/freesp.c
@@ -286,6 +286,9 @@ scanfunc_bno(
xfs_alloc_ptr_t *pp;
xfs_alloc_rec_t *rp;
+ if (be32_to_cpu(block->bb_magic) != XFS_ABTB_MAGIC)
+ return;
+
if (level == 0) {
rp = XFS_ALLOC_REC_ADDR(mp, block, 1);
for (i = 0; i < be16_to_cpu(block->bb_numrecs); i++)
--
1.6.0.4
More information about the xfs
mailing list