xfs
[Top] [All Lists]

[PATCH] Check block magic number so we scan only valid blocks.

To: xfs@xxxxxxxxxxx
Subject: [PATCH] Check block magic number so we scan only valid blocks.
From: Peter Watkins <treestem@xxxxxxxxx>
Date: Wed, 7 Jul 2010 11:09:11 -0400
Cc: Peter Watkins <treestem@xxxxxxxxx>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer; bh=ULunmNUTg+GmMp8evW9eaObb132zqm4a5RYtxsC2N/8=; b=aO1sD/D8UgOFUnfe9m3VHqT/RsT8hgUk7+bYoNd9fTwL0O5TXLFTzv+ZZY30E6bCfm 5GcDBBPQ3jce0L+hkhzJns1UlEPHK2fMNEfKILYBg0fz6h5m8O2HepHk2HPrvSMtFigC dRCNJgxLnsn9yoNEgFgnTG70t9ys5ZkLBWObE=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=DXOSn7j8d56Wbf0bFLYGstcq/jEBmLsUDQCXHH5oqeO/xjHo2AsOwvMSdAxlw2wpqW 6zpqSlqY02XE+m7soki+mYJRSt6TKcU5iQbzR3giTuOKGf4GKD+P/tYDoJonGElSRUQ9 ieqa1YlFKajJfDMFpwmze1l3WEeN9HPqpN2pI=
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@xxxxxxxxx>
---
 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

<Prev in Thread] Current Thread [Next in Thread>