public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH 6/4] xfs: don't assert on corrupted unlinked inode list
Date: Mon, 4 Jun 2018 12:17:54 -0700	[thread overview]
Message-ID: <20180604191754.GP7825@magnolia> (raw)
In-Reply-To: <152812862079.2736.15381483104759513267.stgit@magnolia>

From: Darrick J. Wong <darrick.wong@oracle.com>

Use the per-ag inode number verifiers to detect corrupt lists and error
out, instead of using ASSERTs.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 fs/xfs/xfs_inode.c |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 05207a64dd53..c85ae83e007f 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2090,10 +2090,15 @@ xfs_iunlink_remove(
 	 * list this inode will go on.
 	 */
 	agino = XFS_INO_TO_AGINO(mp, ip->i_ino);
-	ASSERT(agino != 0);
+	if (!xfs_verify_agino(mp, agno, agino))
+		return -EFSCORRUPTED;
 	bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS;
-	ASSERT(agi->agi_unlinked[bucket_index] != cpu_to_be32(NULLAGINO));
-	ASSERT(agi->agi_unlinked[bucket_index]);
+	if (!xfs_verify_agino(mp, agno,
+			be32_to_cpu(agi->agi_unlinked[bucket_index]))) {
+		XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
+				agi, sizeof(*agi));
+		return -EFSCORRUPTED;
+	}
 
 	if (be32_to_cpu(agi->agi_unlinked[bucket_index]) == agino) {
 		/*
@@ -2171,8 +2176,12 @@ xfs_iunlink_remove(
 
 			last_offset = imap.im_boffset;
 			next_agino = be32_to_cpu(last_dip->di_next_unlinked);
-			ASSERT(next_agino != NULLAGINO);
-			ASSERT(next_agino != 0);
+			if (!xfs_verify_agino(mp, agno, next_agino)) {
+				XFS_CORRUPTION_ERROR(__func__,
+						XFS_ERRLEVEL_LOW, mp,
+						last_dip, sizeof(*last_dip));
+				return -EFSCORRUPTED;
+			}
 		}
 
 		/*

  parent reply	other threads:[~2018-06-04 19:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-04 16:10 [PATCH v2 0/4] xfs: fix various checking problems Darrick J. Wong
2018-06-04 16:10 ` [PATCH 1/4] xfs: check directory bestfree information in the verifier Darrick J. Wong
2018-06-04 21:56   ` Dave Chinner
2018-06-04 16:10 ` [PATCH 2/4] xfs: introduce xfs_btree_debug_check_ptr Darrick J. Wong
2018-06-04 21:56   ` Dave Chinner
2018-06-04 16:10 ` [PATCH 3/4] xfs: don't assert when on-disk btree pointers are garbage Darrick J. Wong
2018-06-04 21:57   ` Dave Chinner
2018-06-04 16:10 ` [PATCH 4/4] xfs: strengthen btree pointer checks before use Darrick J. Wong
2018-06-04 21:58   ` Dave Chinner
2018-06-04 19:17 ` [PATCH 5/4] xfs: explicitly pass buffer size to xfs_corruption_error Darrick J. Wong
2018-06-04 22:00   ` Dave Chinner
2018-06-04 19:17 ` Darrick J. Wong [this message]
2018-06-04 22:03   ` [PATCH 6/4] xfs: don't assert on corrupted unlinked inode list Dave Chinner

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=20180604191754.GP7825@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=linux-xfs@vger.kernel.org \
    /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