* [PATCH 0/4] xfsprogs: random fixes
@ 2020-02-05 0:46 Darrick J. Wong
2020-02-05 0:46 ` [PATCH 1/4] libxfs: re-sort libxfs_api_defs.h defines Darrick J. Wong
` (3 more replies)
0 siblings, 4 replies; 17+ messages in thread
From: Darrick J. Wong @ 2020-02-05 0:46 UTC (permalink / raw)
To: sandeen, darrick.wong; +Cc: linux-xfs
Hi all,
Here's the usual pile of xfsprogs cleanups and fixes.
If you're going to start using this mess, you probably ought to just
pull from my git trees, which are linked below.
This is an extraordinary way to destroy everything. Enjoy!
Comments and questions are, as always, welcome.
--D
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=random-fixes
fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=random-fixes
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 1/4] libxfs: re-sort libxfs_api_defs.h defines
2020-02-05 0:46 [PATCH 0/4] xfsprogs: random fixes Darrick J. Wong
@ 2020-02-05 0:46 ` Darrick J. Wong
2020-02-05 2:11 ` Chaitanya Kulkarni
` (2 more replies)
2020-02-05 0:46 ` [PATCH 2/4] libfrog: remove libxfs.h dependencies in fsgeom.c and linux.c Darrick J. Wong
` (2 subsequent siblings)
3 siblings, 3 replies; 17+ messages in thread
From: Darrick J. Wong @ 2020-02-05 0:46 UTC (permalink / raw)
To: sandeen, darrick.wong; +Cc: linux-xfs
From: Darrick J. Wong <darrick.wong@oracle.com>
Re-fix the sorting in this file.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
libxfs/libxfs_api_defs.h | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
index c7fa1607..6e09685b 100644
--- a/libxfs/libxfs_api_defs.h
+++ b/libxfs/libxfs_api_defs.h
@@ -93,6 +93,7 @@
#define xfs_dqblk_repair libxfs_dqblk_repair
#define xfs_dquot_verify libxfs_dquot_verify
+#define xfs_finobt_calc_reserves libxfs_finobt_calc_reserves
#define xfs_free_extent libxfs_free_extent
#define xfs_fs_geometry libxfs_fs_geometry
#define xfs_highbit32 libxfs_highbit32
@@ -118,13 +119,16 @@
#define xfs_perag_put libxfs_perag_put
#define xfs_prealloc_blocks libxfs_prealloc_blocks
+#define xfs_read_agf libxfs_read_agf
#define xfs_refc_block libxfs_refc_block
+#define xfs_refcountbt_calc_reserves libxfs_refcountbt_calc_reserves
#define xfs_refcountbt_init_cursor libxfs_refcountbt_init_cursor
#define xfs_refcountbt_maxrecs libxfs_refcountbt_maxrecs
#define xfs_refcount_get_rec libxfs_refcount_get_rec
#define xfs_refcount_lookup_le libxfs_refcount_lookup_le
#define xfs_rmap_alloc libxfs_rmap_alloc
+#define xfs_rmapbt_calc_reserves libxfs_rmapbt_calc_reserves
#define xfs_rmapbt_init_cursor libxfs_rmapbt_init_cursor
#define xfs_rmapbt_maxrecs libxfs_rmapbt_maxrecs
#define xfs_rmap_compare libxfs_rmap_compare
@@ -176,9 +180,6 @@
#define xfs_verify_rtbno libxfs_verify_rtbno
#define xfs_zero_extent libxfs_zero_extent
-#define xfs_refcountbt_calc_reserves libxfs_refcountbt_calc_reserves
-#define xfs_finobt_calc_reserves libxfs_finobt_calc_reserves
-#define xfs_rmapbt_calc_reserves libxfs_rmapbt_calc_reserves
-#define xfs_read_agf libxfs_read_agf
+/* Please keep this list alphabetized. */
#endif /* __LIBXFS_API_DEFS_H__ */
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 2/4] libfrog: remove libxfs.h dependencies in fsgeom.c and linux.c
2020-02-05 0:46 [PATCH 0/4] xfsprogs: random fixes Darrick J. Wong
2020-02-05 0:46 ` [PATCH 1/4] libxfs: re-sort libxfs_api_defs.h defines Darrick J. Wong
@ 2020-02-05 0:46 ` Darrick J. Wong
2020-02-05 5:28 ` Allison Collins
2020-02-17 13:46 ` Christoph Hellwig
2020-02-05 0:46 ` [PATCH 3/4] xfs_repair: refactor attr root block pointer check Darrick J. Wong
2020-02-05 0:46 ` [PATCH 4/4] xfs_repair: don't corrupt a attr fork da3 node when clearing forw/back Darrick J. Wong
3 siblings, 2 replies; 17+ messages in thread
From: Darrick J. Wong @ 2020-02-05 0:46 UTC (permalink / raw)
To: sandeen, darrick.wong; +Cc: linux-xfs, Eric Sandeen
From: Darrick J. Wong <darrick.wong@oracle.com>
libfrog isn't supposed to depend on libxfs, so don't include the header
file in the libfrog source code.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
---
libfrog/fsgeom.c | 4 +++-
libfrog/linux.c | 4 ++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/libfrog/fsgeom.c b/libfrog/fsgeom.c
index 19a4911f..bd93924e 100644
--- a/libfrog/fsgeom.c
+++ b/libfrog/fsgeom.c
@@ -2,7 +2,9 @@
/*
* Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
*/
-#include "libxfs.h"
+#include "platform_defs.h"
+#include "xfs.h"
+#include "bitops.h"
#include "fsgeom.h"
#include "util.h"
diff --git a/libfrog/linux.c b/libfrog/linux.c
index 79bd79eb..41a168b4 100644
--- a/libfrog/linux.c
+++ b/libfrog/linux.c
@@ -9,8 +9,8 @@
#include <sys/ioctl.h>
#include <sys/sysinfo.h>
-#include "libxfs_priv.h"
-#include "xfs_fs.h"
+#include "platform_defs.h"
+#include "xfs.h"
#include "init.h"
extern char *progname;
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 3/4] xfs_repair: refactor attr root block pointer check
2020-02-05 0:46 [PATCH 0/4] xfsprogs: random fixes Darrick J. Wong
2020-02-05 0:46 ` [PATCH 1/4] libxfs: re-sort libxfs_api_defs.h defines Darrick J. Wong
2020-02-05 0:46 ` [PATCH 2/4] libfrog: remove libxfs.h dependencies in fsgeom.c and linux.c Darrick J. Wong
@ 2020-02-05 0:46 ` Darrick J. Wong
2020-02-05 5:28 ` Allison Collins
` (2 more replies)
2020-02-05 0:46 ` [PATCH 4/4] xfs_repair: don't corrupt a attr fork da3 node when clearing forw/back Darrick J. Wong
3 siblings, 3 replies; 17+ messages in thread
From: Darrick J. Wong @ 2020-02-05 0:46 UTC (permalink / raw)
To: sandeen, darrick.wong; +Cc: linux-xfs
From: Darrick J. Wong <darrick.wong@oracle.com>
In process_longform_attr, replace the agcount check with a call to the
fsblock verification function in libxfs. Now we can also catch blocks
that point to static FS metadata.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
repair/attr_repair.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/repair/attr_repair.c b/repair/attr_repair.c
index 9a44f610..7b26df33 100644
--- a/repair/attr_repair.c
+++ b/repair/attr_repair.c
@@ -980,21 +980,21 @@ process_longform_attr(
*repair = 0;
bno = blkmap_get(blkmap, 0);
-
- if ( bno == NULLFSBLOCK ) {
+ if (bno == NULLFSBLOCK) {
if (dip->di_aformat == XFS_DINODE_FMT_EXTENTS &&
be16_to_cpu(dip->di_anextents) == 0)
return(0); /* the kernel can handle this state */
do_warn(
_("block 0 of inode %" PRIu64 " attribute fork is missing\n"),
ino);
- return(1);
+ return 1;
}
+
/* FIX FOR bug 653709 -- EKN */
- if (mp->m_sb.sb_agcount < XFS_FSB_TO_AGNO(mp, bno)) {
+ if (!xfs_verify_fsbno(mp, bno)) {
do_warn(
_("agno of attribute fork of inode %" PRIu64 " out of regular partition\n"), ino);
- return(1);
+ return 1;
}
bp = libxfs_readbuf(mp->m_dev, XFS_FSB_TO_DADDR(mp, bno),
^ permalink raw reply related [flat|nested] 17+ messages in thread
* [PATCH 4/4] xfs_repair: don't corrupt a attr fork da3 node when clearing forw/back
2020-02-05 0:46 [PATCH 0/4] xfsprogs: random fixes Darrick J. Wong
` (2 preceding siblings ...)
2020-02-05 0:46 ` [PATCH 3/4] xfs_repair: refactor attr root block pointer check Darrick J. Wong
@ 2020-02-05 0:46 ` Darrick J. Wong
2020-02-05 5:29 ` Allison Collins
2020-02-17 13:48 ` Christoph Hellwig
3 siblings, 2 replies; 17+ messages in thread
From: Darrick J. Wong @ 2020-02-05 0:46 UTC (permalink / raw)
To: sandeen, darrick.wong; +Cc: linux-xfs
From: Darrick J. Wong <darrick.wong@oracle.com>
In process_longform_attr, we enforce that the root block of the
attribute index must have both forw or back pointers set to zero.
Unfortunately, the code that nulls out the pointers is not aware that
the root block could be in da3 node format.
This leads to corruption of da3 root node blocks because the functions
that convert attr3 leaf headers to and from the ondisk structures
perform some interpretation of firstused on what they think is an attr1
leaf block.
Found by using xfs/402 to fuzz hdr.info.hdr.forw.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
repair/attr_repair.c | 181 ++++++++++++++++++++++++++++++++------------------
1 file changed, 117 insertions(+), 64 deletions(-)
diff --git a/repair/attr_repair.c b/repair/attr_repair.c
index 7b26df33..535fcfbb 100644
--- a/repair/attr_repair.c
+++ b/repair/attr_repair.c
@@ -952,6 +952,106 @@ _("wrong FS UUID, inode %" PRIu64 " attr block %" PRIu64 "\n"),
return 0;
}
+static int
+process_longform_leaf_root(
+ struct xfs_mount *mp,
+ xfs_ino_t ino,
+ struct xfs_dinode *dip,
+ struct blkmap *blkmap,
+ int *repair,
+ struct xfs_buf *bp)
+{
+ struct xfs_attr3_icleaf_hdr leafhdr;
+ xfs_dahash_t next_hashval;
+ int badness;
+ int repairlinks = 0;
+
+ /*
+ * check sibling pointers in leaf block or root block 0 before
+ * we have to release the btree block
+ */
+ xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &leafhdr, bp->b_addr);
+ if (leafhdr.forw != 0 || leafhdr.back != 0) {
+ if (!no_modify) {
+ do_warn(
+_("clearing forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"),
+ ino);
+ repairlinks = 1;
+ leafhdr.forw = 0;
+ leafhdr.back = 0;
+ xfs_attr3_leaf_hdr_to_disk(mp->m_attr_geo, bp->b_addr,
+ &leafhdr);
+ } else {
+ do_warn(
+_("would clear forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), ino);
+ }
+ }
+
+ badness = process_leaf_attr_block(mp, bp->b_addr, 0, ino, blkmap, 0,
+ &next_hashval, repair);
+ if (badness) {
+ *repair = 0;
+ /* the block is bad. lose the attribute fork. */
+ libxfs_putbuf(bp);
+ return 1;
+ }
+
+ *repair = *repair || repairlinks;
+
+ if (*repair && !no_modify)
+ libxfs_writebuf(bp, 0);
+ else
+ libxfs_putbuf(bp);
+
+ return 0;
+}
+
+static int
+process_longform_da_root(
+ struct xfs_mount *mp,
+ xfs_ino_t ino,
+ struct xfs_dinode *dip,
+ struct blkmap *blkmap,
+ int *repair,
+ struct xfs_buf *bp)
+{
+ struct xfs_da3_icnode_hdr da3_hdr;
+ int repairlinks = 0;
+ int error;
+
+ libxfs_da3_node_hdr_from_disk(mp, &da3_hdr, bp->b_addr);
+ /*
+ * check sibling pointers in leaf block or root block 0 before
+ * we have to release the btree block
+ */
+ if (da3_hdr.forw != 0 || da3_hdr.back != 0) {
+ if (!no_modify) {
+ do_warn(
+_("clearing forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"),
+ ino);
+
+ repairlinks = 1;
+ da3_hdr.forw = 0;
+ da3_hdr.back = 0;
+ xfs_da3_node_hdr_to_disk(mp, bp->b_addr, &da3_hdr);
+ } else {
+ do_warn(
+_("would clear forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), ino);
+ }
+ }
+
+ /* must do this now, to release block 0 before the traversal */
+ if ((*repair || repairlinks) && !no_modify) {
+ *repair = 1;
+ libxfs_writebuf(bp, 0);
+ } else
+ libxfs_putbuf(bp);
+ error = process_node_attr(mp, ino, dip, blkmap); /* + repair */
+ if (error)
+ *repair = 0;
+ return error;
+}
+
/*
* Start processing for a leaf or fuller btree.
* A leaf directory is one where the attribute fork is too big for
@@ -963,19 +1063,15 @@ _("wrong FS UUID, inode %" PRIu64 " attr block %" PRIu64 "\n"),
*/
static int
process_longform_attr(
- xfs_mount_t *mp,
- xfs_ino_t ino,
- xfs_dinode_t *dip,
- blkmap_t *blkmap,
- int *repair) /* out - 1 if something was fixed */
+ struct xfs_mount *mp,
+ xfs_ino_t ino,
+ struct xfs_dinode *dip,
+ struct blkmap *blkmap,
+ int *repair) /* out - 1 if something was fixed */
{
- xfs_attr_leafblock_t *leaf;
- xfs_fsblock_t bno;
- xfs_buf_t *bp;
- xfs_dahash_t next_hashval;
- int repairlinks = 0;
- struct xfs_attr3_icleaf_hdr leafhdr;
- int error;
+ xfs_fsblock_t bno;
+ struct xfs_buf *bp;
+ struct xfs_da_blkinfo *info;
*repair = 0;
@@ -1015,74 +1111,31 @@ process_longform_attr(
return 1;
}
- /* verify leaf block */
- leaf = bp->b_addr;
- xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &leafhdr, leaf);
-
- /* check sibling pointers in leaf block or root block 0 before
- * we have to release the btree block
- */
- if (leafhdr.forw != 0 || leafhdr.back != 0) {
- if (!no_modify) {
- do_warn(
- _("clearing forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"),
- ino);
- repairlinks = 1;
- leafhdr.forw = 0;
- leafhdr.back = 0;
- xfs_attr3_leaf_hdr_to_disk(mp->m_attr_geo,
- leaf, &leafhdr);
- } else {
- do_warn(
- _("would clear forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), ino);
- }
- }
-
/*
* use magic number to tell us what type of attribute this is.
* it's possible to have a node or leaf attribute in either an
* extent format or btree format attribute fork.
*/
- switch (leafhdr.magic) {
+ info = bp->b_addr;
+ switch (be16_to_cpu(info->magic)) {
case XFS_ATTR_LEAF_MAGIC: /* leaf-form attribute */
case XFS_ATTR3_LEAF_MAGIC:
- if (process_leaf_attr_block(mp, leaf, 0, ino, blkmap,
- 0, &next_hashval, repair)) {
- *repair = 0;
- /* the block is bad. lose the attribute fork. */
- libxfs_putbuf(bp);
- return(1);
- }
- *repair = *repair || repairlinks;
- break;
-
+ return process_longform_leaf_root(mp, ino, dip, blkmap, repair,
+ bp);
case XFS_DA_NODE_MAGIC: /* btree-form attribute */
case XFS_DA3_NODE_MAGIC:
- /* must do this now, to release block 0 before the traversal */
- if ((*repair || repairlinks) && !no_modify) {
- *repair = 1;
- libxfs_writebuf(bp, 0);
- } else
- libxfs_putbuf(bp);
- error = process_node_attr(mp, ino, dip, blkmap); /* + repair */
- if (error)
- *repair = 0;
- return error;
+ return process_longform_da_root(mp, ino, dip, blkmap, repair,
+ bp);
default:
do_warn(
_("bad attribute leaf magic # %#x for dir ino %" PRIu64 "\n"),
- be16_to_cpu(leaf->hdr.info.magic), ino);
+ be16_to_cpu(info->magic), ino);
libxfs_putbuf(bp);
*repair = 0;
- return(1);
+ return 1;
}
- if (*repair && !no_modify)
- libxfs_writebuf(bp, 0);
- else
- libxfs_putbuf(bp);
-
- return(0); /* repair may be set */
+ return 0; /* should never get here */
}
^ permalink raw reply related [flat|nested] 17+ messages in thread
* Re: [PATCH 1/4] libxfs: re-sort libxfs_api_defs.h defines
2020-02-05 0:46 ` [PATCH 1/4] libxfs: re-sort libxfs_api_defs.h defines Darrick J. Wong
@ 2020-02-05 2:11 ` Chaitanya Kulkarni
2020-02-05 5:28 ` Allison Collins
2020-02-17 13:45 ` Christoph Hellwig
2 siblings, 0 replies; 17+ messages in thread
From: Chaitanya Kulkarni @ 2020-02-05 2:11 UTC (permalink / raw)
To: Darrick J. Wong, sandeen; +Cc: linux-xfs
Looks good.
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
On 02/04/2020 04:46 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong<darrick.wong@oracle.com>
>
> Re-fix the sorting in this file.
>
> Signed-off-by: Darrick J. Wong<darrick.wong@oracle.com>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/4] libxfs: re-sort libxfs_api_defs.h defines
2020-02-05 0:46 ` [PATCH 1/4] libxfs: re-sort libxfs_api_defs.h defines Darrick J. Wong
2020-02-05 2:11 ` Chaitanya Kulkarni
@ 2020-02-05 5:28 ` Allison Collins
2020-02-17 13:45 ` Christoph Hellwig
2 siblings, 0 replies; 17+ messages in thread
From: Allison Collins @ 2020-02-05 5:28 UTC (permalink / raw)
To: Darrick J. Wong, sandeen; +Cc: linux-xfs
On 2/4/20 5:46 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Re-fix the sorting in this file.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Looks ok to me
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
> ---
> libxfs/libxfs_api_defs.h | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
>
> diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
> index c7fa1607..6e09685b 100644
> --- a/libxfs/libxfs_api_defs.h
> +++ b/libxfs/libxfs_api_defs.h
> @@ -93,6 +93,7 @@
> #define xfs_dqblk_repair libxfs_dqblk_repair
> #define xfs_dquot_verify libxfs_dquot_verify
>
> +#define xfs_finobt_calc_reserves libxfs_finobt_calc_reserves
> #define xfs_free_extent libxfs_free_extent
> #define xfs_fs_geometry libxfs_fs_geometry
> #define xfs_highbit32 libxfs_highbit32
> @@ -118,13 +119,16 @@
> #define xfs_perag_put libxfs_perag_put
> #define xfs_prealloc_blocks libxfs_prealloc_blocks
>
> +#define xfs_read_agf libxfs_read_agf
> #define xfs_refc_block libxfs_refc_block
> +#define xfs_refcountbt_calc_reserves libxfs_refcountbt_calc_reserves
> #define xfs_refcountbt_init_cursor libxfs_refcountbt_init_cursor
> #define xfs_refcountbt_maxrecs libxfs_refcountbt_maxrecs
> #define xfs_refcount_get_rec libxfs_refcount_get_rec
> #define xfs_refcount_lookup_le libxfs_refcount_lookup_le
>
> #define xfs_rmap_alloc libxfs_rmap_alloc
> +#define xfs_rmapbt_calc_reserves libxfs_rmapbt_calc_reserves
> #define xfs_rmapbt_init_cursor libxfs_rmapbt_init_cursor
> #define xfs_rmapbt_maxrecs libxfs_rmapbt_maxrecs
> #define xfs_rmap_compare libxfs_rmap_compare
> @@ -176,9 +180,6 @@
> #define xfs_verify_rtbno libxfs_verify_rtbno
> #define xfs_zero_extent libxfs_zero_extent
>
> -#define xfs_refcountbt_calc_reserves libxfs_refcountbt_calc_reserves
> -#define xfs_finobt_calc_reserves libxfs_finobt_calc_reserves
> -#define xfs_rmapbt_calc_reserves libxfs_rmapbt_calc_reserves
> -#define xfs_read_agf libxfs_read_agf
> +/* Please keep this list alphabetized. */
>
> #endif /* __LIBXFS_API_DEFS_H__ */
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 2/4] libfrog: remove libxfs.h dependencies in fsgeom.c and linux.c
2020-02-05 0:46 ` [PATCH 2/4] libfrog: remove libxfs.h dependencies in fsgeom.c and linux.c Darrick J. Wong
@ 2020-02-05 5:28 ` Allison Collins
2020-02-17 13:46 ` Christoph Hellwig
1 sibling, 0 replies; 17+ messages in thread
From: Allison Collins @ 2020-02-05 5:28 UTC (permalink / raw)
To: Darrick J. Wong, sandeen; +Cc: linux-xfs, Eric Sandeen
On 2/4/20 5:46 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> libfrog isn't supposed to depend on libxfs, so don't include the header
> file in the libfrog source code.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Looks ok
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
> ---
> libfrog/fsgeom.c | 4 +++-
> libfrog/linux.c | 4 ++--
> 2 files changed, 5 insertions(+), 3 deletions(-)
>
>
> diff --git a/libfrog/fsgeom.c b/libfrog/fsgeom.c
> index 19a4911f..bd93924e 100644
> --- a/libfrog/fsgeom.c
> +++ b/libfrog/fsgeom.c
> @@ -2,7 +2,9 @@
> /*
> * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
> */
> -#include "libxfs.h"
> +#include "platform_defs.h"
> +#include "xfs.h"
> +#include "bitops.h"
> #include "fsgeom.h"
> #include "util.h"
>
> diff --git a/libfrog/linux.c b/libfrog/linux.c
> index 79bd79eb..41a168b4 100644
> --- a/libfrog/linux.c
> +++ b/libfrog/linux.c
> @@ -9,8 +9,8 @@
> #include <sys/ioctl.h>
> #include <sys/sysinfo.h>
>
> -#include "libxfs_priv.h"
> -#include "xfs_fs.h"
> +#include "platform_defs.h"
> +#include "xfs.h"
> #include "init.h"
>
> extern char *progname;
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/4] xfs_repair: refactor attr root block pointer check
2020-02-05 0:46 ` [PATCH 3/4] xfs_repair: refactor attr root block pointer check Darrick J. Wong
@ 2020-02-05 5:28 ` Allison Collins
2020-02-13 23:14 ` Eric Sandeen
2020-02-17 13:47 ` Christoph Hellwig
2 siblings, 0 replies; 17+ messages in thread
From: Allison Collins @ 2020-02-05 5:28 UTC (permalink / raw)
To: Darrick J. Wong, sandeen; +Cc: linux-xfs
On 2/4/20 5:46 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> In process_longform_attr, replace the agcount check with a call to the
> fsblock verification function in libxfs. Now we can also catch blocks
> that point to static FS metadata.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Ok, looks good
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
> ---
> repair/attr_repair.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
>
> diff --git a/repair/attr_repair.c b/repair/attr_repair.c
> index 9a44f610..7b26df33 100644
> --- a/repair/attr_repair.c
> +++ b/repair/attr_repair.c
> @@ -980,21 +980,21 @@ process_longform_attr(
> *repair = 0;
>
> bno = blkmap_get(blkmap, 0);
> -
> - if ( bno == NULLFSBLOCK ) {
> + if (bno == NULLFSBLOCK) {
> if (dip->di_aformat == XFS_DINODE_FMT_EXTENTS &&
> be16_to_cpu(dip->di_anextents) == 0)
> return(0); /* the kernel can handle this state */
> do_warn(
> _("block 0 of inode %" PRIu64 " attribute fork is missing\n"),
> ino);
> - return(1);
> + return 1;
> }
> +
> /* FIX FOR bug 653709 -- EKN */
> - if (mp->m_sb.sb_agcount < XFS_FSB_TO_AGNO(mp, bno)) {
> + if (!xfs_verify_fsbno(mp, bno)) {
> do_warn(
> _("agno of attribute fork of inode %" PRIu64 " out of regular partition\n"), ino);
> - return(1);
> + return 1;
> }
>
> bp = libxfs_readbuf(mp->m_dev, XFS_FSB_TO_DADDR(mp, bno),
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4/4] xfs_repair: don't corrupt a attr fork da3 node when clearing forw/back
2020-02-05 0:46 ` [PATCH 4/4] xfs_repair: don't corrupt a attr fork da3 node when clearing forw/back Darrick J. Wong
@ 2020-02-05 5:29 ` Allison Collins
2020-02-05 5:59 ` Darrick J. Wong
2020-02-17 13:48 ` Christoph Hellwig
1 sibling, 1 reply; 17+ messages in thread
From: Allison Collins @ 2020-02-05 5:29 UTC (permalink / raw)
To: Darrick J. Wong, sandeen; +Cc: linux-xfs
On 2/4/20 5:46 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> In process_longform_attr, we enforce that the root block of the
> attribute index must have both forw or back pointers set to zero.
> Unfortunately, the code that nulls out the pointers is not aware that
> the root block could be in da3 node format.
>
> This leads to corruption of da3 root node blocks because the functions
> that convert attr3 leaf headers to and from the ondisk structures
> perform some interpretation of firstused on what they think is an attr1
> leaf block.
>
> Found by using xfs/402 to fuzz hdr.info.hdr.forw.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> repair/attr_repair.c | 181 ++++++++++++++++++++++++++++++++------------------
> 1 file changed, 117 insertions(+), 64 deletions(-)
>
>
> diff --git a/repair/attr_repair.c b/repair/attr_repair.c
> index 7b26df33..535fcfbb 100644
> --- a/repair/attr_repair.c
> +++ b/repair/attr_repair.c
> @@ -952,6 +952,106 @@ _("wrong FS UUID, inode %" PRIu64 " attr block %" PRIu64 "\n"),
> return 0;
> }
>
> +static int
> +process_longform_leaf_root(
> + struct xfs_mount *mp,
> + xfs_ino_t ino,
> + struct xfs_dinode *dip,
> + struct blkmap *blkmap,
> + int *repair,
> + struct xfs_buf *bp)
> +{
> + struct xfs_attr3_icleaf_hdr leafhdr;
> + xfs_dahash_t next_hashval;
> + int badness;
"badness" pretty much just looks like "error" here? Or is it different
in some way?
> + int repairlinks = 0;
> +
> + /*
> + * check sibling pointers in leaf block or root block 0 before
> + * we have to release the btree block
> + */
> + xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &leafhdr, bp->b_addr);
> + if (leafhdr.forw != 0 || leafhdr.back != 0) {
> + if (!no_modify) {
> + do_warn(
> +_("clearing forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"),
> + ino);
> + repairlinks = 1;
> + leafhdr.forw = 0;
> + leafhdr.back = 0;
> + xfs_attr3_leaf_hdr_to_disk(mp->m_attr_geo, bp->b_addr,
> + &leafhdr);
> + } else {
> + do_warn(
> +_("would clear forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), ino);
> + }
> + }
> +
> + badness = process_leaf_attr_block(mp, bp->b_addr, 0, ino, blkmap, 0,
> + &next_hashval, repair);
> + if (badness) {
> + *repair = 0;
> + /* the block is bad. lose the attribute fork. */
> + libxfs_putbuf(bp);
> + return 1;
> + }
> +
> + *repair = *repair || repairlinks;
> +
> + if (*repair && !no_modify)
> + libxfs_writebuf(bp, 0);
> + else
> + libxfs_putbuf(bp);
> +
> + return 0;
> +}
> +
> +static int
> +process_longform_da_root(
> + struct xfs_mount *mp,
> + xfs_ino_t ino,
> + struct xfs_dinode *dip,
> + struct blkmap *blkmap,
> + int *repair,
> + struct xfs_buf *bp)
> +{
> + struct xfs_da3_icnode_hdr da3_hdr;
> + int repairlinks = 0;
> + int error;
> +
> + libxfs_da3_node_hdr_from_disk(mp, &da3_hdr, bp->b_addr);
> + /*
> + * check sibling pointers in leaf block or root block 0 before
> + * we have to release the btree block
> + */
> + if (da3_hdr.forw != 0 || da3_hdr.back != 0) {
> + if (!no_modify) {
> + do_warn(
> +_("clearing forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"),
> + ino);
> +
> + repairlinks = 1;
> + da3_hdr.forw = 0;
> + da3_hdr.back = 0;
> + xfs_da3_node_hdr_to_disk(mp, bp->b_addr, &da3_hdr);
> + } else {
> + do_warn(
> +_("would clear forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), ino);
> + }
> + }
> +
> + /* must do this now, to release block 0 before the traversal */
Did you mean to reference *repair here without setting it? I guess it
was like that from the code it was taken from, but it makes it looks
like repair is both an in and an out. I wonder if it's really needed in
the check below?
Allison
> + if ((*repair || repairlinks) && !no_modify) {
> + *repair = 1;
> + libxfs_writebuf(bp, 0);
> + } else
> + libxfs_putbuf(bp);
> + error = process_node_attr(mp, ino, dip, blkmap); /* + repair */
> + if (error)
> + *repair = 0;
> + return error;
> +}
> +
> /*
> * Start processing for a leaf or fuller btree.
> * A leaf directory is one where the attribute fork is too big for
> @@ -963,19 +1063,15 @@ _("wrong FS UUID, inode %" PRIu64 " attr block %" PRIu64 "\n"),
> */
> static int
> process_longform_attr(
> - xfs_mount_t *mp,
> - xfs_ino_t ino,
> - xfs_dinode_t *dip,
> - blkmap_t *blkmap,
> - int *repair) /* out - 1 if something was fixed */
> + struct xfs_mount *mp,
> + xfs_ino_t ino,
> + struct xfs_dinode *dip,
> + struct blkmap *blkmap,
> + int *repair) /* out - 1 if something was fixed */
> {
> - xfs_attr_leafblock_t *leaf;
> - xfs_fsblock_t bno;
> - xfs_buf_t *bp;
> - xfs_dahash_t next_hashval;
> - int repairlinks = 0;
> - struct xfs_attr3_icleaf_hdr leafhdr;
> - int error;
> + xfs_fsblock_t bno;
> + struct xfs_buf *bp;
> + struct xfs_da_blkinfo *info;
>
> *repair = 0;
>
> @@ -1015,74 +1111,31 @@ process_longform_attr(
> return 1;
> }
>
> - /* verify leaf block */
> - leaf = bp->b_addr;
> - xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &leafhdr, leaf);
> -
> - /* check sibling pointers in leaf block or root block 0 before
> - * we have to release the btree block
> - */
> - if (leafhdr.forw != 0 || leafhdr.back != 0) {
> - if (!no_modify) {
> - do_warn(
> - _("clearing forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"),
> - ino);
> - repairlinks = 1;
> - leafhdr.forw = 0;
> - leafhdr.back = 0;
> - xfs_attr3_leaf_hdr_to_disk(mp->m_attr_geo,
> - leaf, &leafhdr);
> - } else {
> - do_warn(
> - _("would clear forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), ino);
> - }
> - }
> -
> /*
> * use magic number to tell us what type of attribute this is.
> * it's possible to have a node or leaf attribute in either an
> * extent format or btree format attribute fork.
> */
> - switch (leafhdr.magic) {
> + info = bp->b_addr;
> + switch (be16_to_cpu(info->magic)) {
> case XFS_ATTR_LEAF_MAGIC: /* leaf-form attribute */
> case XFS_ATTR3_LEAF_MAGIC:
> - if (process_leaf_attr_block(mp, leaf, 0, ino, blkmap,
> - 0, &next_hashval, repair)) {
> - *repair = 0;
> - /* the block is bad. lose the attribute fork. */
> - libxfs_putbuf(bp);
> - return(1);
> - }
> - *repair = *repair || repairlinks;
> - break;
> -
> + return process_longform_leaf_root(mp, ino, dip, blkmap, repair,
> + bp);
> case XFS_DA_NODE_MAGIC: /* btree-form attribute */
> case XFS_DA3_NODE_MAGIC:
> - /* must do this now, to release block 0 before the traversal */
> - if ((*repair || repairlinks) && !no_modify) {
> - *repair = 1;
> - libxfs_writebuf(bp, 0);
> - } else
> - libxfs_putbuf(bp);
> - error = process_node_attr(mp, ino, dip, blkmap); /* + repair */
> - if (error)
> - *repair = 0;
> - return error;
> + return process_longform_da_root(mp, ino, dip, blkmap, repair,
> + bp);
> default:
> do_warn(
> _("bad attribute leaf magic # %#x for dir ino %" PRIu64 "\n"),
> - be16_to_cpu(leaf->hdr.info.magic), ino);
> + be16_to_cpu(info->magic), ino);
> libxfs_putbuf(bp);
> *repair = 0;
> - return(1);
> + return 1;
> }
>
> - if (*repair && !no_modify)
> - libxfs_writebuf(bp, 0);
> - else
> - libxfs_putbuf(bp);
> -
> - return(0); /* repair may be set */
> + return 0; /* should never get here */
> }
>
>
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4/4] xfs_repair: don't corrupt a attr fork da3 node when clearing forw/back
2020-02-05 5:29 ` Allison Collins
@ 2020-02-05 5:59 ` Darrick J. Wong
0 siblings, 0 replies; 17+ messages in thread
From: Darrick J. Wong @ 2020-02-05 5:59 UTC (permalink / raw)
To: Allison Collins; +Cc: sandeen, linux-xfs
On Tue, Feb 04, 2020 at 10:29:26PM -0700, Allison Collins wrote:
>
>
> On 2/4/20 5:46 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> >
> > In process_longform_attr, we enforce that the root block of the
> > attribute index must have both forw or back pointers set to zero.
> > Unfortunately, the code that nulls out the pointers is not aware that
> > the root block could be in da3 node format.
> >
> > This leads to corruption of da3 root node blocks because the functions
> > that convert attr3 leaf headers to and from the ondisk structures
> > perform some interpretation of firstused on what they think is an attr1
> > leaf block.
> >
> > Found by using xfs/402 to fuzz hdr.info.hdr.forw.
> >
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > repair/attr_repair.c | 181 ++++++++++++++++++++++++++++++++------------------
> > 1 file changed, 117 insertions(+), 64 deletions(-)
> >
> >
> > diff --git a/repair/attr_repair.c b/repair/attr_repair.c
> > index 7b26df33..535fcfbb 100644
> > --- a/repair/attr_repair.c
> > +++ b/repair/attr_repair.c
> > @@ -952,6 +952,106 @@ _("wrong FS UUID, inode %" PRIu64 " attr block %" PRIu64 "\n"),
> > return 0;
> > }
> > +static int
> > +process_longform_leaf_root(
> > + struct xfs_mount *mp,
> > + xfs_ino_t ino,
> > + struct xfs_dinode *dip,
> > + struct blkmap *blkmap,
> > + int *repair,
> > + struct xfs_buf *bp)
> > +{
> > + struct xfs_attr3_icleaf_hdr leafhdr;
> > + xfs_dahash_t next_hashval;
> > + int badness;
> "badness" pretty much just looks like "error" here? Or is it different in
> some way?
The return value for process_leaf_attr_block is 1 if the attr block is
bad and 0 for the attr block is ok. It's not the usual -EFUBAR error
codes that we use in many other parts of xfs.
> > + int repairlinks = 0;
> > +
> > + /*
> > + * check sibling pointers in leaf block or root block 0 before
> > + * we have to release the btree block
> > + */
> > + xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &leafhdr, bp->b_addr);
> > + if (leafhdr.forw != 0 || leafhdr.back != 0) {
> > + if (!no_modify) {
> > + do_warn(
> > +_("clearing forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"),
> > + ino);
> > + repairlinks = 1;
> > + leafhdr.forw = 0;
> > + leafhdr.back = 0;
> > + xfs_attr3_leaf_hdr_to_disk(mp->m_attr_geo, bp->b_addr,
> > + &leafhdr);
> > + } else {
> > + do_warn(
> > +_("would clear forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), ino);
> > + }
> > + }
> > +
> > + badness = process_leaf_attr_block(mp, bp->b_addr, 0, ino, blkmap, 0,
> > + &next_hashval, repair);
> > + if (badness) {
> > + *repair = 0;
> > + /* the block is bad. lose the attribute fork. */
> > + libxfs_putbuf(bp);
> > + return 1;
> > + }
> > +
> > + *repair = *repair || repairlinks;
> > +
> > + if (*repair && !no_modify)
> > + libxfs_writebuf(bp, 0);
> > + else
> > + libxfs_putbuf(bp);
> > +
> > + return 0;
> > +}
> > +
> > +static int
> > +process_longform_da_root(
> > + struct xfs_mount *mp,
> > + xfs_ino_t ino,
> > + struct xfs_dinode *dip,
> > + struct blkmap *blkmap,
> > + int *repair,
> > + struct xfs_buf *bp)
> > +{
> > + struct xfs_da3_icnode_hdr da3_hdr;
> > + int repairlinks = 0;
> > + int error;
> > +
> > + libxfs_da3_node_hdr_from_disk(mp, &da3_hdr, bp->b_addr);
> > + /*
> > + * check sibling pointers in leaf block or root block 0 before
> > + * we have to release the btree block
> > + */
> > + if (da3_hdr.forw != 0 || da3_hdr.back != 0) {
> > + if (!no_modify) {
> > + do_warn(
> > +_("clearing forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"),
> > + ino);
> > +
> > + repairlinks = 1;
> > + da3_hdr.forw = 0;
> > + da3_hdr.back = 0;
> > + xfs_da3_node_hdr_to_disk(mp, bp->b_addr, &da3_hdr);
> > + } else {
> > + do_warn(
> > +_("would clear forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), ino);
> > + }
> > + }
> > +
> > + /* must do this now, to release block 0 before the traversal */
> Did you mean to reference *repair here without setting it? I guess it was
> like that from the code it was taken from, but it makes it looks like repair
> is both an in and an out. I wonder if it's really needed in the check
> below?
*repair is passed from a stack variable in process_inode_attr_fork ->
process_attributes -> process_longform_attr. It's initialized properly,
but the code doesn't make it easy to figure that out since that's three
functions up in the call stack and anyone is allowed to mess with it.
One of the grottier bits of xfs_repair is that the return values for
those functions also have meaning...I think return 1 means "zap this
whole thing" vs. *repair ==1 means "we fixed it".
--D
>
> Allison
>
> > + if ((*repair || repairlinks) && !no_modify) {
> > + *repair = 1;
> > + libxfs_writebuf(bp, 0);
> > + } else
> > + libxfs_putbuf(bp);
> > + error = process_node_attr(mp, ino, dip, blkmap); /* + repair */
> > + if (error)
> > + *repair = 0;
> > + return error;
> > +}
> > +
> > /*
> > * Start processing for a leaf or fuller btree.
> > * A leaf directory is one where the attribute fork is too big for
> > @@ -963,19 +1063,15 @@ _("wrong FS UUID, inode %" PRIu64 " attr block %" PRIu64 "\n"),
> > */
> > static int
> > process_longform_attr(
> > - xfs_mount_t *mp,
> > - xfs_ino_t ino,
> > - xfs_dinode_t *dip,
> > - blkmap_t *blkmap,
> > - int *repair) /* out - 1 if something was fixed */
> > + struct xfs_mount *mp,
> > + xfs_ino_t ino,
> > + struct xfs_dinode *dip,
> > + struct blkmap *blkmap,
> > + int *repair) /* out - 1 if something was fixed */
> > {
> > - xfs_attr_leafblock_t *leaf;
> > - xfs_fsblock_t bno;
> > - xfs_buf_t *bp;
> > - xfs_dahash_t next_hashval;
> > - int repairlinks = 0;
> > - struct xfs_attr3_icleaf_hdr leafhdr;
> > - int error;
> > + xfs_fsblock_t bno;
> > + struct xfs_buf *bp;
> > + struct xfs_da_blkinfo *info;
> > *repair = 0;
> > @@ -1015,74 +1111,31 @@ process_longform_attr(
> > return 1;
> > }
> > - /* verify leaf block */
> > - leaf = bp->b_addr;
> > - xfs_attr3_leaf_hdr_from_disk(mp->m_attr_geo, &leafhdr, leaf);
> > -
> > - /* check sibling pointers in leaf block or root block 0 before
> > - * we have to release the btree block
> > - */
> > - if (leafhdr.forw != 0 || leafhdr.back != 0) {
> > - if (!no_modify) {
> > - do_warn(
> > - _("clearing forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"),
> > - ino);
> > - repairlinks = 1;
> > - leafhdr.forw = 0;
> > - leafhdr.back = 0;
> > - xfs_attr3_leaf_hdr_to_disk(mp->m_attr_geo,
> > - leaf, &leafhdr);
> > - } else {
> > - do_warn(
> > - _("would clear forw/back pointers in block 0 for attributes in inode %" PRIu64 "\n"), ino);
> > - }
> > - }
> > -
> > /*
> > * use magic number to tell us what type of attribute this is.
> > * it's possible to have a node or leaf attribute in either an
> > * extent format or btree format attribute fork.
> > */
> > - switch (leafhdr.magic) {
> > + info = bp->b_addr;
> > + switch (be16_to_cpu(info->magic)) {
> > case XFS_ATTR_LEAF_MAGIC: /* leaf-form attribute */
> > case XFS_ATTR3_LEAF_MAGIC:
> > - if (process_leaf_attr_block(mp, leaf, 0, ino, blkmap,
> > - 0, &next_hashval, repair)) {
> > - *repair = 0;
> > - /* the block is bad. lose the attribute fork. */
> > - libxfs_putbuf(bp);
> > - return(1);
> > - }
> > - *repair = *repair || repairlinks;
> > - break;
> > -
> > + return process_longform_leaf_root(mp, ino, dip, blkmap, repair,
> > + bp);
> > case XFS_DA_NODE_MAGIC: /* btree-form attribute */
> > case XFS_DA3_NODE_MAGIC:
> > - /* must do this now, to release block 0 before the traversal */
> > - if ((*repair || repairlinks) && !no_modify) {
> > - *repair = 1;
> > - libxfs_writebuf(bp, 0);
> > - } else
> > - libxfs_putbuf(bp);
> > - error = process_node_attr(mp, ino, dip, blkmap); /* + repair */
> > - if (error)
> > - *repair = 0;
> > - return error;
> > + return process_longform_da_root(mp, ino, dip, blkmap, repair,
> > + bp);
> > default:
> > do_warn(
> > _("bad attribute leaf magic # %#x for dir ino %" PRIu64 "\n"),
> > - be16_to_cpu(leaf->hdr.info.magic), ino);
> > + be16_to_cpu(info->magic), ino);
> > libxfs_putbuf(bp);
> > *repair = 0;
> > - return(1);
> > + return 1;
> > }
> > - if (*repair && !no_modify)
> > - libxfs_writebuf(bp, 0);
> > - else
> > - libxfs_putbuf(bp);
> > -
> > - return(0); /* repair may be set */
> > + return 0; /* should never get here */
> > }
> >
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/4] xfs_repair: refactor attr root block pointer check
2020-02-05 0:46 ` [PATCH 3/4] xfs_repair: refactor attr root block pointer check Darrick J. Wong
2020-02-05 5:28 ` Allison Collins
@ 2020-02-13 23:14 ` Eric Sandeen
2020-02-14 4:24 ` Darrick J. Wong
2020-02-17 13:47 ` Christoph Hellwig
2 siblings, 1 reply; 17+ messages in thread
From: Eric Sandeen @ 2020-02-13 23:14 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: linux-xfs
On 2/4/20 6:46 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> In process_longform_attr, replace the agcount check with a call to the
> fsblock verification function in libxfs. Now we can also catch blocks
> that point to static FS metadata.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> repair/attr_repair.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
>
> diff --git a/repair/attr_repair.c b/repair/attr_repair.c
> index 9a44f610..7b26df33 100644
> --- a/repair/attr_repair.c
> +++ b/repair/attr_repair.c
> @@ -980,21 +980,21 @@ process_longform_attr(
> *repair = 0;
>
> bno = blkmap_get(blkmap, 0);
> -
> - if ( bno == NULLFSBLOCK ) {
> + if (bno == NULLFSBLOCK) {
> if (dip->di_aformat == XFS_DINODE_FMT_EXTENTS &&
> be16_to_cpu(dip->di_anextents) == 0)
> return(0); /* the kernel can handle this state */
> do_warn(
> _("block 0 of inode %" PRIu64 " attribute fork is missing\n"),
> ino);
> - return(1);
> + return 1;
> }
> +
> /* FIX FOR bug 653709 -- EKN */
> - if (mp->m_sb.sb_agcount < XFS_FSB_TO_AGNO(mp, bno)) {
> + if (!xfs_verify_fsbno(mp, bno)) {
> do_warn(
> _("agno of attribute fork of inode %" PRIu64 " out of regular partition\n"), ino);
I'll change this to
"block in attribute fork of inode %" PRIu64 " is not valid"
ok?
> - return(1);
> + return 1;
> }
>
> bp = libxfs_readbuf(mp->m_dev, XFS_FSB_TO_DADDR(mp, bno),
>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/4] xfs_repair: refactor attr root block pointer check
2020-02-13 23:14 ` Eric Sandeen
@ 2020-02-14 4:24 ` Darrick J. Wong
0 siblings, 0 replies; 17+ messages in thread
From: Darrick J. Wong @ 2020-02-14 4:24 UTC (permalink / raw)
To: Eric Sandeen; +Cc: linux-xfs
On Thu, Feb 13, 2020 at 05:14:57PM -0600, Eric Sandeen wrote:
> On 2/4/20 6:46 PM, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> >
> > In process_longform_attr, replace the agcount check with a call to the
> > fsblock verification function in libxfs. Now we can also catch blocks
> > that point to static FS metadata.
> >
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> > repair/attr_repair.c | 10 +++++-----
> > 1 file changed, 5 insertions(+), 5 deletions(-)
> >
> >
> > diff --git a/repair/attr_repair.c b/repair/attr_repair.c
> > index 9a44f610..7b26df33 100644
> > --- a/repair/attr_repair.c
> > +++ b/repair/attr_repair.c
> > @@ -980,21 +980,21 @@ process_longform_attr(
> > *repair = 0;
> >
> > bno = blkmap_get(blkmap, 0);
> > -
> > - if ( bno == NULLFSBLOCK ) {
> > + if (bno == NULLFSBLOCK) {
> > if (dip->di_aformat == XFS_DINODE_FMT_EXTENTS &&
> > be16_to_cpu(dip->di_anextents) == 0)
> > return(0); /* the kernel can handle this state */
> > do_warn(
> > _("block 0 of inode %" PRIu64 " attribute fork is missing\n"),
> > ino);
> > - return(1);
> > + return 1;
> > }
> > +
> > /* FIX FOR bug 653709 -- EKN */
> > - if (mp->m_sb.sb_agcount < XFS_FSB_TO_AGNO(mp, bno)) {
> > + if (!xfs_verify_fsbno(mp, bno)) {
> > do_warn(
> > _("agno of attribute fork of inode %" PRIu64 " out of regular partition\n"), ino);
>
> I'll change this to
>
> "block in attribute fork of inode %" PRIu64 " is not valid"
Sounds good!
--D
> ok?
>
> > - return(1);
> > + return 1;
> > }
> >
> > bp = libxfs_readbuf(mp->m_dev, XFS_FSB_TO_DADDR(mp, bno),
> >
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 1/4] libxfs: re-sort libxfs_api_defs.h defines
2020-02-05 0:46 ` [PATCH 1/4] libxfs: re-sort libxfs_api_defs.h defines Darrick J. Wong
2020-02-05 2:11 ` Chaitanya Kulkarni
2020-02-05 5:28 ` Allison Collins
@ 2020-02-17 13:45 ` Christoph Hellwig
2 siblings, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2020-02-17 13:45 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: sandeen, linux-xfs
On Tue, Feb 04, 2020 at 04:46:13PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Re-fix the sorting in this file.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 2/4] libfrog: remove libxfs.h dependencies in fsgeom.c and linux.c
2020-02-05 0:46 ` [PATCH 2/4] libfrog: remove libxfs.h dependencies in fsgeom.c and linux.c Darrick J. Wong
2020-02-05 5:28 ` Allison Collins
@ 2020-02-17 13:46 ` Christoph Hellwig
1 sibling, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2020-02-17 13:46 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: sandeen, linux-xfs, Eric Sandeen
On Tue, Feb 04, 2020 at 04:46:20PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> libfrog isn't supposed to depend on libxfs, so don't include the header
> file in the libfrog source code.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 3/4] xfs_repair: refactor attr root block pointer check
2020-02-05 0:46 ` [PATCH 3/4] xfs_repair: refactor attr root block pointer check Darrick J. Wong
2020-02-05 5:28 ` Allison Collins
2020-02-13 23:14 ` Eric Sandeen
@ 2020-02-17 13:47 ` Christoph Hellwig
2 siblings, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2020-02-17 13:47 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: sandeen, linux-xfs
On Tue, Feb 04, 2020 at 04:46:28PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> In process_longform_attr, replace the agcount check with a call to the
> fsblock verification function in libxfs. Now we can also catch blocks
> that point to static FS metadata.
Looks good (especially with the fixup from Eric):
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4/4] xfs_repair: don't corrupt a attr fork da3 node when clearing forw/back
2020-02-05 0:46 ` [PATCH 4/4] xfs_repair: don't corrupt a attr fork da3 node when clearing forw/back Darrick J. Wong
2020-02-05 5:29 ` Allison Collins
@ 2020-02-17 13:48 ` Christoph Hellwig
1 sibling, 0 replies; 17+ messages in thread
From: Christoph Hellwig @ 2020-02-17 13:48 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: sandeen, linux-xfs
On Tue, Feb 04, 2020 at 04:46:34PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> In process_longform_attr, we enforce that the root block of the
> attribute index must have both forw or back pointers set to zero.
> Unfortunately, the code that nulls out the pointers is not aware that
> the root block could be in da3 node format.
>
> This leads to corruption of da3 root node blocks because the functions
> that convert attr3 leaf headers to and from the ondisk structures
> perform some interpretation of firstused on what they think is an attr1
> leaf block.
>
> Found by using xfs/402 to fuzz hdr.info.hdr.forw.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2020-02-17 13:48 UTC | newest]
Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-05 0:46 [PATCH 0/4] xfsprogs: random fixes Darrick J. Wong
2020-02-05 0:46 ` [PATCH 1/4] libxfs: re-sort libxfs_api_defs.h defines Darrick J. Wong
2020-02-05 2:11 ` Chaitanya Kulkarni
2020-02-05 5:28 ` Allison Collins
2020-02-17 13:45 ` Christoph Hellwig
2020-02-05 0:46 ` [PATCH 2/4] libfrog: remove libxfs.h dependencies in fsgeom.c and linux.c Darrick J. Wong
2020-02-05 5:28 ` Allison Collins
2020-02-17 13:46 ` Christoph Hellwig
2020-02-05 0:46 ` [PATCH 3/4] xfs_repair: refactor attr root block pointer check Darrick J. Wong
2020-02-05 5:28 ` Allison Collins
2020-02-13 23:14 ` Eric Sandeen
2020-02-14 4:24 ` Darrick J. Wong
2020-02-17 13:47 ` Christoph Hellwig
2020-02-05 0:46 ` [PATCH 4/4] xfs_repair: don't corrupt a attr fork da3 node when clearing forw/back Darrick J. Wong
2020-02-05 5:29 ` Allison Collins
2020-02-05 5:59 ` Darrick J. Wong
2020-02-17 13:48 ` Christoph Hellwig
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.