From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Dave Chinner <david@fromorbit.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 07/10] xfs: xfs_alloc_get_rec should return EFSCORRUPTED for obvious bnobt corruption
Date: Sun, 3 Jun 2018 21:32:21 -0700 [thread overview]
Message-ID: <20180604043221.GN7825@magnolia> (raw)
In-Reply-To: <20180604001406.GE10363@dastard>
On Mon, Jun 04, 2018 at 10:14:06AM +1000, Dave Chinner wrote:
> On Sun, Jun 03, 2018 at 04:23:08PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> >
> > Return -EFSCORRUPTED when the bnobt/cntbt return obviously corrupt
> > values, rather than letting them bounce around in the internal code.
> >
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > fs/xfs/libxfs/xfs_alloc.c | 12 ++++++++----
> > 1 file changed, 8 insertions(+), 4 deletions(-)
> >
> >
> > diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> > index dc9dd3805d97..0214a77808d0 100644
> > --- a/fs/xfs/libxfs/xfs_alloc.c
> > +++ b/fs/xfs/libxfs/xfs_alloc.c
> > @@ -231,10 +231,14 @@ xfs_alloc_get_rec(
> > int error;
> >
> > error = xfs_btree_get_rec(cur, &rec, stat);
> > - if (!error && *stat == 1) {
> > - *bno = be32_to_cpu(rec->alloc.ar_startblock);
> > - *len = be32_to_cpu(rec->alloc.ar_blockcount);
> > - }
> > + if (error || !(*stat))
> > + return error;
> > + if (rec->alloc.ar_blockcount == 0)
> > + return -EFSCORRUPTED;
> > +
> > + *bno = be32_to_cpu(rec->alloc.ar_startblock);
> > + *len = be32_to_cpu(rec->alloc.ar_blockcount);
>
> Looks good, but makes me wonder if we should verify that
> ar_startblock is a valid agbno, and that the extent lies wholly
> within the AG? That can be another patch, though.
We probably ought to fix all the _get_rec functions to check that
they're not returning obviously garbage results.
--D
> Reviewed-by: Dave Chinner <dchinner@redhat.com>
>
> 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
next prev parent reply other threads:[~2018-06-04 4:32 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-03 23:22 [PATCH 00/10] xfs: fix various checking problems Darrick J. Wong
2018-06-03 23:22 ` [PATCH 01/10] xfs: don't forbid setting dax flag on directories if device doesn't dax Darrick J. Wong
2018-06-03 23:41 ` Dave Chinner
2018-06-04 4:25 ` Darrick J. Wong
2018-06-03 23:22 ` [PATCH 02/10] xfs: strengthen btree pointer checks before use Darrick J. Wong
2018-06-03 23:45 ` Dave Chinner
2018-06-03 23:22 ` [PATCH 03/10] xfs: don't assert when on-disk btree pointers are garbage Darrick J. Wong
2018-06-03 23:49 ` Dave Chinner
2018-06-03 23:55 ` Dave Chinner
2018-06-03 23:22 ` [PATCH 04/10] xfs: check directory bestfree information in the verifier Darrick J. Wong
2018-06-04 0:10 ` Dave Chinner
2018-06-04 4:23 ` Darrick J. Wong
2018-06-03 23:22 ` [PATCH 05/10] xfs: don't assert when reporting on-disk corruption while loading btree Darrick J. Wong
2018-06-03 23:51 ` Dave Chinner
2018-06-03 23:23 ` [PATCH 06/10] xfs: remove redundant ASSERT on insufficient bestfree length in _leaf_addname Darrick J. Wong
2018-06-04 0:11 ` Dave Chinner
2018-06-03 23:23 ` [PATCH 07/10] xfs: xfs_alloc_get_rec should return EFSCORRUPTED for obvious bnobt corruption Darrick J. Wong
2018-06-04 0:14 ` Dave Chinner
2018-06-04 4:32 ` Darrick J. Wong [this message]
2018-06-04 23:22 ` Dave Chinner
2018-06-03 23:23 ` [PATCH 08/10] xfs: btree lookup shouldn't ASSERT on empty btree nodes Darrick J. Wong
2018-06-04 0:14 ` Dave Chinner
2018-06-03 23:23 ` [PATCH 09/10] xfs: don't ASSERT on short form btree root pointer of zero Darrick J. Wong
2018-06-04 0:15 ` Dave Chinner
2018-06-03 23:23 ` [PATCH 10/10] xfs: don't return garbage buffers in xfs_da3_node_read Darrick J. Wong
2018-06-04 0:18 ` Dave Chinner
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=20180604043221.GN7825@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox