public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Zorro Lang <zlang@kernel.org>
Cc: fstests@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH v2] xfs: new test on xfs with corrupted sb_inopblock
Date: Fri, 28 Oct 2022 09:25:44 -0700	[thread overview]
Message-ID: <Y1wCiERfVq34IoYb@magnolia> (raw)
In-Reply-To: <20221028154337.1788413-1-zlang@kernel.org>

On Fri, Oct 28, 2022 at 11:43:37PM +0800, Zorro Lang wrote:
> There's a known bug fix 392c6de98af1 ("xfs: sanitize sb_inopblock in
> xfs_mount_validate_sb"). So try to corrupt the sb_inopblock of xfs,
> to cover this bug.
> 
> Signed-off-by: Zorro Lang <zlang@redhat.com>
> ---
> 
> V2 does below changes:
> 1) Add _fixed_by_kernel_commit ...
> 2) Repair and check the xfs at the test end
> 
> Thanks,
> Zorro
> 
>  tests/xfs/555     | 32 ++++++++++++++++++++++++++++++++
>  tests/xfs/555.out |  6 ++++++
>  2 files changed, 38 insertions(+)
>  create mode 100755 tests/xfs/555
>  create mode 100644 tests/xfs/555.out
> 
> diff --git a/tests/xfs/555 b/tests/xfs/555
> new file mode 100755
> index 00000000..a4024501
> --- /dev/null
> +++ b/tests/xfs/555
> @@ -0,0 +1,32 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2022 Red Hat, Inc.  All Rights Reserved.
> +#
> +# FS QA Test 555
> +#
> +# Corrupt xfs sb_inopblock, make sure no crash. This's a test coverage of
> +# 392c6de98af1 ("xfs: sanitize sb_inopblock in xfs_mount_validate_sb")
> +#
> +. ./common/preamble
> +_begin_fstest auto quick
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_fixed_by_kernel_commit 392c6de98af1 \
> +	"xfs: sanitize sb_inopblock in xfs_mount_validate_sb"
> +_require_scratch

This /might/ want a _require_xfs_db_command "write" too, but that might
not be necessary since iirc 'write' has been in db for a long time now.

Either way, this test looks ok to me so
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> +
> +_scratch_mkfs >>$seqres.full
> +echo "corrupt inopblock of sb 0"
> +_scratch_xfs_set_metadata_field "inopblock" "500" "sb 0" >> $seqres.full
> +echo "try to mount ..."
> +_try_scratch_mount 2>> $seqres.full && _fail "mount should not succeed!"
> +echo "no crash or hang"
> +echo "repair corrupted sb 0"
> +_scratch_xfs_repair >> $seqres.full 2>&1
> +echo "check fs"
> +_scratch_xfs_repair -n >> $seqres.full 2>&1 || echo "fs isn't fixed!"
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/555.out b/tests/xfs/555.out
> new file mode 100644
> index 00000000..4f1b01a2
> --- /dev/null
> +++ b/tests/xfs/555.out
> @@ -0,0 +1,6 @@
> +QA output created by 555
> +corrupt inopblock of sb 0
> +try to mount ...
> +no crash or hang
> +repair corrupted sb 0
> +check fs
> -- 
> 2.31.1
> 

      reply	other threads:[~2022-10-28 16:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-28 15:43 [PATCH v2] xfs: new test on xfs with corrupted sb_inopblock Zorro Lang
2022-10-28 16:25 ` Darrick J. Wong [this message]

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=Y1wCiERfVq34IoYb@magnolia \
    --to=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=zlang@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