public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Watkins <treestem@gmail.com>
To: xfs@oss.sgi.com
Cc: Peter Watkins <treestem@gmail.com>
Subject: [PATCH] Check block magic number so we scan only valid blocks.
Date: Wed,  7 Jul 2010 11:09:11 -0400	[thread overview]
Message-ID: <1278515351-24928-1-git-send-email-treestem@gmail.com> (raw)

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@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

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

             reply	other threads:[~2010-07-07 15:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-07 15:09 Peter Watkins [this message]
2010-07-07 23:52 ` [PATCH] Check block magic number so we scan only valid blocks Christoph Hellwig
2010-07-08 19:20   ` Peter Watkins

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=1278515351-24928-1-git-send-email-treestem@gmail.com \
    --to=treestem@gmail.com \
    --cc=xfs@oss.sgi.com \
    /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