diff mbox series

xfs: new test on xfs with corrupted sb_inopblock

Message ID 20221027164254.1472306-1-zlang@kernel.org (mailing list archive)
State Superseded, archived
Headers show
Series xfs: new test on xfs with corrupted sb_inopblock | expand

Commit Message

Zorro Lang Oct. 27, 2022, 4:42 p.m. UTC
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>
---
 tests/xfs/555     | 27 +++++++++++++++++++++++++++
 tests/xfs/555.out |  4 ++++
 2 files changed, 31 insertions(+)
 create mode 100755 tests/xfs/555
 create mode 100644 tests/xfs/555.out

Comments

Darrick J. Wong Oct. 27, 2022, 5:01 p.m. UTC | #1
On Fri, Oct 28, 2022 at 12:42:54AM +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>
> ---
>  tests/xfs/555     | 27 +++++++++++++++++++++++++++
>  tests/xfs/555.out |  4 ++++
>  2 files changed, 31 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..7f46a9af
> --- /dev/null
> +++ b/tests/xfs/555
> @@ -0,0 +1,27 @@
> +#! /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")

_fixed_by_kernel_commit?

> +#
> +. ./common/preamble
> +_begin_fstest auto quick
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_require_scratch_nocheck
> +
> +_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"

You might want to check the scratch fs to make sure repair will deal
with the problem...?

--D

> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/555.out b/tests/xfs/555.out
> new file mode 100644
> index 00000000..36c3446e
> --- /dev/null
> +++ b/tests/xfs/555.out
> @@ -0,0 +1,4 @@
> +QA output created by 555
> +corrupt inopblock of sb 0
> +try to mount ...
> +no crash or hang
> -- 
> 2.31.1
>
Zorro Lang Oct. 28, 2022, 5:43 a.m. UTC | #2
On Thu, Oct 27, 2022 at 10:01:14AM -0700, Darrick J. Wong wrote:
> On Fri, Oct 28, 2022 at 12:42:54AM +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>
> > ---
> >  tests/xfs/555     | 27 +++++++++++++++++++++++++++
> >  tests/xfs/555.out |  4 ++++
> >  2 files changed, 31 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..7f46a9af
> > --- /dev/null
> > +++ b/tests/xfs/555
> > @@ -0,0 +1,27 @@
> > +#! /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")
> 
> _fixed_by_kernel_commit?

Sure

> 
> > +#
> > +. ./common/preamble
> > +_begin_fstest auto quick
> > +
> > +# real QA test starts here
> > +_supported_fs xfs
> > +_require_scratch_nocheck
> > +
> > +_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"
> 
> You might want to check the scratch fs to make sure repair will deal
> with the problem...?

I thought it's not a part of the original reproducer, so tried to save this
time, especially xfs/350 xfs/351 already covered this part testing :) But if
you think it's worth, I'll add it in next version.

Thanks,
Zorro

> 
> --D
> 
> > +# success, all done
> > +status=0
> > +exit
> > diff --git a/tests/xfs/555.out b/tests/xfs/555.out
> > new file mode 100644
> > index 00000000..36c3446e
> > --- /dev/null
> > +++ b/tests/xfs/555.out
> > @@ -0,0 +1,4 @@
> > +QA output created by 555
> > +corrupt inopblock of sb 0
> > +try to mount ...
> > +no crash or hang
> > -- 
> > 2.31.1
> > 
>
diff mbox series

Patch

diff --git a/tests/xfs/555 b/tests/xfs/555
new file mode 100755
index 00000000..7f46a9af
--- /dev/null
+++ b/tests/xfs/555
@@ -0,0 +1,27 @@ 
+#! /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
+_require_scratch_nocheck
+
+_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"
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/555.out b/tests/xfs/555.out
new file mode 100644
index 00000000..36c3446e
--- /dev/null
+++ b/tests/xfs/555.out
@@ -0,0 +1,4 @@ 
+QA output created by 555
+corrupt inopblock of sb 0
+try to mount ...
+no crash or hang