From 5b3d24ad23f8aa88cda43446e8b3928881cd48b3 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Thu, 20 Feb 2025 13:47:03 -0800 Subject: [PATCH] xfs: create fuzz tests for metadata directories Create fuzz tests to make sure that all the validation works for metadata directories and subdirectories. The metadir fuzzer tests are tagged 'realtime' to force creation of an interesting metadata directory tree full of rtgroups inodes. Signed-off-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Signed-off-by: Zorro Lang --- common/xfs | 22 ++++++++++++++++++++++ tests/xfs/807 | 34 ++++++++++++++++++++++++++++++++++ tests/xfs/807.out | 4 ++++ tests/xfs/808 | 34 ++++++++++++++++++++++++++++++++++ tests/xfs/808.out | 4 ++++ tests/xfs/809 | 34 ++++++++++++++++++++++++++++++++++ tests/xfs/809.out | 4 ++++ tests/xfs/810 | 35 +++++++++++++++++++++++++++++++++++ tests/xfs/810.out | 4 ++++ tests/xfs/811 | 34 ++++++++++++++++++++++++++++++++++ tests/xfs/811.out | 4 ++++ tests/xfs/812 | 34 ++++++++++++++++++++++++++++++++++ tests/xfs/812.out | 4 ++++ tests/xfs/813 | 34 ++++++++++++++++++++++++++++++++++ tests/xfs/813.out | 4 ++++ tests/xfs/814 | 35 +++++++++++++++++++++++++++++++++++ tests/xfs/814.out | 4 ++++ 17 files changed, 328 insertions(+) create mode 100755 tests/xfs/807 create mode 100644 tests/xfs/807.out create mode 100755 tests/xfs/808 create mode 100644 tests/xfs/808.out create mode 100755 tests/xfs/809 create mode 100644 tests/xfs/809.out create mode 100755 tests/xfs/810 create mode 100644 tests/xfs/810.out create mode 100755 tests/xfs/811 create mode 100644 tests/xfs/811.out create mode 100755 tests/xfs/812 create mode 100644 tests/xfs/812.out create mode 100755 tests/xfs/813 create mode 100644 tests/xfs/813.out create mode 100755 tests/xfs/814 create mode 100644 tests/xfs/814.out diff --git a/common/xfs b/common/xfs index eb4d99c9..771ef906 100644 --- a/common/xfs +++ b/common/xfs @@ -1956,3 +1956,25 @@ _xfs_calc_hidden_quota_files() { echo 0 fi } + +_require_xfs_mkfs_metadir() +{ + _scratch_mkfs_xfs_supported -m metadir=1 >/dev/null 2>&1 || \ + _notrun "mkfs.xfs doesn't have metadir features" +} + +_require_xfs_scratch_metadir() +{ + _require_xfs_mkfs_metadir + _require_scratch + + _scratch_mkfs -m metadir=1 &> /dev/null + _require_scratch_xfs_features METADIR + _try_scratch_mount + res=$? + if [ $res -ne 0 ]; then + _notrun "mounting with metadir not supported by filesystem type: $FSTYP" + else + _scratch_unmount + fi +} diff --git a/tests/xfs/807 b/tests/xfs/807 new file mode 100755 index 00000000..39c7e512 --- /dev/null +++ b/tests/xfs/807 @@ -0,0 +1,34 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 807 +# +# Populate a XFS filesystem and fuzz every metadir root field. +# Use xfs_scrub to fix the corruption. + +. ./common/preamble +_begin_fstest dangerous_fuzzers scrub fuzzers_online_repair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy + +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /') + +echo "Fuzz metadir root" +_scratch_xfs_fuzz_metadata '' 'online' 'path -m /' >> $seqres.full +echo "Done fuzzing metadir root" + +# success, all done +status=0 +exit diff --git a/tests/xfs/807.out b/tests/xfs/807.out new file mode 100644 index 00000000..0eb55219 --- /dev/null +++ b/tests/xfs/807.out @@ -0,0 +1,4 @@ +QA output created by 807 +Format and populate +Fuzz metadir root +Done fuzzing metadir root diff --git a/tests/xfs/808 b/tests/xfs/808 new file mode 100755 index 00000000..d2894c86 --- /dev/null +++ b/tests/xfs/808 @@ -0,0 +1,34 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 808 +# +# Populate a XFS filesystem and fuzz every metadir root field. +# Use xfs_repair to fix the corruption. + +. ./common/preamble +_begin_fstest dangerous_fuzzers repair fuzzers_repair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy + +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /') + +echo "Fuzz metadir root" +_scratch_xfs_fuzz_metadata '' 'offline' 'path -m /' >> $seqres.full +echo "Done fuzzing metadir root" + +# success, all done +status=0 +exit diff --git a/tests/xfs/808.out b/tests/xfs/808.out new file mode 100644 index 00000000..4e34e3c1 --- /dev/null +++ b/tests/xfs/808.out @@ -0,0 +1,4 @@ +QA output created by 808 +Format and populate +Fuzz metadir root +Done fuzzing metadir root diff --git a/tests/xfs/809 b/tests/xfs/809 new file mode 100755 index 00000000..80dd9298 --- /dev/null +++ b/tests/xfs/809 @@ -0,0 +1,34 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 809 +# +# Populate a XFS filesystem and fuzz every metadir root field. +# Do not fix the filesystem, to test metadata verifiers. + +. ./common/preamble +_begin_fstest dangerous_fuzzers fuzzers_norepair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy + +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /') + +echo "Fuzz metadir root" +_scratch_xfs_fuzz_metadata '' 'none' 'path -m /' >> $seqres.full +echo "Done fuzzing metadir root" + +# success, all done +status=0 +exit diff --git a/tests/xfs/809.out b/tests/xfs/809.out new file mode 100644 index 00000000..953d5a66 --- /dev/null +++ b/tests/xfs/809.out @@ -0,0 +1,4 @@ +QA output created by 809 +Format and populate +Fuzz metadir root +Done fuzzing metadir root diff --git a/tests/xfs/810 b/tests/xfs/810 new file mode 100755 index 00000000..5ffb8be5 --- /dev/null +++ b/tests/xfs/810 @@ -0,0 +1,35 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 810 +# +# Populate a XFS filesystem and fuzz every metadir root field. +# Try online repair and, if necessary, offline repair, +# to test the most likely usage pattern. + +. ./common/preamble +_begin_fstest dangerous_fuzzers scrub repair fuzzers_bothrepair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy + +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /') + +echo "Fuzz metadir root" +_scratch_xfs_fuzz_metadata '' 'both' 'path -m /' >> $seqres.full +echo "Done fuzzing metadir root" + +# success, all done +status=0 +exit diff --git a/tests/xfs/810.out b/tests/xfs/810.out new file mode 100644 index 00000000..014d1172 --- /dev/null +++ b/tests/xfs/810.out @@ -0,0 +1,4 @@ +QA output created by 810 +Format and populate +Fuzz metadir root +Done fuzzing metadir root diff --git a/tests/xfs/811 b/tests/xfs/811 new file mode 100755 index 00000000..7455d951 --- /dev/null +++ b/tests/xfs/811 @@ -0,0 +1,34 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 811 +# +# Populate a XFS filesystem and fuzz every metadir subdir field. +# Use xfs_scrub to fix the corruption. + +. ./common/preamble +_begin_fstest dangerous_fuzzers scrub fuzzers_online_repair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy + +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /rtgroups') + +echo "Fuzz metadir subdir" +_scratch_xfs_fuzz_metadata '' 'online' 'path -m /rtgroups' >> $seqres.full +echo "Done fuzzing metadir subdir" + +# success, all done +status=0 +exit diff --git a/tests/xfs/811.out b/tests/xfs/811.out new file mode 100644 index 00000000..071c04bd --- /dev/null +++ b/tests/xfs/811.out @@ -0,0 +1,4 @@ +QA output created by 811 +Format and populate +Fuzz metadir subdir +Done fuzzing metadir subdir diff --git a/tests/xfs/812 b/tests/xfs/812 new file mode 100755 index 00000000..daa119d8 --- /dev/null +++ b/tests/xfs/812 @@ -0,0 +1,34 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 812 +# +# Populate a XFS filesystem and fuzz every metadir subdir field. +# Use xfs_repair to fix the corruption. + +. ./common/preamble +_begin_fstest dangerous_fuzzers repair fuzzers_repair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy + +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /rtgroups') + +echo "Fuzz metadir subdir" +_scratch_xfs_fuzz_metadata '' 'offline' 'path -m /rtgroups' >> $seqres.full +echo "Done fuzzing metadir subdir" + +# success, all done +status=0 +exit diff --git a/tests/xfs/812.out b/tests/xfs/812.out new file mode 100644 index 00000000..653456e0 --- /dev/null +++ b/tests/xfs/812.out @@ -0,0 +1,4 @@ +QA output created by 812 +Format and populate +Fuzz metadir subdir +Done fuzzing metadir subdir diff --git a/tests/xfs/813 b/tests/xfs/813 new file mode 100755 index 00000000..97fc53ed --- /dev/null +++ b/tests/xfs/813 @@ -0,0 +1,34 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 813 +# +# Populate a XFS filesystem and fuzz every metadir subdir field. +# Do not fix the filesystem, to test metadata verifiers. + +. ./common/preamble +_begin_fstest dangerous_fuzzers fuzzers_norepair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy + +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /rtgroups') + +echo "Fuzz metadir subdir" +_scratch_xfs_fuzz_metadata '' 'none' 'path -m /rtgroups' >> $seqres.full +echo "Done fuzzing metadir subdir" + +# success, all done +status=0 +exit diff --git a/tests/xfs/813.out b/tests/xfs/813.out new file mode 100644 index 00000000..15c7a426 --- /dev/null +++ b/tests/xfs/813.out @@ -0,0 +1,4 @@ +QA output created by 813 +Format and populate +Fuzz metadir subdir +Done fuzzing metadir subdir diff --git a/tests/xfs/814 b/tests/xfs/814 new file mode 100755 index 00000000..9394e80a --- /dev/null +++ b/tests/xfs/814 @@ -0,0 +1,35 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2022-2025 Oracle. All Rights Reserved. +# +# FS QA Test No. 814 +# +# Populate a XFS filesystem and fuzz every metadir subdir field. +# Try online repair and, if necessary, offline repair, +# to test the most likely usage pattern. + +. ./common/preamble +_begin_fstest dangerous_fuzzers scrub repair fuzzers_bothrepair realtime + +_register_cleanup "_cleanup" BUS + +. ./common/filter +. ./common/populate +. ./common/fuzzy + +_require_xfs_scratch_metadir +_require_scratch_xfs_fuzz_fields +_disable_dmesg_check + +echo "Format and populate" +_scratch_populate_cached nofill > $seqres.full 2>&1 + +inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /rtgroups') + +echo "Fuzz metadir subdir" +_scratch_xfs_fuzz_metadata '' 'both' 'path -m /rtgroups' >> $seqres.full +echo "Done fuzzing metadir subdir" + +# success, all done +status=0 +exit diff --git a/tests/xfs/814.out b/tests/xfs/814.out new file mode 100644 index 00000000..3cdacd5b --- /dev/null +++ b/tests/xfs/814.out @@ -0,0 +1,4 @@ +QA output created by 814 +Format and populate +Fuzz metadir subdir +Done fuzzing metadir subdir -- 2.39.5