All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: handle error if xfs_btree_get_bufs fails
@ 2016-12-12 22:00 Eric Sandeen
  2016-12-12 22:14 ` Dave Chinner
  2016-12-12 22:39 ` Eric Sandeen
  0 siblings, 2 replies; 11+ messages in thread
From: Eric Sandeen @ 2016-12-12 22:00 UTC (permalink / raw)
  To: linux-xfs; +Cc: Jason L Tibbitts III

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.  I chose EIO here
for lack of a better idea.  :)

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

diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index effb64c..d125135 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 = -EIO;
+					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 = -EIO;
+			goto out_agbp_relse;
+		}
 		xfs_trans_binval(tp, bp);
 	}
 


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] xfs: handle error if xfs_btree_get_bufs fails
  2016-12-12 22:00 [PATCH] xfs: handle error if xfs_btree_get_bufs fails Eric Sandeen
@ 2016-12-12 22:14 ` Dave Chinner
  2016-12-12 22:33   ` Eric Sandeen
  2016-12-12 22:39 ` Eric Sandeen
  1 sibling, 1 reply; 11+ messages in thread
From: Dave Chinner @ 2016-12-12 22:14 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: linux-xfs, Jason L Tibbitts III

On Mon, Dec 12, 2016 at 04:00:26PM -0600, Eric Sandeen wrote:
> 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.  I chose EIO here
> for lack of a better idea.  :)
> 
> Reported-by: Jason L Tibbitts III <tibbs@math.uh.edu>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> 
> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> index effb64c..d125135 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 = -EIO;
> +					goto error0;
> +				}

If this happens, it's because the filesystem is corrupted, not
because we had an IO error. -EFSCORRUPTED is more appropriate here,
as the comment in _xfs_buf_find() says...

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] xfs: handle error if xfs_btree_get_bufs fails
  2016-12-12 22:14 ` Dave Chinner
@ 2016-12-12 22:33   ` Eric Sandeen
  0 siblings, 0 replies; 11+ messages in thread
From: Eric Sandeen @ 2016-12-12 22:33 UTC (permalink / raw)
  To: Dave Chinner; +Cc: linux-xfs, Jason L Tibbitts III

On 12/12/16 4:14 PM, Dave Chinner wrote:
> On Mon, Dec 12, 2016 at 04:00:26PM -0600, Eric Sandeen wrote:
>> 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.  I chose EIO here
>> for lack of a better idea.  :)
>>
>> Reported-by: Jason L Tibbitts III <tibbs@math.uh.edu>
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>> ---
>>
>> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
>> index effb64c..d125135 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 = -EIO;
>> +					goto error0;
>> +				}
> 
> If this happens, it's because the filesystem is corrupted, not
> because we had an IO error. -EFSCORRUPTED is more appropriate here,
> as the comment in _xfs_buf_find() says...

Ok, I thought I saw other places set EIO and ENOMEM, but it doesn't
matter to me ...  I'll resend w/ -EFSCORRUPTED.

Thanks,
-Eric

> Cheers,
> 
> Dave.
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] xfs: handle error if xfs_btree_get_bufs fails
  2016-12-12 22:00 [PATCH] xfs: handle error if xfs_btree_get_bufs fails Eric Sandeen
  2016-12-12 22:14 ` Dave Chinner
@ 2016-12-12 22:39 ` Eric Sandeen
  2016-12-14 10:44   ` Christoph Hellwig
  2017-10-10  2:19   ` Luis R. Rodriguez
  1 sibling, 2 replies; 11+ messages in thread
From: Eric Sandeen @ 2016-12-12 22:39 UTC (permalink / raw)
  To: Eric Sandeen, linux-xfs; +Cc: Jason L Tibbitts III

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.

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);
 	}
 



^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH] xfs: handle error if xfs_btree_get_bufs fails
  2016-12-12 22:39 ` Eric Sandeen
@ 2016-12-14 10:44   ` Christoph Hellwig
  2017-10-10  2:19   ` Luis R. Rodriguez
  1 sibling, 0 replies; 11+ messages in thread
From: Christoph Hellwig @ 2016-12-14 10:44 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Eric Sandeen, linux-xfs, Jason L Tibbitts III

