From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: sandeen@redhat.com
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH v2 09/11] xfs_repair: actually fix .. entries that point to inode zero
Date: Tue, 8 May 2018 09:31:24 -0700 [thread overview]
Message-ID: <20180508163124.GM11261@magnolia> (raw)
In-Reply-To: <152401964787.13319.7143262291746238151.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
If we encounter a directory with an entry that points to inode zero,
we'll crash due to an ASSERT during process_inode_chunk. This is due to
process_dir2_data not arranging for phase 6 to fix the parent pointer
when '..' -> 0, so do that. Found via xfs/386 fuzzing bu[1].inumber to
zero.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
libxfs/libxfs_api_defs.h | 1 +
repair/dir2.c | 17 +++++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h
index d588f342..56f9f8ca 100644
--- a/libxfs/libxfs_api_defs.h
+++ b/libxfs/libxfs_api_defs.h
@@ -78,6 +78,7 @@
#define xfs_bmbt_get_all libxfs_bmbt_get_all
#define xfs_rtfree_extent libxfs_rtfree_extent
#define xfs_verify_rtbno libxfs_verify_rtbno
+#define xfs_verify_ino libxfs_verify_ino
#define xfs_zero_extent libxfs_zero_extent
#define xfs_defer_init libxfs_defer_init
diff --git a/repair/dir2.c b/repair/dir2.c
index fbe88b50..f0371371 100644
--- a/repair/dir2.c
+++ b/repair/dir2.c
@@ -847,6 +847,23 @@ _("bad .. entry in root directory inode %" PRIu64 ", was %" PRIu64 ": "),
}
*parent = ino;
}
+ /*
+ * Make sure our parent pointer doesn't point
+ * off into space.
+ */
+ if (!junkit &&
+ *parent != NULLFSINO &&
+ !libxfs_verify_ino(mp, *parent)) {
+ do_warn(
+_("bad .. entry in directory inode %" PRIu64 ", was %" PRIu64 ": "),
+ ino, *parent);
+ if (!no_modify) {
+ do_warn(_("correcting\n"));
+ } else {
+ do_warn(_("would correct\n"));
+ }
+ *parent = NULLFSINO;
+ }
}
/*
* Can't fix the directory unless we know which ..
next prev parent reply other threads:[~2018-05-08 16:31 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-18 2:46 [PATCH 00/11] xfsprogs-4.17: xfs_repair fixes Darrick J. Wong
2018-04-18 2:46 ` [PATCH 01/11] xfs_repair: examine all remote attribute blocks Darrick J. Wong
2018-05-04 18:20 ` Eric Sandeen
2018-05-04 19:23 ` Darrick J. Wong
2018-05-23 3:15 ` [PATCH v2 " Darrick J. Wong
2018-05-23 3:47 ` Allison Henderson
2018-04-18 2:46 ` [PATCH 02/11] xfs_repair: don't leak buffer on xattr remote buf verifier error Darrick J. Wong
2018-05-04 19:16 ` Eric Sandeen
2018-04-18 2:46 ` [PATCH 03/11] xfs_repair: validate some of the log space information Darrick J. Wong
2018-05-04 19:29 ` Eric Sandeen
2018-05-04 20:25 ` Darrick J. Wong
2018-05-04 20:54 ` Eric Sandeen
2018-05-23 3:15 ` [PATCH v2 " Darrick J. Wong
2018-05-23 3:52 ` Allison Henderson
2018-04-18 2:46 ` [PATCH 04/11] xfs_repair: zap corrupt remote symlink Darrick J. Wong
2018-05-04 19:46 ` Eric Sandeen
2018-05-04 20:22 ` Darrick J. Wong
2018-04-18 2:47 ` [PATCH 05/11] xfs_repair: treat zero da btree pointers as corruption Darrick J. Wong
2018-05-04 19:59 ` Eric Sandeen
2018-04-18 2:47 ` [PATCH 06/11] xfs_repair: invalidate dirty dir buffers when we zap a directory Darrick J. Wong
2018-05-04 20:13 ` Eric Sandeen
2018-04-18 2:47 ` [PATCH 07/11] xfs_repair: only update in-core extent state after scanning full extent Darrick J. Wong
2018-05-04 21:52 ` Eric Sandeen
2018-04-18 2:47 ` [PATCH 08/11] xfs_repair: don't crash if da btree is corrupt Darrick J. Wong
2018-05-04 22:00 ` Eric Sandeen
2018-04-18 2:47 ` [PATCH 09/11] xfs_repair: don't assert if we run across a dir entry with null ino ptr Darrick J. Wong
2018-05-04 22:33 ` Eric Sandeen
2018-05-04 22:45 ` Darrick J. Wong
2018-05-08 16:07 ` Darrick J. Wong
2018-05-08 16:31 ` Darrick J. Wong [this message]
2018-04-18 2:47 ` [PATCH 10/11] xfs_repair: check inode nsec for obviously garbage values Darrick J. Wong
2018-05-04 22:38 ` Eric Sandeen
2018-04-18 2:47 ` [PATCH 11/11] xfs_repair: don't assert on bad '.' entry in no-modify mode Darrick J. Wong
2018-05-04 22:41 ` Eric Sandeen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180508163124.GM11261@magnolia \
--to=darrick.wong@oracle.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox