xfs: fuzz every field of every structure and test kernel crashes

Fuzz every field of every structure and then try to write the
filesystem, to see how many of these writes can crash the kernel.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
Darrick J. Wong
2018-07-06 07:41:46 -07:00
committed by Eryu Guan
parent 0f849ea13f
commit 0804dc1736
76 changed files with 2072 additions and 23 deletions
+31 -23
View File
@@ -168,7 +168,7 @@ __fuzz_notify() {
# Fuzz one field of some piece of metadata.
# First arg is the field name
# Second arg is the fuzz verb (ones, zeroes, random, add, sub...)
# Third arg is the repair mode (online, offline, both)
# Third arg is the repair mode (online, offline, both, none)
__scratch_xfs_fuzz_field_test() {
field="$1"
fuzzverb="$2"
@@ -189,12 +189,14 @@ __scratch_xfs_fuzz_field_test() {
if [ $res -eq 0 ]; then
# Try an online scrub unless we're fuzzing ag 0's sb,
# which scrub doesn't know how to fix.
echo "++ Online scrub"
if [ "$1" != "sb 0" ]; then
_scratch_scrub -n -a 1 -e continue 2>&1
res=$?
test $res -eq 0 && \
(>&2 echo "scrub didn't fail with ${field} = ${fuzzverb}.")
if [ "${repair}" != "none" ]; then
echo "++ Online scrub"
if [ "$1" != "sb 0" ]; then
_scratch_scrub -n -a 1 -e continue 2>&1
res=$?
test $res -eq 0 && \
(>&2 echo "scrub didn't fail with ${field} = ${fuzzverb}.")
fi
fi
# Try fixing the filesystem online?!
@@ -221,11 +223,13 @@ __scratch_xfs_fuzz_field_test() {
fi
# See if repair finds a clean fs
echo "+ Make sure error is gone (offline)"
_scratch_xfs_repair -n 2>&1
res=$?
test $res -ne 0 && \
(>&2 echo "offline re-scrub ($res) with ${field} = ${fuzzverb}.")
if [ "${repair}" != "none" ]; then
echo "+ Make sure error is gone (offline)"
_scratch_xfs_repair -n 2>&1
res=$?
test $res -ne 0 && \
(>&2 echo "offline re-scrub ($res) with ${field} = ${fuzzverb}.")
fi
# See if scrub finds a clean fs
echo "+ Make sure error is gone (online)"
@@ -234,12 +238,14 @@ __scratch_xfs_fuzz_field_test() {
if [ $res -eq 0 ]; then
# Try an online scrub unless we're fuzzing ag 0's sb,
# which scrub doesn't know how to fix.
echo "++ Online scrub"
if [ "$1" != "sb 0" ]; then
_scratch_scrub -n -e continue 2>&1
res=$?
test $res -ne 0 && \
(>&2 echo "online re-scrub ($res) with ${field} = ${fuzzverb}.")
if [ "${repair}" != "none" ]; then
echo "++ Online scrub"
if [ "$1" != "sb 0" ]; then
_scratch_scrub -n -e continue 2>&1
res=$?
test $res -ne 0 && \
(>&2 echo "online re-scrub ($res) with ${field} = ${fuzzverb}.")
fi
fi
# Try modifying the filesystem again!
@@ -251,11 +257,13 @@ __scratch_xfs_fuzz_field_test() {
fi
# See if repair finds a clean fs
echo "+ Re-check the filesystem (offline)"
_scratch_xfs_repair -n 2>&1
res=$?
test $res -ne 0 && \
(>&2 echo "re-repair failed ($res) with ${field} = ${fuzzverb}.")
if [ "${repair}" != "none" ]; then
echo "+ Re-check the filesystem (offline)"
_scratch_xfs_repair -n 2>&1
res=$?
test $res -ne 0 && \
(>&2 echo "re-repair failed ($res) with ${field} = ${fuzzverb}.")
fi
}
# Make sure we have all the pieces we need for field fuzzing
Executable
+46
View File
@@ -0,0 +1,46 @@
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle, Inc. All rights reserved.
#
# FS QA Test No. 453
#
# Populate a XFS filesystem and fuzz every superblock field.
# Do not fix the filesystem, to test metadata verifiers.
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 7 15
_cleanup()
{
cd /
rm -rf $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/populate
. ./common/fuzzy
# real QA test starts here
_supported_os Linux
_supported_fs xfs
_require_scratch_xfs_fuzz_fields
_disable_dmesg_check
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz superblock"
_scratch_xfs_fuzz_metadata '' 'none' 'sb 1' >> $seqres.full
echo "Done fuzzing superblock"
# success, all done
status=0
exit
+4
View File
@@ -0,0 +1,4 @@
QA output created by 453
Format and populate
Fuzz superblock
Done fuzzing superblock
Executable
+46
View File
@@ -0,0 +1,46 @@
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle, Inc. All rights reserved.
#
# FS QA Test No. 454
#
# Populate a XFS filesystem and fuzz every AGF field.
# Do not fix the filesystem, to test metadata verifiers.
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 7 15
_cleanup()
{
cd /
rm -rf $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/populate
. ./common/fuzzy
# real QA test starts here
_supported_os Linux
_supported_fs xfs
_require_scratch_xfs_fuzz_fields
_disable_dmesg_check
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz AGF"
_scratch_xfs_fuzz_metadata '' 'none' 'agf 0' >> $seqres.full
echo "Done fuzzing AGF"
# success, all done
status=0
exit
+4
View File
@@ -0,0 +1,4 @@
QA output created by 454
Format and populate
Fuzz AGF
Done fuzzing AGF
Executable
+51
View File
@@ -0,0 +1,51 @@
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle, Inc. All rights reserved.
#
# FS QA Test No. 455
#
# Populate a XFS filesystem and fuzz every AGFL field.
# Do not fix the filesystem, to test metadata verifiers.
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 7 15
_cleanup()
{
cd /
rm -rf $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/populate
. ./common/fuzzy
# real QA test starts here
_supported_os Linux
_supported_fs xfs
_require_scratch_xfs_fuzz_fields
_disable_dmesg_check
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz AGFL"
_scratch_xfs_fuzz_metadata '' 'none' 'agfl 0' >> $seqres.full
echo "Done fuzzing AGFL"
echo "Fuzz AGFL flfirst"
flfirst=$(_scratch_xfs_db -c 'agf 0' -c 'p flfirst' | sed -e 's/flfirst = //g')
SCRATCH_XFS_LIST_METADATA_FIELDS="bno[${flfirst}]" _scratch_xfs_fuzz_metadata '' 'none' 'agfl 0' >> $seqres.full
echo "Done fuzzing AGFL flfirst"
# success, all done
status=0
exit
+6
View File
@@ -0,0 +1,6 @@
QA output created by 455
Format and populate
Fuzz AGFL
Done fuzzing AGFL
Fuzz AGFL flfirst
Done fuzzing AGFL flfirst
Executable
+46
View File
@@ -0,0 +1,46 @@
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle, Inc. All rights reserved.
#
# FS QA Test No. 456
#
# Populate a XFS filesystem and fuzz every AGI field.
# Do not fix the filesystem, to test metadata verifiers.
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 7 15
_cleanup()
{
cd /
rm -rf $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/populate
. ./common/fuzzy
# real QA test starts here
_supported_os Linux
_supported_fs xfs
_require_scratch_xfs_fuzz_fields
_disable_dmesg_check
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz AGI"
_scratch_xfs_fuzz_metadata '' 'none' 'agi 0' >> $seqres.full
echo "Done fuzzing AGI"
# success, all done
status=0
exit
+4
View File
@@ -0,0 +1,4 @@
QA output created by 456
Format and populate
Fuzz AGI
Done fuzzing AGI
Executable
+46
View File
@@ -0,0 +1,46 @@
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle, Inc. All rights reserved.
#
# FS QA Test No. 457
#
# Populate a XFS filesystem and fuzz every bnobt field.
# Do not fix the filesystem, to test metadata verifiers.
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 7 15
_cleanup()
{
cd /
rm -rf $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/populate
. ./common/fuzzy
# real QA test starts here
_supported_os Linux
_supported_fs xfs
_require_scratch_xfs_fuzz_fields
_disable_dmesg_check
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz bnobt recs"
_scratch_xfs_fuzz_metadata '' 'none' 'agf 0' 'addr bnoroot' 'addr ptrs[1]' >> $seqres.full
echo "Done fuzzing bnobt recs"
# success, all done
status=0
exit
+4
View File
@@ -0,0 +1,4 @@
QA output created by 457
Format and populate
Fuzz bnobt recs
Done fuzzing bnobt recs
Executable
+46
View File
@@ -0,0 +1,46 @@
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle, Inc. All rights reserved.
#
# FS QA Test No. 458
#
# Populate a XFS filesystem and fuzz every bnobt key/pointer.
# Do not fix the filesystem, to test metadata verifiers.
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 7 15
_cleanup()
{
cd /
rm -rf $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/populate
. ./common/fuzzy
# real QA test starts here
_supported_os Linux
_supported_fs xfs
_require_scratch_xfs_fuzz_fields
_disable_dmesg_check
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz bnobt keyptr"
_scratch_xfs_fuzz_metadata '' 'none' 'agf 0' 'addr bnoroot' >> $seqres.full
echo "Done fuzzing bnobt keyptr"
# success, all done
status=0
exit
+4
View File
@@ -0,0 +1,4 @@
QA output created by 458
Format and populate
Fuzz bnobt keyptr
Done fuzzing bnobt keyptr
Executable
+46
View File
@@ -0,0 +1,46 @@
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle, Inc. All rights reserved.
#
# FS QA Test No. 459
#
# Populate a XFS filesystem and fuzz every cntbt field.
# Do not fix the filesystem, to test metadata verifiers.
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 7 15
_cleanup()
{
cd /
rm -rf $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/populate
. ./common/fuzzy
# real QA test starts here
_supported_os Linux
_supported_fs xfs
_require_scratch_xfs_fuzz_fields
_disable_dmesg_check
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz cntbt"
_scratch_xfs_fuzz_metadata '' 'none' 'agf 0' 'addr cntroot' 'addr ptrs[1]' >> $seqres.full
echo "Done fuzzing cntbt"
# success, all done
status=0
exit
+4
View File
@@ -0,0 +1,4 @@
QA output created by 459
Format and populate
Fuzz cntbt
Done fuzzing cntbt
Executable
+46
View File
@@ -0,0 +1,46 @@
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle, Inc. All rights reserved.
#
# FS QA Test No. 460
#
# Populate a XFS filesystem and fuzz every inobt field.
# Do not fix the filesystem, to test metadata verifiers.
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 7 15
_cleanup()
{
cd /
rm -rf $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/populate
. ./common/fuzzy
# real QA test starts here
_supported_os Linux
_supported_fs xfs
_require_scratch_xfs_fuzz_fields
_disable_dmesg_check
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz inobt"
_scratch_xfs_fuzz_metadata '' 'none' 'agi 1' 'addr root' >> $seqres.full
echo "Done fuzzing inobt"
# success, all done
status=0
exit
+4
View File
@@ -0,0 +1,4 @@
QA output created by 460
Format and populate
Fuzz inobt
Done fuzzing inobt
Executable
+47
View File
@@ -0,0 +1,47 @@
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle, Inc. All rights reserved.
#
# FS QA Test No. 461
#
# Populate a XFS filesystem and fuzz every finobt field.
# Do not fix the filesystem, to test metadata verifiers.
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 7 15
_cleanup()
{
cd /
rm -rf $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/populate
. ./common/fuzzy
# real QA test starts here
_supported_os Linux
_supported_fs xfs
_require_scratch_xfs_fuzz_fields
_disable_dmesg_check
_require_xfs_finobt
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz finobt"
_scratch_xfs_fuzz_metadata '' 'none' 'agi 0' 'addr free_root' >> $seqres.full
echo "Done fuzzing finobt"
# success, all done
status=0
exit
+4
View File
@@ -0,0 +1,4 @@
QA output created by 461
Format and populate
Fuzz finobt
Done fuzzing finobt
Executable
+47
View File
@@ -0,0 +1,47 @@
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle, Inc. All rights reserved.
#
# FS QA Test No. 462
#
# Populate a XFS filesystem and fuzz every rmapbt field.
# Do not fix the filesystem, to test metadata verifiers.
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 7 15
_cleanup()
{
cd /
rm -rf $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/populate
. ./common/fuzzy
# real QA test starts here
_supported_os Linux
_supported_fs xfs
_require_xfs_scratch_rmapbt
_require_scratch_xfs_fuzz_fields
_disable_dmesg_check
echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1
echo "Fuzz rmapbt recs"
_scratch_xfs_fuzz_metadata '' 'none' 'agf 0' 'addr rmaproot' 'addr ptrs[1]' >> $seqres.full
echo "Done fuzzing rmapbt recs"
# success, all done
status=0
exit

Some files were not shown because too many files have changed in this diff Show More