]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
xfs: new test on xfs with corrupted sb_inopblock v2022.10.30
authorZorro Lang <zlang@kernel.org>
Fri, 28 Oct 2022 15:43:37 +0000 (23:43 +0800)
committerZorro Lang <zlang@kernel.org>
Sun, 30 Oct 2022 10:41:13 +0000 (18:41 +0800)
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>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
tests/xfs/555 [new file with mode: 0755]
tests/xfs/555.out [new file with mode: 0644]

diff --git a/tests/xfs/555 b/tests/xfs/555
new file mode 100755 (executable)
index 0000000..a402450
--- /dev/null
@@ -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
+
+_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 (file)
index 0000000..4f1b01a
--- /dev/null
@@ -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