linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: linux-xfs <linux-xfs@vger.kernel.org>, John Jore <john@jore.no>
Subject: Re: [PATCH] xfs_repair: fix bad next_unlinked field
Date: Mon, 10 Feb 2020 07:54:13 -0800	[thread overview]
Message-ID: <20200210155413.GJ6870@magnolia> (raw)
In-Reply-To: <f5b8a2a9-e691-3bf5-c2c7-f4986a933454@redhat.com>

On Mon, Feb 10, 2020 at 09:42:28AM -0600, Eric Sandeen wrote:
> As of xfsprogs-4.17 we started testing whether the di_next_unlinked field
> on an inode is valid in the inode verifiers. However, this field is never
> tested or repaired during inode processing.
> 
> So if, for example, we had a completely zeroed-out inode, we'd detect and
> fix the broken magic and version, but the invalid di_next_unlinked field
> would not be touched, fail the write verifier, and prevent the inode from
> being properly repaired or even written out.
> 
> Fix this by checking the di_next_unlinked inode field for validity and
> clearing it if it is invalid.
> 
> Reported-by: John Jore <john@jore.no>
> Fixes: 2949b4677 ("xfs: don't accept inode buffers with suspicious unlinked chains")
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Seems reasonable,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
> 
> diff --git a/repair/dinode.c b/repair/dinode.c
> index 8af2cb25..c5d2f350 100644
> --- a/repair/dinode.c
> +++ b/repair/dinode.c
> @@ -2272,6 +2272,7 @@ process_dinode_int(xfs_mount_t *mp,
>  	const int		is_free = 0;
>  	const int		is_used = 1;
>  	blkmap_t		*dblkmap = NULL;
> +	xfs_agino_t		unlinked_ino;
>  
>  	*dirty = *isa_dir = 0;
>  	*used = is_used;
> @@ -2351,6 +2352,23 @@ process_dinode_int(xfs_mount_t *mp,
>  		}
>  	}
>  
> +	unlinked_ino = be32_to_cpu(dino->di_next_unlinked);
> +	if (!xfs_verify_agino_or_null(mp, agno, unlinked_ino)) {
> +		retval = 1;
> +		if (!uncertain)
> +			do_warn(_("bad next_unlinked 0x%x on inode %" PRIu64 "%c"),
> +				(__s32)dino->di_next_unlinked, lino,
> +				verify_mode ? '\n' : ',');
> +		if (!verify_mode) {
> +			if (!no_modify) {
> +				do_warn(_(" resetting next_unlinked\n"));
> +				clear_dinode_unlinked(mp, dino);
> +				*dirty = 1;
> +			} else
> +				do_warn(_(" would reset next_unlinked\n"));
> +		}
> +	}
> +
>  	/*
>  	 * We don't bother checking the CRC here - we cannot guarantee that when
>  	 * we are called here that the inode has not already been modified in
> 

  reply	other threads:[~2020-02-10 15:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 15:42 [PATCH] xfs_repair: fix bad next_unlinked field Eric Sandeen
2020-02-10 15:54 ` Darrick J. Wong [this message]
2020-02-11  9:08 ` Carlos Maiolino
2020-02-11 14:34   ` Eric Sandeen
2020-02-11 10:11 ` John Jore
2020-02-11 14:31   ` 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=20200210155413.GJ6870@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=john@jore.no \
    --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;
as well as URLs for NNTP newsgroup(s).