On Mon, Dec 12, 2016 at 04:39:49PM -0600, Eric Sandeen wrote:
> 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>

Looks fine, although the Subject line needs to lose to Re:

Reviewed-by: Christoph Hellwig <hch@lst.de>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] xfs: handle error if xfs_btree_get_bufs fails
  2016-12-12 22:39 ` Eric Sandeen
  2016-12-14 10:44   ` Christoph Hellwig
@ 2017-10-10  2:19   ` Luis R. Rodriguez
  2017-10-10  3:07     ` Eric Sandeen
  1 sibling, 1 reply; 11+ messages in thread
From: Luis R. Rodriguez @ 2017-10-10  2:19 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Christoph Hellwig, linux-xfs, gfigueira, tetsuya.inoue

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] xfs: handle error if xfs_btree_get_bufs fails
  2017-10-10  2:19   ` Luis R. Rodriguez
@ 2017-10-10  3:07     ` Eric Sandeen
  2017-10-10  4:07       ` Darrick J. Wong
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Sandeen @ 2017-10-10  3:07 UTC (permalink / raw)
  To: Luis R. Rodriguez, Eric Sandeen
  Cc: Christoph Hellwig, linux-xfs, gfigueira, tetsuya.inoue



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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] xfs: handle error if xfs_btree_get_bufs fails
  2017-10-10  3:07     ` Eric Sandeen
@ 2017-10-10  4:07       ` Darrick J. Wong
  2017-10-13  0:02         ` Luis R. Rodriguez
  0 siblings, 1 reply; 11+ messages in thread
From: Darrick J. Wong @ 2017-10-10  4:07 UTC (permalink / raw)
  To: Eric Sandeen
  Cc: Luis R. Rodriguez, Eric Sandeen, Christoph Hellwig, linux-xfs,
	gfigueira, tetsuya.inoue

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] xfs: handle error if xfs_btree_get_bufs fails
  2017-10-10  4:07       ` Darrick J. Wong
@ 2017-10-13  0:02         ` Luis R. Rodriguez
  2017-10-17 18:27           ` Luis R. Rodriguez
  0 siblings, 1 reply; 11+ messages in thread
From: Luis R. Rodriguez @ 2017-10-13  0:02 UTC (permalink / raw)
  To: Darrick J. Wong
  Cc: Eric Sandeen, Luis R. Rodriguez, Eric Sandeen, Christoph Hellwig,
	linux-xfs, gfigueira, tetsuya.inoue

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] xfs: handle error if xfs_btree_get_bufs fails
  2017-10-13  0:02         ` Luis R. Rodriguez
@ 2017-10-17 18:27           ` Luis R. Rodriguez
  2017-10-17 18:35             ` Darrick J. Wong
  0 siblings, 1 reply; 11+ messages in thread
From: Luis R. Rodriguez @ 2017-10-17 18:27 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: Darrick J. Wong, Eric Sandeen, Eric Sandeen, Christoph Hellwig,
	linux-xfs, gfigueira, tetsuya.inoue

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH] xfs: handle error if xfs_btree_get_bufs fails
  2017-10-17 18:27           ` Luis R. Rodriguez
@ 2017-10-17 18:35             ` Darrick J. Wong
  0 siblings, 0 replies; 11+ messages in thread
From: Darrick J. Wong @ 2017-10-17 18:35 UTC (permalink / raw)
  To: Luis R. Rodriguez
  Cc: Eric Sandeen, Eric Sandeen, Christoph Hellwig, linux-xfs,
	gfigueira, tetsuya.inoue

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-10-17 18:36 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-12 22:00 [PATCH] xfs: handle error if xfs_btree_get_bufs fails Eric Sandeen
2016-12-12 22:14 ` Dave Chinner
2016-12-12 22:33   ` Eric Sandeen
2016-12-12 22:39 ` Eric Sandeen
2016-12-14 10:44   ` Christoph Hellwig
2017-10-10  2:19   ` Luis R. Rodriguez
2017-10-10  3:07     ` Eric Sandeen
2017-10-10  4:07       ` Darrick J. Wong
2017-10-13  0:02         ` Luis R. Rodriguez
2017-10-17 18:27           ` Luis R. Rodriguez
2017-10-17 18:35             ` Darrick J. Wong

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.