* [PATCH] xfs: check da node magic in _node_lookup_int
@ 2018-07-31 20:03 Darrick J. Wong
2018-07-31 22:31 ` Dave Chinner
0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2018-07-31 20:03 UTC (permalink / raw)
To: xfs
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;
/*
* Search an intermediate node for a match.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: check da node magic in _node_lookup_int
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
0 siblings, 1 reply; 3+ messages in thread
From: Dave Chinner @ 2018-07-31 22:31 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: xfs
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....
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xfs: check da node magic in _node_lookup_int
2018-07-31 22:31 ` Dave Chinner
@ 2018-07-31 23:04 ` Darrick J. Wong
0 siblings, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2018-07-31 23:04 UTC (permalink / raw)
To: Dave Chinner; +Cc: xfs
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-08-01 0:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).