public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Lachlan McIlroy <lachlan@sgi.com>
To: xfs-dev <xfs-dev@sgi.com>, xfs-oss <xfs@oss.sgi.com>
Subject: REVIEW: xfs_bmap_check_leaf_extents() can reference unmapped memory
Date: Thu, 20 Mar 2008 17:11:23 +1100	[thread overview]
Message-ID: <47E2000B.9030208@sgi.com> (raw)

While investigating the extent corruption bug I ran into this bug in
debug only code.  xfs_bmap_check_leaf_extents() loops through the leaf
blocks of the extent btree checking that every extent is entirely
before the next extent.  It also compares the last extent in the previous
block to the first extent in the current block when the previous block
has been released and potentially unmapped.  So take a copy of the last
extent instead of a pointer.  Also move the last extent check out of the
loop because we only need to do it once.

Lachlan


--- fs/xfs/xfs_bmap.c_1.386	2008-03-17 13:37:32.000000000 +1100
+++ fs/xfs/xfs_bmap.c	2008-03-19 14:55:41.000000000 +1100
@@ -6194,7 +6194,7 @@ xfs_bmap_check_leaf_extents(
  	xfs_mount_t		*mp;	/* file system mount structure */
  	__be64			*pp;	/* pointer to block address */
  	xfs_bmbt_rec_t		*ep;	/* pointer to current extent */
-	xfs_bmbt_rec_t		*lastp; /* pointer to previous extent */
+	xfs_bmbt_rec_t		last;   /* last extent in previous block */
  	xfs_bmbt_rec_t		*nextp;	/* pointer to next extent */
  	int			bp_release = 0;

@@ -6264,7 +6264,6 @@ xfs_bmap_check_leaf_extents(
  	/*
  	 * Loop over all leaf nodes checking that all extents are in the right order.
  	 */
-	lastp = NULL;
  	for (;;) {
  		xfs_fsblock_t	nextbno;
  		xfs_extnum_t	num_recs;
@@ -6285,18 +6284,18 @@ xfs_bmap_check_leaf_extents(
  		 */

  		ep = XFS_BTREE_REC_ADDR(xfs_bmbt, block, 1);
+		if (i) {
+			xfs_btree_check_rec(XFS_BTNUM_BMAP, (void *)&last,
+				(void *)ep);
+		}
  		for (j = 1; j < num_recs; j++) {
  			nextp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, j + 1);
-			if (lastp) {
-				xfs_btree_check_rec(XFS_BTNUM_BMAP,
-					(void *)lastp, (void *)ep);
-			}
  			xfs_btree_check_rec(XFS_BTNUM_BMAP, (void *)ep,
  				(void *)(nextp));
-			lastp = ep;
  			ep = nextp;
  		}

+		last = *ep;
  		i += num_recs;
  		if (bp_release) {
  			bp_release = 0;

             reply	other threads:[~2008-03-20  6:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-20  6:11 Lachlan McIlroy [this message]
2008-03-20  7:55 ` REVIEW: xfs_bmap_check_leaf_extents() can reference unmapped memory Christoph Hellwig

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=47E2000B.9030208@sgi.com \
    --to=lachlan@sgi.com \
    --cc=xfs-dev@sgi.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