All of lore.kernel.org
 help / color / mirror / Atom feed
From: Allison Henderson <allison.henderson@oracle.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>, sandeen@redhat.com
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH v2 03/11] xfs_repair: validate some of the log space information
Date: Tue, 22 May 2018 20:52:34 -0700	[thread overview]
Message-ID: <5d76f6ae-80f3-38c3-db7e-c55e565b3259@oracle.com> (raw)
In-Reply-To: <20180523031536.GH14384@magnolia>

Ok, looks good.

Reviewed by: Allison Henderson <allison.henderson@oracle.com>

On 05/22/2018 08:15 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Validate the log space information in a similar manner to the kernel so
> that repair will stumble over (and fix) broken log info that prevents
> mounting.  Fixes logsunit fuzz-and-fix failures in xfs/350.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>   repair/globals.h    |    3 ++-
>   repair/sb.c         |   27 +++++++++++++++++++++++++++
>   repair/xfs_repair.c |    2 ++
>   3 files changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/repair/globals.h b/repair/globals.h
> index e777ba27..164619b0 100644
> --- a/repair/globals.h
> +++ b/repair/globals.h
> @@ -51,7 +51,8 @@
>   #define XR_BAD_SVN		19	/* bad shared version number */
>   #define XR_BAD_CRC		20	/* Bad CRC */
>   #define XR_BAD_DIR_SIZE_DATA	21	/* Bad directory geometry */
> -#define XR_BAD_ERR_CODE		22	/* Bad error code */
> +#define XR_BAD_LOG_GEOMETRY	22	/* Bad log geometry */
> +#define XR_BAD_ERR_CODE		23	/* Bad error code */
>   
>   /* XFS filesystem (il)legal values */
>   
> diff --git a/repair/sb.c b/repair/sb.c
> index 3dc6538b..ef44e39c 100644
> --- a/repair/sb.c
> +++ b/repair/sb.c
> @@ -298,6 +298,30 @@ sb_validate_ino_align(struct xfs_sb *sb)
>   	return false;
>   }
>   
> +/*
> + * Validate the given log space.  Derived from xfs_log_mount, though we
> + * can't validate the minimum log size until later.  We only do this
> + * validation on V5 filesystems because the kernel doesn't reject malformed
> + * log geometry on older revision filesystems.
> + *
> + * Returns false if the log is garbage.
> + */
> +static bool
> +verify_sb_loginfo(
> +	struct xfs_sb	*sb)
> +{
> +	if (xfs_sb_version_hascrc(sb) &&
> +	    (sb->sb_logblocks == 0 ||
> +	     sb->sb_logblocks > XFS_MAX_LOG_BLOCKS ||
> +	     (sb->sb_logblocks << sb->sb_blocklog) > XFS_MAX_LOG_BYTES))
> +		return false;
> +
> +	if (sb->sb_logsunit > 1 && sb->sb_logsunit % sb->sb_blocksize)
> +		return false;
> +
> +	return true;
> +}
> +
>   /*
>    * verify a superblock -- does not verify root inode #
>    *	can only check that geometry info is internally
> @@ -412,6 +436,9 @@ verify_sb(char *sb_buf, xfs_sb_t *sb, int is_primary_sb)
>   	    (sb->sb_blocklog - sb->sb_inodelog != sb->sb_inopblog))
>   		return XR_BAD_INO_SIZE_DATA;
>   
> +	if (!verify_sb_loginfo(sb))
> +		return XR_BAD_LOG_GEOMETRY;
> +
>   	if (xfs_sb_version_hassector(sb))  {
>   
>   		/* check to make sure log sector is legal 2^N, 9 <= N <= 15 */
> diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
> index ff6a7384..b7c2d267 100644
> --- a/repair/xfs_repair.c
> +++ b/repair/xfs_repair.c
> @@ -155,6 +155,8 @@ err_string(int err_code)
>   			_("bad CRC in superblock");
>   		err_message[XR_BAD_DIR_SIZE_DATA] =
>   			_("inconsistent directory geometry information");
> +		err_message[XR_BAD_LOG_GEOMETRY] =
> +			_("inconsistent log geometry information");
>   		done = 1;
>   	}
>   
> --
> 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  https://urldefense.proofpoint.com/v2/url?u=http-3A__vger.kernel.org_majordomo-2Dinfo.html&d=DwIBAg&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=LHZQ8fHvy6wDKXGTWcm97burZH5sQKHRDMaY1UthQxc&m=nZ0K_Km7ERFhI8CrunSV1T8eZYlZ-DRLdVcNPos7ubQ&s=ZkAtuu-cih4_uXaSekCCbLGpd5WW-a-JeDmxWBBTVwI&e=
> 

  reply	other threads:[~2018-05-23  3:52 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 [this message]
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   ` [PATCH v2 09/11] xfs_repair: actually fix .. entries that point to inode zero Darrick J. Wong
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=5d76f6ae-80f3-38c3-db7e-c55e565b3259@oracle.com \
    --to=allison.henderson@oracle.com \
    --cc=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 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.