From: Dave Chinner <david@fromorbit.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Ole Tange <tange@binf.ku.dk>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH V2] xfs_repair: skip freelist scan of corrupt agf in no-modify mode
Date: Mon, 4 Mar 2013 10:36:15 +1100 [thread overview]
Message-ID: <20130303233615.GK26081@dastard> (raw)
In-Reply-To: <51326DC0.8030403@sandeen.net>
On Sat, Mar 02, 2013 at 03:23:12PM -0600, Eric Sandeen wrote:
> In xfs_repair's no-modify mode (-n), verify_set_agf doesn't fix up
> bad freelist blocks that it finds. When we get to scan_freelist,
> this can wreak havoc if, for example, first > last and the loop
> never exits; we index agfl->agfl_bno[i] off into the weeds.
>
> To fix this, re-check the values in no-modify mode, and if
> they're off, warn about it and skip the scan.
>
> Reported-by: Ole Tange <tange@binf.ku.dk>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
>
> V2: Remove dumb mistakes :/
>
> diff --git a/repair/scan.c b/repair/scan.c
> index 5345094..1d39bdc 100644
> --- a/repair/scan.c
> +++ b/repair/scan.c
> @@ -1066,6 +1066,18 @@ scan_freelist(
> return;
> }
> agfl = XFS_BUF_TO_AGFL(agflbuf);
> +
> + if (no_modify) {
> + /* agf values not fixed in verify_set_agf, so recheck */
> + if (be32_to_cpu(agf->agf_flfirst) >= XFS_AGFL_SIZE(mp) ||
> + be32_to_cpu(agf->agf_fllast) >= XFS_AGFL_SIZE(mp)) {
> + do_warn(_("agf %d freelist blocks bad, skipping "
> + "freelist scan\n"), i);
> + return;
> + }
> + } else /* should have been fixed in verify_set_agf() */
> + ASSERT(0);
> +
> i = be32_to_cpu(agf->agf_flfirst);
> count = 0;
> for (;;) {
Looks ok, but IIRC there are overruns in these functions for the
same reason (i.e. unchecked use of agf->agf_flfirst as an array
index)
db/check.c::scan_freelist()
db/freesp.c::scan_freelist()
I found lots of almost-but-not-quite-exact code duplication like
this recenty when doing CRC updates to the userspace code....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2013-03-03 23:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-01 23:46 [PATCH] xfs_repair: skip freelist scan of dodgy agf in no-modify mode Eric Sandeen
2013-03-02 1:18 ` Dave Chinner
2013-03-02 1:22 ` Eric Sandeen
2013-03-02 21:23 ` [PATCH V2] xfs_repair: skip freelist scan of corrupt " Eric Sandeen
2013-03-03 23:36 ` Dave Chinner [this message]
2013-03-08 20:31 ` Rich Johnston
2013-03-08 20:31 ` Eric Sandeen
2013-03-09 9:00 ` Dave Chinner
2013-03-11 12:20 ` Rich Johnston
2013-03-09 15:00 ` Eric Sandeen
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=20130303233615.GK26081@dastard \
--to=david@fromorbit.com \
--cc=sandeen@sandeen.net \
--cc=tange@binf.ku.dk \
--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