[Top] [All Lists]

Re: [PATCH] xfsprogs: fix inode crash in xfs_repair

To: Mark Tinguely <tinguely@xxxxxxx>
Subject: Re: [PATCH] xfsprogs: fix inode crash in xfs_repair
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Fri, 16 Aug 2013 07:47:59 +1000
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <520CE0AD.7060306@xxxxxxx>
References: <20130813221739.031858865@xxxxxxx> <20130814064013.GC12779@dastard> <520B870F.8040808@xxxxxxx> <20130815003313.GJ6023@dastard> <520CE0AD.7060306@xxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Thu, Aug 15, 2013 at 09:07:41AM -0500, Mark Tinguely wrote:
> On 08/14/13 19:33, Dave Chinner wrote:
> >On Wed, Aug 14, 2013 at 08:33:03AM -0500, Mark Tinguely wrote:
> >>>I don't understand this check.
> >>>
> >>>We've already dereferenced ip several lines above to increment the
> >>>link count and get the inode number stored in ino, so the ip != NULL
> >>>is unnecessary.
> >>>
> >>>We've just allocated the inode, so why would the magic number be
> >>>wrong? And why would the inode number lie in a non-existent
> >>>allocation group?
> >>>
> >>
> >>just being being paranoid.
> >
> >It's the same code as in the kernel - if is that broken that it
> >can't tell it didn't allocate a real inode, then we've got bigger
> >problems. We design the code to return an error when it fails so we
> >don't have to robustly check every possible error condition at every
> >call site. So really the only check needed is "if (!irec) {...}"
> The inode number check came from find_inode_rec(ag, agino)
> (repair/incore.h). A bad inode number will also return a NULL irec.

Yes, it will. But we just allocated the inode, so it's guaranteed to
have a valid inode number. We've got an inode *from a trusted
source* so we don't need to validate it the same way we need to
validate an inode number that we've pulled of disk that might be

Paranoia is great when using data from an untrusted source. But when
the data is from a trusted source, extreme paranoia is not necessary
and just makes the code hard to read...


Dave Chinner

<Prev in Thread] Current Thread [Next in Thread>