Skip to contentSkip to conversation

xfs: new test on xfs with corrupted sb_inopblock

PATCH Superseded Zorro Lang 3 participants 3 messages Oct 27, 2022 – Oct 28, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zorro Lang

author
#0 lore raw

PATCH 1/1 xfs: new test on xfs with corrupted sb_inopblock

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.

---
 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
tests/xfs/555 new file +27 -0
new file mode 100755
index 00000000..7f46a9af
@@ -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
tests/xfs/555.out new file +4 -0
new file mode 100644
index 00000000..36c3446e
@@ -0,0 +1,4 @@
+QA output created by 555
+corrupt inopblock of sb 0
+try to mount ...
+no crash or hang
Signature · 1 line
2.31.1
#1 lore raw
Quoted 18 lines · Zorro Lang

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.

---
 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
tests/xfs/555 new file +0 -0
new file mode 100755
index 00000000..7f46a9af

tests/xfs/555 line 8

Quoted 8 lines
tests/xfs/555 new file +8 -0
@@ -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?

Quoted 6 lines
tests/xfs/555 new file +6 -0
+#
+. ./common/preamble
+_begin_fstest auto quick
+
+# real QA test starts here
+_supported_fs xfs

tests/xfs/555 line 24

Quoted 10 lines
tests/xfs/555 new file +10 -0
+_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

Quoted 16 lines
tests/xfs/555 new file +3 -0
+# success, all done
+status=0
+exit
tests/xfs/555.out new file +4 -0
new file mode 100644
index 00000000..36c3446e
@@ -0,0 +1,4 @@
+QA output created by 555
+corrupt inopblock of sb 0
+try to mount ...
+no crash or hang
Signature · 1 line
2.31.1
#2 lore raw
Quoted 13 lines · Darrick J. Wong
Quoted 12 lines · Zorro Lang

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.

---
 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
Quoted 16 lines
Quoted 6 lines
tests/xfs/555 new file +0 -0
new file mode 100755
index 00000000..7f46a9af

tests/xfs/555 line 8

Quoted 8 lines
tests/xfs/555 new file +8 -0
@@ -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

Quoted 12 lines
Quoted 12 lines
tests/xfs/555 new file +11 -0
+#
+. ./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"
Quoted 8 lines

tests/xfs/555 line 24

Quoted 5 lines
tests/xfs/555 new file +5 -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

Quoted 20 lines

--D

Quoted 16 lines
tests/xfs/555 new file +3 -0
+# success, all done
+status=0
+exit
tests/xfs/555.out new file +4 -0
new file mode 100644
index 00000000..36c3446e
@@ -0,0 +1,4 @@
+QA output created by 555
+corrupt inopblock of sb 0
+try to mount ...
+no crash or hang
Signature · 1 line
2.31.1