All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: xfs <linux-xfs@vger.kernel.org>
Subject: Re: [PATCH] xfs: check da node magic in _node_lookup_int
Date: Tue, 31 Jul 2018 16:04:35 -0700	[thread overview]
Message-ID: <20180731230435.GZ30972@magnolia> (raw)
In-Reply-To: <20180731223112.GG2234@dastard>

On Wed, Aug 01, 2018 at 08:31:12AM +1000, Dave Chinner wrote:
> On Tue, Jul 31, 2018 at 01:03:56PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Before we start processing what we /think/ is a da3 node block, actually
> > check the magic to make sure that we're looking at a node block.  This
> > way we won't blow the asserts in _node_hdr_from_disk on corrupted
> > metadata.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  fs/xfs/libxfs/xfs_da_btree.c |    5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> > index 9efbd2038ffb..70e7da634f3e 100644
> > --- a/fs/xfs/libxfs/xfs_da_btree.c
> > +++ b/fs/xfs/libxfs/xfs_da_btree.c
> > @@ -1522,8 +1522,11 @@ xfs_da3_node_lookup_int(
> >  			break;
> >  		}
> >  
> > -		blk->magic = XFS_DA_NODE_MAGIC;
> > +		if (blk->magic != XFS_DA_NODE_MAGIC &&
> > +		    blk->magic != XFS_DA3_NODE_MAGIC)
> > +			return -EFSCORRUPTED;
> >  
> > +		blk->magic = XFS_DA_NODE_MAGIC;
> 
> Can we please use a temporary variable for the on-disk magic number
> checks, then? blk->magic isn't supposed to hold the on disk format
> magic number - it's just an indication of the format the current
> state block points at - so using it to temporarily store the on disk
> magic number for checks like this is just wrong....

Ok.

--D

> Cheers,
> 
> Dave.
> -- 
> Dave Chinner
> david@fromorbit.com
> --
> 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:[~2018-08-01  0:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-31 20:03 [PATCH] xfs: check da node magic in _node_lookup_int Darrick J. Wong
2018-07-31 22:31 ` Dave Chinner
2018-07-31 23:04   ` Darrick J. Wong [this message]

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=20180731230435.GZ30972@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=david@fromorbit.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.