From: Christoph Hellwig <hch@infradead.org>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: Richard Kolkovich <richard@intrameta.com>, xfs-oss <xfs@oss.sgi.com>
Subject: Re: [PATCH] xfs_repair: catch bad depth in traverse_int_dir2block
Date: Mon, 8 Jun 2009 03:42:30 -0400 [thread overview]
Message-ID: <20090608074230.GA28066@infradead.org> (raw)
In-Reply-To: <4A2C8AD8.9030107@sandeen.net>
On Sun, Jun 07, 2009 at 10:51:52PM -0500, Eric Sandeen wrote:
> A bad on-disk tree depth in traverse_int_dir2block() can
> later cause a segfault when it's used as an array index in
> this function; if we get something beyond the max depth,
> just error out and the dir will get rebuilt.
>
> Reported-by: Richard Kolkovich <richard@intrameta.com>
> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
> ---
>
> diff --git a/repair/dir2.c b/repair/dir2.c
> index 9575fb1..2723e3b 100644
> --- a/repair/dir2.c
> +++ b/repair/dir2.c
> @@ -339,9 +339,17 @@ traverse_int_dir2block(xfs_mount_t *mp,
> /*
> * maintain level counter
> */
> - if (i == -1)
> + if (i == -1) {
> i = da_cursor->active = be16_to_cpu(node->hdr.level);
> - else {
> + if (i >= XFS_DA_NODE_MAXDEPTH) {
> + do_warn(_("bad header depth for directory "
> + "inode %llu\n"),
> + da_cursor->ino);
> + da_brelse(bp);
> + i = -1;
> + goto error_out;
> + }
> + } else {
>From reading the surrounding code this means the dir is now flagged
as corrupted and we attemp to rebuild it. Which is the only thing we
can do here for now.
Reviewed-by: Christoph Hellwig <hch@lst.de>
It would be very good to have an xfsqa testcase with a forcibly
corrupted directoty (checked in image or using xfs_db) to verify this
behaviour.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2009-06-08 7:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-08 3:51 [PATCH] xfs_repair: catch bad depth in traverse_int_dir2block Eric Sandeen
2009-06-08 7:42 ` Christoph Hellwig [this message]
2009-06-09 16:06 ` Richard Kolkovich
2009-06-09 16:38 ` Eric Sandeen
2009-06-10 21:47 ` Richard Kolkovich
2009-06-11 22:30 ` 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=20090608074230.GA28066@infradead.org \
--to=hch@infradead.org \
--cc=richard@intrameta.com \
--cc=sandeen@sandeen.net \
--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