linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 05/12] xfs: verify dinode header first
Date: Mon, 18 Sep 2017 12:45:57 -0700	[thread overview]
Message-ID: <20170918194557.GR6540@magnolia> (raw)
In-Reply-To: <20170906164353.GE55280@bfoster.bfoster>

On Wed, Sep 06, 2017 at 12:43:53PM -0400, Brian Foster wrote:
> On Mon, Aug 28, 2017 at 11:17:01AM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Move the v3 inode integrity information (crc, owner, metauuid) before we
> > look at anything else in the inode so that we don't waste time on a torn
> > write or a totally garbled block.  This makes xfs_dinode_verify more
> > consistent with the other verifiers.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> 
> Hmm, was there a practical reason for doing this? In the common case,
> the filesystem is not corrupted and we have to pass all the checks
> anyways. I'd just say keep the code flow simple rather than worry about
> optimizing the error case, unless there's some reason to prioritize some
> error checks over others..?

I'm under the impression that we want to reject a metadata object if its
crc is bad before we even try to verify the object's fields.

Granted, we have to check the magic and the version to find out if
there even /is/ a crc, but in general crc checks come first everywhere
else in xfs.

--D

> 
> Brian
> 
> >  fs/xfs/libxfs/xfs_inode_buf.c |   23 +++++++++++++----------
> >  1 file changed, 13 insertions(+), 10 deletions(-)
> > 
> > 
> > diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
> > index a5bcf2b..b2423a3 100644
> > --- a/fs/xfs/libxfs/xfs_inode_buf.c
> > +++ b/fs/xfs/libxfs/xfs_inode_buf.c
> > @@ -393,6 +393,19 @@ xfs_dinode_verify(
> >  	if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC))
> >  		return __this_address;
> >  
> > +	/* Verify v3 integrity information first */
> > +	if (dip->di_version >= 3) {
> > +		if (!xfs_sb_version_hascrc(&mp->m_sb))
> > +			return __this_address;
> > +		if (!xfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize,
> > +				      XFS_DINODE_CRC_OFF))
> > +			return __this_address;
> > +		if (be64_to_cpu(dip->di_ino) != ino)
> > +			return __this_address;
> > +		if (!uuid_equal(&dip->di_uuid, &mp->m_sb.sb_meta_uuid))
> > +			return __this_address;
> > +	}
> > +
> >  	/* don't allow invalid i_size */
> >  	if (be64_to_cpu(dip->di_size) & (1ULL << 63))
> >  		return __this_address;
> > @@ -409,16 +422,6 @@ xfs_dinode_verify(
> >  	if (dip->di_version < 3)
> >  		return NULL;
> >  
> > -	if (!xfs_sb_version_hascrc(&mp->m_sb))
> > -		return __this_address;
> > -	if (!xfs_verify_cksum((char *)dip, mp->m_sb.sb_inodesize,
> > -			      XFS_DINODE_CRC_OFF))
> > -		return __this_address;
> > -	if (be64_to_cpu(dip->di_ino) != ino)
> > -		return __this_address;
> > -	if (!uuid_equal(&dip->di_uuid, &mp->m_sb.sb_meta_uuid))
> > -		return __this_address;
> > -
> >  	flags = be16_to_cpu(dip->di_flags);
> >  	flags2 = be64_to_cpu(dip->di_flags2);
> >  
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2017-09-18 19:46 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-28 18:16 [PATCH 00/12] xfs: more and better verifiers Darrick J. Wong
2017-08-28 18:16 ` [PATCH 01/12] xfs: refactor long-format btree header verification routines Darrick J. Wong
2017-08-28 18:16 ` [PATCH 02/12] xfs: remove XFS_WANT_CORRUPTED_RETURN from dir3 data verifiers Darrick J. Wong
2017-08-28 18:16 ` [PATCH 03/12] xfs: have buffer verifier functions report failing address Darrick J. Wong
2017-08-28 18:16 ` [PATCH 04/12] xfs: refactor verifier callers to print address of failing check Darrick J. Wong
2017-09-06 16:43   ` Brian Foster
2017-09-18 19:29     ` Darrick J. Wong
2017-08-28 18:17 ` [PATCH 05/12] xfs: verify dinode header first Darrick J. Wong
2017-09-06 16:43   ` Brian Foster
2017-09-18 19:45     ` Darrick J. Wong [this message]
2017-08-28 18:17 ` [PATCH 06/12] xfs: move inode fork verifiers to xfs_dinode_verify Darrick J. Wong
2017-09-06 16:44   ` Brian Foster
2017-09-18 20:22     ` Darrick J. Wong
2017-08-28 18:17 ` [PATCH 07/12] xfs: create structure verifier function for shortform xattrs Darrick J. Wong
2017-08-28 18:17 ` [PATCH 08/12] xfs: create structure verifier function for short form symlinks Darrick J. Wong
2017-08-28 18:17 ` [PATCH 09/12] xfs: refactor short form directory structure verifier function Darrick J. Wong
2017-08-28 18:17 ` [PATCH 10/12] xfs: provide a centralized method for verifying inline fork data Darrick J. Wong
2017-08-28 18:17 ` [PATCH 11/12] xfs: fail out of xfs_attr3_leaf_lookup_int if it looks corrupt Darrick J. Wong
2017-08-28 18:17 ` [PATCH 12/12] xfs: create a new buf_ops pointer to verify structure metadata Darrick J. Wong
2017-09-06 16:47   ` Brian Foster
2017-09-18 20:32     ` Darrick J. Wong
2017-09-19 14:52       ` Brian Foster
2017-09-19 17:24         ` Darrick J. Wong
2017-09-06 16:43 ` [PATCH 00/12] xfs: more and better verifiers Brian Foster
2017-09-18 20:23   ` Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2017-08-17 23:31 [RFC " Darrick J. Wong
2017-08-17 23:32 ` [PATCH 05/12] xfs: verify dinode header first 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=20170918194557.GR6540@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=bfoster@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).