From: Eric Sandeen <sandeen@sandeen.net>
To: "Darrick J. Wong" <djwong@alder.djwong.org>,
david@fromorbit.com, darrick.wong@oracle.com
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 02/10] xfs_db: don't crash on a corrupt inode
Date: Mon, 17 Aug 2015 13:52:18 -0500 [thread overview]
Message-ID: <55D22D62.9060806@sandeen.net> (raw)
In-Reply-To: <20150815014351.1839.81382.stgit@birch.djwong.org>
On 8/14/15 8:43 PM, Darrick J. Wong wrote:
> If the user selects a corrupt inode via the 'inode XXX' command, the
> read verifier will fail and the io cursor at the top of the ring will
> not have any data attached. When this is the case, we cannot
> dereference the NULL pointer or xfs_db will crash. Therefore, check
> the buffer pointer before using it.
>
> It's arguable that we ought to retry the read without the verifiers
> if the inode is corrupt or fails CRC, since this /is/ a debugging
> tool, and maybe you wanted the contents anyway.
I agree. It seems like we should do that, though it probably needs to
be done across the board for all metadata types if it's going to be done.
Maybe something to add to the TODO?
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> db/inode.c | 2 ++
> 1 file changed, 2 insertions(+)
>
>
> diff --git a/db/inode.c b/db/inode.c
> index e86dabd..64b263b 100644
> --- a/db/inode.c
> +++ b/db/inode.c
> @@ -682,6 +682,8 @@ set_cur_inode(
> set_cur(&typtab[TYP_INODE], XFS_AGB_TO_DADDR(mp, agno, cluster_agbno),
> numblks, DB_RING_IGN, NULL);
> off_cur(offset << mp->m_sb.sb_inodelog, mp->m_sb.sb_inodesize);
off_cur checks for iocur_top == NULL, and warns if it is, so that's good.
The user should have a clue about what's gone wrong, at least.
But, callers of set_cur_inode() are still going to crash often as not:
ablock_f:
set_cur_inode(iocur_top->ino);
haveattr = XFS_DFORK_Q((xfs_dinode_t *)iocur_top->data);
bmap:
set_cur_inode(iocur_top->ino);
nex = *nexp;
*nexp = 0;
ASSERT(nex > 0);
dip = iocur_top->data;
bmap_f:
set_cur_inode(iocur_top->ino);
dip = iocur_top->data;
and a few more :(
Perhaps set_cur_inode() should return failure, so the caller knows to bail,
pop_cur if it needs to, etc?
-Eric
> + if (!iocur_top->data)
> + return;
> dip = iocur_top->data;
> iocur_top->ino_buf = 1;
> iocur_top->ino = ino;
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-08-17 18:52 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-15 1:43 [PATCH 00/10] xfsprogs August 2015 patchbomb Darrick J. Wong
2015-08-15 1:43 ` [PATCH 01/10] libxfs: readahead of dir3 data blocks should use the read verifier Darrick J. Wong
2015-08-17 18:31 ` Eric Sandeen
2015-08-17 20:30 ` Darrick J. Wong
2015-08-15 1:43 ` [PATCH 02/10] xfs_db: don't crash on a corrupt inode Darrick J. Wong
2015-08-17 18:52 ` Eric Sandeen [this message]
2015-08-17 20:45 ` Darrick J. Wong
2015-08-15 1:43 ` [PATCH 03/10] xfs_repair: ignore "repaired" flag after we decide to clear xattr block Darrick J. Wong
2015-08-17 19:20 ` Eric Sandeen
2015-08-17 20:50 ` Darrick J. Wong
2015-08-15 1:44 ` [PATCH 04/10] xfs_repair: fix broken EFSBADCRC/EFSCORRUPTED usage with buffer errors Darrick J. Wong
2015-08-17 19:51 ` Eric Sandeen
2015-08-17 19:57 ` Eric Sandeen
2015-08-15 1:44 ` [PATCH 05/10] xfs_repair: force not-so-bad bmbt blocks back through the verifier Darrick J. Wong
2015-08-17 21:14 ` Eric Sandeen
2015-08-17 23:48 ` Darrick J. Wong
2015-08-15 1:44 ` [PATCH 06/10] xfs_repair: mark unreachable prefetched metadata blocks stale Darrick J. Wong
2015-08-15 1:44 ` [PATCH 07/10] xfs_io: support reflinking and deduping file ranges Darrick J. Wong
2015-08-15 1:44 ` [PATCH 08/10] xfs_db: enable blocktrash for checksummed filesystems Darrick J. Wong
2015-08-18 19:26 ` Eric Sandeen
2015-08-19 15:22 ` Darrick J. Wong
2015-08-15 1:44 ` [PATCH 09/10] xfs_db: trash the block at the top of the cursor stack Darrick J. Wong
2015-08-18 19:59 ` Eric Sandeen
2015-08-19 15:12 ` Darrick J. Wong
2015-08-15 1:44 ` [PATCH 10/10] xfs_db: enable blockget for v5 filesystems Darrick J. Wong
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=55D22D62.9060806@sandeen.net \
--to=sandeen@sandeen.net \
--cc=darrick.wong@oracle.com \
--cc=david@fromorbit.com \
--cc=djwong@alder.djwong.org \
--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