* [PATCH] xfs: don't crash when read verifier reports errors with null b_ops
@ 2019-01-15 17:08 Darrick J. Wong
2019-01-15 20:23 ` Dave Chinner
2019-01-15 22:42 ` [PATCH v2] " Darrick J. Wong
0 siblings, 2 replies; 5+ messages in thread
From: Darrick J. Wong @ 2019-01-15 17:08 UTC (permalink / raw)
To: xfs
From: Darrick J. Wong <darrick.wong@oracle.com>
In xrep_findroot_block, we work out the btree type and correctness of a
given block by calling different btree verifiers on root block
candidates. However, we leave the NULL b_ops while ->verify_read
validates the block, which means that if the verifier calls
xfs_buf_verifier_error it'll crash on the null b_ops. Fix it to avoid
this crash.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
FWIW I also thought about stuffing in a fake b_ops while xrep_findroot
is calling a candidate read verifier, but thought that might just
confuse things more?
---
fs/xfs/xfs_error.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index 9866f542e77b..2a02be280769 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -359,7 +359,7 @@ xfs_buf_verifier_error(
xfs_alert(mp, "Metadata %s detected at %pS, %s block 0x%llx %s",
bp->b_error == -EFSBADCRC ? "CRC error" : "corruption",
- fa, bp->b_ops->name, bp->b_bn, name);
+ fa, bp->b_ops ? bp->b_ops->name : "unknown", bp->b_bn, name);
xfs_alert(mp, "Unmount and run xfs_repair");
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs: don't crash when read verifier reports errors with null b_ops
2019-01-15 17:08 [PATCH] xfs: don't crash when read verifier reports errors with null b_ops Darrick J. Wong
@ 2019-01-15 20:23 ` Dave Chinner
2019-01-15 22:38 ` Darrick J. Wong
2019-01-15 22:42 ` [PATCH v2] " Darrick J. Wong
1 sibling, 1 reply; 5+ messages in thread
From: Dave Chinner @ 2019-01-15 20:23 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: xfs
On Tue, Jan 15, 2019 at 09:08:20AM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> In xrep_findroot_block, we work out the btree type and correctness of a
> given block by calling different btree verifiers on root block
> candidates. However, we leave the NULL b_ops while ->verify_read
> validates the block, which means that if the verifier calls
> xfs_buf_verifier_error it'll crash on the null b_ops. Fix it to avoid
> this crash.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> FWIW I also thought about stuffing in a fake b_ops while xrep_findroot
> is calling a candidate read verifier, but thought that might just
> confuse things more?
> ---
> fs/xfs/xfs_error.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> index 9866f542e77b..2a02be280769 100644
> --- a/fs/xfs/xfs_error.c
> +++ b/fs/xfs/xfs_error.c
> @@ -359,7 +359,7 @@ xfs_buf_verifier_error(
>
> xfs_alert(mp, "Metadata %s detected at %pS, %s block 0x%llx %s",
> bp->b_error == -EFSBADCRC ? "CRC error" : "corruption",
> - fa, bp->b_ops->name, bp->b_bn, name);
> + fa, bp->b_ops ? bp->b_ops->name : "unknown", bp->b_bn, name);
Looks fine, but can you add a comment to xfs_buf_verifier_error()
that says that some callers might be running the verifiers
themselves rather than through the b_ops structure and so it may be
null...
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] xfs: don't crash when read verifier reports errors with null b_ops
2019-01-15 20:23 ` Dave Chinner
@ 2019-01-15 22:38 ` Darrick J. Wong
0 siblings, 0 replies; 5+ messages in thread
From: Darrick J. Wong @ 2019-01-15 22:38 UTC (permalink / raw)
To: Dave Chinner; +Cc: xfs
On Wed, Jan 16, 2019 at 07:23:36AM +1100, Dave Chinner wrote:
> On Tue, Jan 15, 2019 at 09:08:20AM -0800, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> >
> > In xrep_findroot_block, we work out the btree type and correctness of a
> > given block by calling different btree verifiers on root block
> > candidates. However, we leave the NULL b_ops while ->verify_read
> > validates the block, which means that if the verifier calls
> > xfs_buf_verifier_error it'll crash on the null b_ops. Fix it to avoid
> > this crash.
> >
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > FWIW I also thought about stuffing in a fake b_ops while xrep_findroot
> > is calling a candidate read verifier, but thought that might just
> > confuse things more?
> > ---
> > fs/xfs/xfs_error.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
> > index 9866f542e77b..2a02be280769 100644
> > --- a/fs/xfs/xfs_error.c
> > +++ b/fs/xfs/xfs_error.c
> > @@ -359,7 +359,7 @@ xfs_buf_verifier_error(
> >
> > xfs_alert(mp, "Metadata %s detected at %pS, %s block 0x%llx %s",
> > bp->b_error == -EFSBADCRC ? "CRC error" : "corruption",
> > - fa, bp->b_ops->name, bp->b_bn, name);
> > + fa, bp->b_ops ? bp->b_ops->name : "unknown", bp->b_bn, name);
>
> Looks fine, but can you add a comment to xfs_buf_verifier_error()
> that says that some callers might be running the verifiers
> themselves rather than through the b_ops structure and so it may be
> null...
Will do.
--D
> Cheers,
>
> Dave.
> --
> Dave Chinner
> david@fromorbit.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] xfs: don't crash when read verifier reports errors with null b_ops
2019-01-15 17:08 [PATCH] xfs: don't crash when read verifier reports errors with null b_ops Darrick J. Wong
2019-01-15 20:23 ` Dave Chinner
@ 2019-01-15 22:42 ` Darrick J. Wong
2019-01-18 5:04 ` Dave Chinner
1 sibling, 1 reply; 5+ messages in thread
From: Darrick J. Wong @ 2019-01-15 22:42 UTC (permalink / raw)
To: xfs; +Cc: Dave Chinner
From: Darrick J. Wong <darrick.wong@oracle.com>
In xrep_findroot_block, we work out the btree type and correctness of a
given block by calling different btree verifiers on root block
candidates. However, we leave the NULL b_ops while ->verify_read
validates the block, which means that if the verifier calls
xfs_buf_verifier_error it'll crash on the null b_ops. Fix it to avoid
this crash.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
v2: leave a comment about what we're doing above the function
---
fs/xfs/xfs_error.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index 9866f542e77b..6e80e438b27a 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -340,6 +340,9 @@ xfs_corruption_error(
/*
* Warnings specifically for verifier errors. Differentiate CRC vs. invalid
* values, and omit the stack trace unless the error level is tuned high.
+ *
+ * NOTE: Some callers might be calling the verifiers directly (rather than
+ * through the b_ops structure) so bp->b_ops may be NULL.
*/
void
xfs_buf_verifier_error(
@@ -359,7 +362,7 @@ xfs_buf_verifier_error(
xfs_alert(mp, "Metadata %s detected at %pS, %s block 0x%llx %s",
bp->b_error == -EFSBADCRC ? "CRC error" : "corruption",
- fa, bp->b_ops->name, bp->b_bn, name);
+ fa, bp->b_ops ? bp->b_ops->name : "unknown", bp->b_bn, name);
xfs_alert(mp, "Unmount and run xfs_repair");
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] xfs: don't crash when read verifier reports errors with null b_ops
2019-01-15 22:42 ` [PATCH v2] " Darrick J. Wong
@ 2019-01-18 5:04 ` Dave Chinner
0 siblings, 0 replies; 5+ messages in thread
From: Dave Chinner @ 2019-01-18 5:04 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: xfs
On Tue, Jan 15, 2019 at 02:42:56PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> In xrep_findroot_block, we work out the btree type and correctness of a
> given block by calling different btree verifiers on root block
> candidates. However, we leave the NULL b_ops while ->verify_read
> validates the block, which means that if the verifier calls
> xfs_buf_verifier_error it'll crash on the null b_ops. Fix it to avoid
> this crash.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> v2: leave a comment about what we're doing above the function
> ---
Looks good now.
Reviewed-by: Dave Chinner <dchinner@redhat.com>
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-01-18 5:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-15 17:08 [PATCH] xfs: don't crash when read verifier reports errors with null b_ops Darrick J. Wong
2019-01-15 20:23 ` Dave Chinner
2019-01-15 22:38 ` Darrick J. Wong
2019-01-15 22:42 ` [PATCH v2] " Darrick J. Wong
2019-01-18 5:04 ` Dave Chinner
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.