xfs: handle error if xfs_btree_get_bufs fails
diff mbox

Message ID f4473870-0514-87c3-6cf2-1dfd548a1e4a@sandeen.net
State Accepted
Headers show

Commit Message

Eric Sandeen Dec. 12, 2016, 10:39 p.m. UTC
Jason reported that a corrupted filesystem failed to replay
the log with a metadata block out of bounds warning:

XFS (dm-2): _xfs_buf_find: Block out of range: block 0x80270fff8, EOFS 0x9c40000 

_xfs_buf_find() and xfs_btree_get_bufs() return NULL if
that happens, and then when xfs_alloc_fix_freelist() calls
xfs_trans_binval() on that NULL bp, we oops with:

BUG: unable to handle kernel NULL pointer dereference at 00000000000000f8

We don't handle _xfs_buf_find errors very well, every
caller higher up the stack gets to guess at why it failed.
But we should at least handle it somehow, so return
EFSCORRUPTED here.

Reported-by: Jason L Tibbitts III <tibbs@math.uh.edu>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

V2: use EFSCORRUPTED.



--
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

Comments

Luis Chamberlain Oct. 10, 2017, 2:19 a.m. UTC | #1
What ever happened to this patch [0]? It was ACKed [1] but I haven't
seen it merged. Did it fall through the cracks?

[0] https://patchwork.kernel.org/patch/9486811/
[1] https://www.spinics.net/lists/linux-xfs/msg02818.html

  Luis
--
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
Eric Sandeen Oct. 10, 2017, 3:07 a.m. UTC | #2
On 10/9/17 9:19 PM, Luis R. Rodriguez wrote:
> What ever happened to this patch [0]? It was ACKed [1] 

(it was reviewed-by hch)

> but I haven't
> seen it merged. Did it fall through the cracks?

Seems like it, possibly because I sent V2 as a re:, accidentally.

-Eric
 
> [0] https://patchwork.kernel.org/patch/9486811/
> [1] https://www.spinics.net/lists/linux-xfs/msg02818.html
> 
>   Luis
--
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
Darrick J. Wong Oct. 10, 2017, 4:07 a.m. UTC | #3
On Mon, Oct 09, 2017 at 10:07:12PM -0500, Eric Sandeen wrote:
> 
> 
> On 10/9/17 9:19 PM, Luis R. Rodriguez wrote:
> > What ever happened to this patch [0]? It was ACKed [1] 
> 
> (it was reviewed-by hch)
> 
> > but I haven't
> > seen it merged. Did it fall through the cracks?
> 
> Seems like it, possibly because I sent V2 as a re:, accidentally.

<grumble>

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> 
> -Eric
>  
> > [0] https://patchwork.kernel.org/patch/9486811/
> > [1] https://www.spinics.net/lists/linux-xfs/msg02818.html
> > 
> >   Luis
> --
> 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
Luis Chamberlain Oct. 13, 2017, 12:02 a.m. UTC | #4
On Mon, Oct 09, 2017 at 09:07:36PM -0700, Darrick J. Wong wrote:
> On Mon, Oct 09, 2017 at 10:07:12PM -0500, Eric Sandeen wrote:
> > 
> > 
> > On 10/9/17 9:19 PM, Luis R. Rodriguez wrote:
> > > What ever happened to this patch [0]? It was ACKed [1] 
> > 
> > (it was reviewed-by hch)
> > 
> > > but I haven't
> > > seen it merged. Did it fall through the cracks?
> > 
> > Seems like it, possibly because I sent V2 as a re:, accidentally.
> 
> <grumble>
> 
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

If we're going to add this shouldn't we then also have checks for
xfs_btree_get_bufl() calls?

  Luis
--
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
Luis Chamberlain Oct. 17, 2017, 6:27 p.m. UTC | #5
On Fri, Oct 13, 2017 at 02:02:16AM +0200, Luis R. Rodriguez wrote:
> On Mon, Oct 09, 2017 at 09:07:36PM -0700, Darrick J. Wong wrote:
> > On Mon, Oct 09, 2017 at 10:07:12PM -0500, Eric Sandeen wrote:
> > > 
> > > 
> > > On 10/9/17 9:19 PM, Luis R. Rodriguez wrote:
> > > > What ever happened to this patch [0]? It was ACKed [1] 
> > > 
> > > (it was reviewed-by hch)
> > > 
> > > > but I haven't
> > > > seen it merged. Did it fall through the cracks?
> > > 
> > > Seems like it, possibly because I sent V2 as a re:, accidentally.
> > 
> > <grumble>
> > 
> > Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> 
> If we're going to add this shouldn't we then also have checks for
> xfs_btree_get_bufl() calls?

*re-poke*

  Luis
--
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
Darrick J. Wong Oct. 17, 2017, 6:35 p.m. UTC | #6
On Tue, Oct 17, 2017 at 08:27:28PM +0200, Luis R. Rodriguez wrote:
> On Fri, Oct 13, 2017 at 02:02:16AM +0200, Luis R. Rodriguez wrote:
> > On Mon, Oct 09, 2017 at 09:07:36PM -0700, Darrick J. Wong wrote:
> > > On Mon, Oct 09, 2017 at 10:07:12PM -0500, Eric Sandeen wrote:
> > > > 
> > > > 
> > > > On 10/9/17 9:19 PM, Luis R. Rodriguez wrote:
> > > > > What ever happened to this patch [0]? It was ACKed [1] 
> > > > 
> > > > (it was reviewed-by hch)
> > > > 
> > > > > but I haven't
> > > > > seen it merged. Did it fall through the cracks?
> > > > 
> > > > Seems like it, possibly because I sent V2 as a re:, accidentally.
> > > 
> > > <grumble>
> > > 
> > > Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > If we're going to add this shouldn't we then also have checks for
> > xfs_btree_get_bufl() calls?
> 
> *re-poke*

AFAICT the two callers of xfs_btree_get_bufl already checked that the
incoming argument isn't NULLFSBLOCK, and (at least in theory) the bnobt
shouldn't have freespace records extending outside the filesystem.

That said, new patches accepted. ;)

--D

> 
>   Luis
--
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

Patch
diff mbox

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index effb64c..c90b307 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -1640,6 +1640,10 @@  STATIC int xfs_alloc_ag_vextent_small(xfs_alloc_arg_t *,
 
 				bp = xfs_btree_get_bufs(args->mp, args->tp,
 					args->agno, fbno, 0);
+				if (!bp) {
+					error = -EFSCORRUPTED;
+					goto error0;
+				}
 				xfs_trans_binval(args->tp, bp);
 			}
 			args->len = 1;
@@ -2185,6 +2189,10 @@  STATIC int xfs_alloc_ag_vextent_small(xfs_alloc_arg_t *,
 		if (error)
 			goto out_agbp_relse;
 		bp = xfs_btree_get_bufs(mp, tp, args->agno, bno, 0);
+		if (!bp) {
+			error = -EFSCORRUPTED;
+			goto out_agbp_relse;
+		}
 		xfs_trans_binval(tp, bp);
 	}