* [PATCH 1/2] xfs: use a local variable for magic number in xfs_da3_node_lookup_int
@ 2018-07-31 23:20 Darrick J. Wong
2018-07-31 23:21 ` [PATCH 2/2] xfs: check da node magic in _node_lookup_int Darrick J. Wong
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Darrick J. Wong @ 2018-07-31 23:20 UTC (permalink / raw)
To: darrick.wong; +Cc: linux-xfs
From: Darrick J. Wong <darrick.wong@oracle.com>
Use a local variable for the block magic number checks instead of
abusing blk->magic.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
fs/xfs/libxfs/xfs_da_btree.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 9efbd2038ffb..8ffe17b223da 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -1481,6 +1481,7 @@ xfs_da3_node_lookup_int(
int error;
int retval;
unsigned int expected_level = 0;
+ uint16_t magic;
struct xfs_inode *dp = state->args->dp;
args = state->args;
@@ -1505,17 +1506,17 @@ xfs_da3_node_lookup_int(
return error;
}
curr = blk->bp->b_addr;
- blk->magic = be16_to_cpu(curr->magic);
+ magic = be16_to_cpu(curr->magic);
- if (blk->magic == XFS_ATTR_LEAF_MAGIC ||
- blk->magic == XFS_ATTR3_LEAF_MAGIC) {
+ if (magic == XFS_ATTR_LEAF_MAGIC ||
+ magic == XFS_ATTR3_LEAF_MAGIC) {
blk->magic = XFS_ATTR_LEAF_MAGIC;
blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL);
break;
}
- if (blk->magic == XFS_DIR2_LEAFN_MAGIC ||
- blk->magic == XFS_DIR3_LEAFN_MAGIC) {
+ if (magic == XFS_DIR2_LEAFN_MAGIC ||
+ magic == XFS_DIR3_LEAFN_MAGIC) {
blk->magic = XFS_DIR2_LEAFN_MAGIC;
blk->hashval = xfs_dir2_leaf_lasthash(args->dp,
blk->bp, NULL);
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/2] xfs: check da node magic in _node_lookup_int
2018-07-31 23:20 [PATCH 1/2] xfs: use a local variable for magic number in xfs_da3_node_lookup_int Darrick J. Wong
@ 2018-07-31 23:21 ` Darrick J. Wong
2018-08-01 12:07 ` Brian Foster
2018-08-01 12:12 ` Carlos Maiolino
2018-08-01 12:07 ` [PATCH 1/2] xfs: use a local variable for magic number in xfs_da3_node_lookup_int Brian Foster
2018-08-01 12:10 ` Carlos Maiolino
2 siblings, 2 replies; 8+ messages in thread
From: Darrick J. Wong @ 2018-07-31 23:21 UTC (permalink / raw)
To: darrick.wong; +Cc: linux-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 | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
index 8ffe17b223da..376bee94b5dd 100644
--- a/fs/xfs/libxfs/xfs_da_btree.c
+++ b/fs/xfs/libxfs/xfs_da_btree.c
@@ -1523,8 +1523,10 @@ xfs_da3_node_lookup_int(
break;
}
- blk->magic = XFS_DA_NODE_MAGIC;
+ if (magic != XFS_DA_NODE_MAGIC && 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] 8+ messages in thread
* Re: [PATCH 1/2] xfs: use a local variable for magic number in xfs_da3_node_lookup_int
2018-07-31 23:20 [PATCH 1/2] xfs: use a local variable for magic number in xfs_da3_node_lookup_int Darrick J. Wong
2018-07-31 23:21 ` [PATCH 2/2] xfs: check da node magic in _node_lookup_int Darrick J. Wong
@ 2018-08-01 12:07 ` Brian Foster
2018-08-01 12:10 ` Carlos Maiolino
2 siblings, 0 replies; 8+ messages in thread
From: Brian Foster @ 2018-08-01 12:07 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-xfs
On Tue, Jul 31, 2018 at 04:20:54PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Use a local variable for the block magic number checks instead of
> abusing blk->magic.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
Reviewed-by: Brian Foster <bfoster@redhat.com>
> fs/xfs/libxfs/xfs_da_btree.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
>
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index 9efbd2038ffb..8ffe17b223da 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -1481,6 +1481,7 @@ xfs_da3_node_lookup_int(
> int error;
> int retval;
> unsigned int expected_level = 0;
> + uint16_t magic;
> struct xfs_inode *dp = state->args->dp;
>
> args = state->args;
> @@ -1505,17 +1506,17 @@ xfs_da3_node_lookup_int(
> return error;
> }
> curr = blk->bp->b_addr;
> - blk->magic = be16_to_cpu(curr->magic);
> + magic = be16_to_cpu(curr->magic);
>
> - if (blk->magic == XFS_ATTR_LEAF_MAGIC ||
> - blk->magic == XFS_ATTR3_LEAF_MAGIC) {
> + if (magic == XFS_ATTR_LEAF_MAGIC ||
> + magic == XFS_ATTR3_LEAF_MAGIC) {
> blk->magic = XFS_ATTR_LEAF_MAGIC;
> blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL);
> break;
> }
>
> - if (blk->magic == XFS_DIR2_LEAFN_MAGIC ||
> - blk->magic == XFS_DIR3_LEAFN_MAGIC) {
> + if (magic == XFS_DIR2_LEAFN_MAGIC ||
> + magic == XFS_DIR3_LEAFN_MAGIC) {
> blk->magic = XFS_DIR2_LEAFN_MAGIC;
> blk->hashval = xfs_dir2_leaf_lasthash(args->dp,
> blk->bp, NULL);
>
> --
> 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] 8+ messages in thread
* Re: [PATCH 2/2] xfs: check da node magic in _node_lookup_int
2018-07-31 23:21 ` [PATCH 2/2] xfs: check da node magic in _node_lookup_int Darrick J. Wong
@ 2018-08-01 12:07 ` Brian Foster
2018-08-01 12:12 ` Carlos Maiolino
1 sibling, 0 replies; 8+ messages in thread
From: Brian Foster @ 2018-08-01 12:07 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-xfs
On Tue, Jul 31, 2018 at 04:21:00PM -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>
> ---
Reviewed-by: Brian Foster <bfoster@redhat.com>
> fs/xfs/libxfs/xfs_da_btree.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
>
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index 8ffe17b223da..376bee94b5dd 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -1523,8 +1523,10 @@ xfs_da3_node_lookup_int(
> break;
> }
>
> - blk->magic = XFS_DA_NODE_MAGIC;
> + if (magic != XFS_DA_NODE_MAGIC && magic != XFS_DA3_NODE_MAGIC)
> + return -EFSCORRUPTED;
>
> + blk->magic = XFS_DA_NODE_MAGIC;
>
> /*
> * Search an intermediate node for a match.
>
> --
> 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] 8+ messages in thread
* Re: [PATCH 1/2] xfs: use a local variable for magic number in xfs_da3_node_lookup_int
2018-07-31 23:20 [PATCH 1/2] xfs: use a local variable for magic number in xfs_da3_node_lookup_int Darrick J. Wong
2018-07-31 23:21 ` [PATCH 2/2] xfs: check da node magic in _node_lookup_int Darrick J. Wong
2018-08-01 12:07 ` [PATCH 1/2] xfs: use a local variable for magic number in xfs_da3_node_lookup_int Brian Foster
@ 2018-08-01 12:10 ` Carlos Maiolino
2 siblings, 0 replies; 8+ messages in thread
From: Carlos Maiolino @ 2018-08-01 12:10 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-xfs
On Tue, Jul 31, 2018 at 04:20:54PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Use a local variable for the block magic number checks instead of
> abusing blk->magic.
>
Looks good
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
> fs/xfs/libxfs/xfs_da_btree.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
>
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index 9efbd2038ffb..8ffe17b223da 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -1481,6 +1481,7 @@ xfs_da3_node_lookup_int(
> int error;
> int retval;
> unsigned int expected_level = 0;
> + uint16_t magic;
> struct xfs_inode *dp = state->args->dp;
>
> args = state->args;
> @@ -1505,17 +1506,17 @@ xfs_da3_node_lookup_int(
> return error;
> }
> curr = blk->bp->b_addr;
> - blk->magic = be16_to_cpu(curr->magic);
> + magic = be16_to_cpu(curr->magic);
>
> - if (blk->magic == XFS_ATTR_LEAF_MAGIC ||
> - blk->magic == XFS_ATTR3_LEAF_MAGIC) {
> + if (magic == XFS_ATTR_LEAF_MAGIC ||
> + magic == XFS_ATTR3_LEAF_MAGIC) {
> blk->magic = XFS_ATTR_LEAF_MAGIC;
> blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL);
> break;
> }
>
> - if (blk->magic == XFS_DIR2_LEAFN_MAGIC ||
> - blk->magic == XFS_DIR3_LEAFN_MAGIC) {
> + if (magic == XFS_DIR2_LEAFN_MAGIC ||
> + magic == XFS_DIR3_LEAFN_MAGIC) {
> blk->magic = XFS_DIR2_LEAFN_MAGIC;
> blk->hashval = xfs_dir2_leaf_lasthash(args->dp,
> blk->bp, NULL);
>
> --
> 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
--
Carlos
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] xfs: check da node magic in _node_lookup_int
2018-07-31 23:21 ` [PATCH 2/2] xfs: check da node magic in _node_lookup_int Darrick J. Wong
2018-08-01 12:07 ` Brian Foster
@ 2018-08-01 12:12 ` Carlos Maiolino
2018-08-01 14:15 ` Darrick J. Wong
1 sibling, 1 reply; 8+ messages in thread
From: Carlos Maiolino @ 2018-08-01 12:12 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-xfs
On Tue, Jul 31, 2018 at 04:21:00PM -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>
The patch looks good, but why wouldn't merge it into the previous one?
Both patches look reasonable to fit into a single one.
But, merging both or not.
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> ---
> fs/xfs/libxfs/xfs_da_btree.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
>
> diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> index 8ffe17b223da..376bee94b5dd 100644
> --- a/fs/xfs/libxfs/xfs_da_btree.c
> +++ b/fs/xfs/libxfs/xfs_da_btree.c
> @@ -1523,8 +1523,10 @@ xfs_da3_node_lookup_int(
> break;
> }
>
> - blk->magic = XFS_DA_NODE_MAGIC;
> + if (magic != XFS_DA_NODE_MAGIC && magic != XFS_DA3_NODE_MAGIC)
> + return -EFSCORRUPTED;
>
> + blk->magic = XFS_DA_NODE_MAGIC;
>
> /*
> * Search an intermediate node for a match.
>
> --
> 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
--
Carlos
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/2] xfs: check da node magic in _node_lookup_int
2018-08-01 12:12 ` Carlos Maiolino
@ 2018-08-01 14:15 ` Darrick J. Wong
2018-08-02 9:38 ` Carlos Maiolino
0 siblings, 1 reply; 8+ messages in thread
From: Darrick J. Wong @ 2018-08-01 14:15 UTC (permalink / raw)
To: linux-xfs
On Wed, Aug 01, 2018 at 02:12:02PM +0200, Carlos Maiolino wrote:
> On Tue, Jul 31, 2018 at 04:21:00PM -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>
>
> The patch looks good, but why wouldn't merge it into the previous one?
>
> Both patches look reasonable to fit into a single one.
>
> But, merging both or not.
They're different logical changes to the source code -- one refactors to
use a local variable, the other adds extra checks.
--D
> Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
>
> > ---
> > fs/xfs/libxfs/xfs_da_btree.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> >
> > diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> > index 8ffe17b223da..376bee94b5dd 100644
> > --- a/fs/xfs/libxfs/xfs_da_btree.c
> > +++ b/fs/xfs/libxfs/xfs_da_btree.c
> > @@ -1523,8 +1523,10 @@ xfs_da3_node_lookup_int(
> > break;
> > }
> >
> > - blk->magic = XFS_DA_NODE_MAGIC;
> > + if (magic != XFS_DA_NODE_MAGIC && magic != XFS_DA3_NODE_MAGIC)
> > + return -EFSCORRUPTED;
> >
> > + blk->magic = XFS_DA_NODE_MAGIC;
> >
> > /*
> > * Search an intermediate node for a match.
> >
> > --
> > 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
>
> --
> Carlos
> --
> 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] 8+ messages in thread
* Re: [PATCH 2/2] xfs: check da node magic in _node_lookup_int
2018-08-01 14:15 ` Darrick J. Wong
@ 2018-08-02 9:38 ` Carlos Maiolino
0 siblings, 0 replies; 8+ messages in thread
From: Carlos Maiolino @ 2018-08-02 9:38 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-xfs
On Wed, Aug 01, 2018 at 07:15:24AM -0700, Darrick J. Wong wrote:
> On Wed, Aug 01, 2018 at 02:12:02PM +0200, Carlos Maiolino wrote:
> > On Tue, Jul 31, 2018 at 04:21:00PM -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>
> >
> > The patch looks good, but why wouldn't merge it into the previous one?
> >
> > Both patches look reasonable to fit into a single one.
> >
> > But, merging both or not.
>
> They're different logical changes to the source code -- one refactors to
> use a local variable, the other adds extra checks.
I'm fine with it either way :)
>
> --D
>
> > Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
> >
> > > ---
> > > fs/xfs/libxfs/xfs_da_btree.c | 4 +++-
> > > 1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > >
> > > diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c
> > > index 8ffe17b223da..376bee94b5dd 100644
> > > --- a/fs/xfs/libxfs/xfs_da_btree.c
> > > +++ b/fs/xfs/libxfs/xfs_da_btree.c
> > > @@ -1523,8 +1523,10 @@ xfs_da3_node_lookup_int(
> > > break;
> > > }
> > >
> > > - blk->magic = XFS_DA_NODE_MAGIC;
> > > + if (magic != XFS_DA_NODE_MAGIC && magic != XFS_DA3_NODE_MAGIC)
> > > + return -EFSCORRUPTED;
> > >
> > > + blk->magic = XFS_DA_NODE_MAGIC;
> > >
> > > /*
> > > * Search an intermediate node for a match.
> > >
> > > --
> > > 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
> >
> > --
> > Carlos
> > --
> > 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
--
Carlos
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-08-02 11:28 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-31 23:20 [PATCH 1/2] xfs: use a local variable for magic number in xfs_da3_node_lookup_int Darrick J. Wong
2018-07-31 23:21 ` [PATCH 2/2] xfs: check da node magic in _node_lookup_int Darrick J. Wong
2018-08-01 12:07 ` Brian Foster
2018-08-01 12:12 ` Carlos Maiolino
2018-08-01 14:15 ` Darrick J. Wong
2018-08-02 9:38 ` Carlos Maiolino
2018-08-01 12:07 ` [PATCH 1/2] xfs: use a local variable for magic number in xfs_da3_node_lookup_int Brian Foster
2018-08-01 12:10 ` Carlos Maiolino
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.