From fc4dd6168835ede80e97bba42feb7b60eeb46263 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Mon, 21 Sep 2015 12:13:50 +1000 Subject: [PATCH] ext4: test file/dir/symlink metadata corruption checking and repair Targeted fuzzing tests which destroy various pieces of file, directory, and symlink metadata; the tests look for (a) kernel detection of corruption, (b) e2fsck repair of said corruption, and (c) post-repair fs usability. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Signed-off-by: Dave Chinner --- tests/ext4/013 | 126 +++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/013.out | 15 ++++++ tests/ext4/014 | 124 ++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/014.out | 15 ++++++ tests/ext4/015 | 103 ++++++++++++++++++++++++++++++++++++ tests/ext4/015.out | 12 +++++ tests/ext4/016 | 96 ++++++++++++++++++++++++++++++++++ tests/ext4/016.out | 12 +++++ tests/ext4/017 | 99 +++++++++++++++++++++++++++++++++++ tests/ext4/017.out | 12 +++++ tests/ext4/018 | 97 ++++++++++++++++++++++++++++++++++ tests/ext4/018.out | 12 +++++ tests/ext4/019 | 95 ++++++++++++++++++++++++++++++++++ tests/ext4/019.out | 11 ++++ tests/ext4/group | 7 +++ 15 files changed, 836 insertions(+) create mode 100755 tests/ext4/013 create mode 100644 tests/ext4/013.out create mode 100755 tests/ext4/014 create mode 100644 tests/ext4/014.out create mode 100755 tests/ext4/015 create mode 100644 tests/ext4/015.out create mode 100755 tests/ext4/016 create mode 100644 tests/ext4/016.out create mode 100755 tests/ext4/017 create mode 100644 tests/ext4/017.out create mode 100755 tests/ext4/018 create mode 100644 tests/ext4/018.out create mode 100755 tests/ext4/019 create mode 100644 tests/ext4/019.out diff --git a/tests/ext4/013 b/tests/ext4/013 new file mode 100755 index 00000000..0c98142e --- /dev/null +++ b/tests/ext4/013 @@ -0,0 +1,126 @@ +#! /bin/bash +# FS QA Test No. 013 +# +# Create and populate an ext4 filesystem, corrupt an inode, then see how +# the kernel and e2fsck deal with it. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015 Oracle, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +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 15 + +_cleanup() +{ + cd / + #rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr + +# real QA test starts here +_supported_fs ext4 +_supported_os Linux + +_require_scratch +test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc +_require_attrs + +rm -f $seqres.full +TESTDIR="${SCRATCH_MNT}/scratchdir" +TESTFILE="${TESTDIR}/testfile" + +echo "+ create scratch fs" +_scratch_mkfs_ext4 > /dev/null 2>&1 + +echo "+ mount fs image" +_scratch_mount + +echo "+ make some files" +mkdir -p "${TESTDIR}" +for x in `seq 1 1024`; do + touch "${SCRATCH_MNT}/junk.${x}" + inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")" + if [ "$x" -gt 512 ] && [ "$((inode % 64))" -eq 0 ]; then + mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1" + break + fi +done +for x in `seq 2 64`; do + touch "${TESTFILE}.${x}" +done +inode="$(stat -c '%i' "${TESTFILE}.1")" +umount "${SCRATCH_MNT}" + +echo "+ check fs" +e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" + +echo "+ corrupt image" +blk="$(debugfs -R "imap <$inode>" "${SCRATCH_DEV}" 2> /dev/null | grep located | sed -e 's/^.*block \([0-9]*\),.*$/\1/g')" +debugfs -w -R "zap_block ${blk}" "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "inode fuzz failed" + +echo "+ mount image" +_scratch_mount + +echo "+ modify files" +broken=0 +for x in `seq 1 64`; do + #test -e "${TESTFILE}.${x}" || continue + stat "${TESTFILE}.${x}" >> $seqres.full 2>&1 + test $? -ne 0 && broken=1 + echo moo | dd oflag=append of="${TESTFILE}.${x}" 2>/dev/null + test $? -ne 0 && broken=1 +done +echo "broken: ${broken}" +umount "${SCRATCH_MNT}" + +echo "+ repair fs" +e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1 + +echo "+ mount image (2)" +_scratch_mount + +echo "+ chattr -R -i" +chattr -R -f -i "${SCRATCH_MNT}/" + +echo "+ modify files (2)" +broken=0 +for x in `seq 1 64`; do + test -e "${TESTFILE}.${x}" || continue + stat "${TESTFILE}.${x}" >> $seqres.full 2>&1 + test $? -ne 0 && broken=1 + echo moo | dd oflag=append of="${TESTFILE}.${x}" 2>/dev/null + test $? -ne 0 && broken=1 +done +echo "broken: ${broken}" +umount "${SCRATCH_MNT}" + +echo "+ check fs (2)" +e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" + +status=0 +exit diff --git a/tests/ext4/013.out b/tests/ext4/013.out new file mode 100644 index 00000000..f01a2c8b --- /dev/null +++ b/tests/ext4/013.out @@ -0,0 +1,15 @@ +QA output created by 013 ++ create scratch fs ++ mount fs image ++ make some files ++ check fs ++ corrupt image ++ mount image ++ modify files +broken: 1 ++ repair fs ++ mount image (2) ++ chattr -R -i ++ modify files (2) +broken: 0 ++ check fs (2) diff --git a/tests/ext4/014 b/tests/ext4/014 new file mode 100755 index 00000000..6c3fe6fe --- /dev/null +++ b/tests/ext4/014 @@ -0,0 +1,124 @@ +#! /bin/bash +# FS QA Test No. 014 +# +# Create and populate an ext4 filesystem, corrupt root directory, then +# see how the kernel and e2fsck deal with it. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015 Oracle, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +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 15 + +_cleanup() +{ + cd / + #rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr + +# real QA test starts here +_supported_fs ext4 +_supported_os Linux + +_require_scratch +test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc +_require_attrs + +rm -f $seqres.full +TESTDIR="${SCRATCH_MNT}/scratchdir" +TESTFILE="${TESTDIR}/testfile" + +echo "+ create scratch fs" +_scratch_mkfs_ext4 > /dev/null 2>&1 + +echo "+ mount fs image" +_scratch_mount + +echo "+ make some files" +mkdir -p "${TESTDIR}" +for x in `seq 1 128`; do + touch "${SCRATCH_MNT}/junk.${x}" + inode="$(stat -c '%i' "${SCRATCH_MNT}/junk.${x}")" + if [ "$x" -gt 64 ] && [ "$((inode % 64))" -eq 0 ]; then + mv "${SCRATCH_MNT}/junk.${x}" "${TESTFILE}.1" + break + fi +done +for x in `seq 2 64`; do + touch "${TESTFILE}.${x}" +done +umount "${SCRATCH_MNT}" + +echo "+ check fs" +e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" + +echo "+ corrupt image" +debugfs -w -R "zap -f / 0" "${SCRATCH_DEV}" >> $seqres.full 2>&1 + +echo "+ mount image" +_scratch_mount + +echo "+ modify files" +broken=0 +for x in `seq 1 64`; do + #test -e "${TESTFILE}.${x}" || continue + stat "${TESTFILE}.${x}" >> $seqres.full 2>&1 + test $? -ne 0 && broken=1 + echo moo | dd oflag=append of="${TESTFILE}.${x}" 2>/dev/null + test $? -ne 0 && broken=1 +done +echo "broken: ${broken}" +umount "${SCRATCH_MNT}" + +echo "+ repair fs" +e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1 && _fail "e2fsck should not succeed" + +echo "+ mount image (2)" +_scratch_mount + +echo "+ chattr -R -i" +chattr -R -f -i "${SCRATCH_MNT}/" + +echo "+ modify files (2)" +broken=0 +for x in `seq 1 64`; do + test -e "${TESTFILE}.${x}" || continue + stat "${TESTFILE}.${x}" >> $seqres.full 2>&1 + test $? -ne 0 && broken=1 + echo moo | dd oflag=append of="${TESTFILE}.${x}" 2>/dev/null + test $? -ne 0 && broken=1 +done +echo "broken: ${broken}" +umount "${SCRATCH_MNT}" + +echo "+ check fs (2)" +e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" + +status=0 +exit diff --git a/tests/ext4/014.out b/tests/ext4/014.out new file mode 100644 index 00000000..96a9efcb --- /dev/null +++ b/tests/ext4/014.out @@ -0,0 +1,15 @@ +QA output created by 014 ++ create scratch fs ++ mount fs image ++ make some files ++ check fs ++ corrupt image ++ mount image ++ modify files +broken: 1 ++ repair fs ++ mount image (2) ++ chattr -R -i ++ modify files (2) +broken: 0 ++ check fs (2) diff --git a/tests/ext4/015 b/tests/ext4/015 new file mode 100755 index 00000000..52dfb176 --- /dev/null +++ b/tests/ext4/015 @@ -0,0 +1,103 @@ +#! /bin/bash +# FS QA Test No. 015 +# +# Create and populate an ext4 filesystem, corrupt an extent tree block, then +# see how the kernel and e2fsck deal with it. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015 Oracle, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +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 15 + +_cleanup() +{ + cd / + #rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr + +# real QA test starts here +_supported_fs ext4 +_supported_os Linux + +_require_xfs_io_command "falloc" +_require_xfs_io_command "fpunch" +_require_scratch +test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc +_require_attrs + +rm -f $seqres.full +TESTDIR="${SCRATCH_MNT}/scratchdir" +TESTFILE="${TESTDIR}/testfile" + +echo "+ create scratch fs" +_scratch_mkfs_ext4 > /dev/null 2>&1 + +echo "+ mount fs image" +_scratch_mount +blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")" +freeblks="$((3 * blksz / 12))" + +echo "+ make some files" +$XFS_IO_PROG -f -c "falloc 0 $((blksz * freeblks))" "${SCRATCH_MNT}/bigfile" >> $seqres.full +seq 1 2 ${freeblks} | while read lblk; do + $XFS_IO_PROG -f -c "fpunch $((lblk * blksz)) ${blksz}" "${SCRATCH_MNT}/bigfile" >> $seqres.full +done +umount "${SCRATCH_MNT}" + +echo "+ check fs" +e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" + +echo "+ corrupt image" +debugfs "${SCRATCH_DEV}" -R 'ex /bigfile' 2> /dev/null | grep '^ 0' | awk '{print $8}' | while read blk; do + $XFS_IO_PROG -f -c "pwrite -S 0x62 $((blk * blksz + 8)) 8" "${SCRATCH_DEV}" >> $seqres.full +done + +echo "+ mount image" +_scratch_mount + +echo "+ modify files" +echo moo >> "${SCRATCH_MNT}/bigfile" 2> /dev/null && _fail "extent tree should be corrupt" +umount "${SCRATCH_MNT}" + +echo "+ repair fs" +e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1 + +echo "+ mount image (2)" +_scratch_mount + +echo "+ modify files (2)" +$XFS_IO_PROG -f -c "pwrite ${blksz} ${blksz}" "${SCRATCH_MNT}/bigfile" >> $seqres.full +umount "${SCRATCH_MNT}" + +echo "+ check fs (2)" +e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" + +status=0 +exit diff --git a/tests/ext4/015.out b/tests/ext4/015.out new file mode 100644 index 00000000..b49d13be --- /dev/null +++ b/tests/ext4/015.out @@ -0,0 +1,12 @@ +QA output created by 015 ++ create scratch fs ++ mount fs image ++ make some files ++ check fs ++ corrupt image ++ mount image ++ modify files ++ repair fs ++ mount image (2) ++ modify files (2) ++ check fs (2) diff --git a/tests/ext4/016 b/tests/ext4/016 new file mode 100755 index 00000000..c09d01ba --- /dev/null +++ b/tests/ext4/016 @@ -0,0 +1,96 @@ +#! /bin/bash +# FS QA Test No. 016 +# +# Create and populate an ext4 filesystem, corrupt a dirent block, then +# see how the kernel and e2fsck deal with it. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015 Oracle, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +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 15 + +_cleanup() +{ + cd / + #rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr + +# real QA test starts here +_supported_fs ext4 +_supported_os Linux + +_require_scratch +test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc +_require_attrs + +rm -f $seqres.full +TESTDIR="${SCRATCH_MNT}/scratchdir" +TESTFILE="${TESTDIR}/testfile" + +echo "+ create scratch fs" +_scratch_mkfs_ext4 > /dev/null 2>&1 + +echo "+ mount fs image" +_scratch_mount + +echo "+ make some files" +for x in `seq 1 15`; do + mkdir -p "${SCRATCH_MNT}/test/d_${x}" +done +umount "${SCRATCH_MNT}" + +echo "+ check fs" +e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" + +echo "+ corrupt image" +debugfs -w -R "zap -f /test 0" "${SCRATCH_DEV}" 2> /dev/null + +echo "+ mount image" +_scratch_mount + +echo "+ modify dirs" +mkdir -p "${SCRATCH_MNT}/test/newdir" 2> /dev/null && _fail "directory should be corrupt" +umount "${SCRATCH_MNT}" + +echo "+ repair fs" +e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1 + +echo "+ mount image (2)" +_scratch_mount + +echo "+ modify dirs (2)" +mkdir -p "${SCRATCH_MNT}/test/newdir" || _fail "directory should be corrupt" +umount "${SCRATCH_MNT}" + +echo "+ check fs (2)" +e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" + +status=0 +exit diff --git a/tests/ext4/016.out b/tests/ext4/016.out new file mode 100644 index 00000000..74bf9f9c --- /dev/null +++ b/tests/ext4/016.out @@ -0,0 +1,12 @@ +QA output created by 016 ++ create scratch fs ++ mount fs image ++ make some files ++ check fs ++ corrupt image ++ mount image ++ modify dirs ++ repair fs ++ mount image (2) ++ modify dirs (2) ++ check fs (2) diff --git a/tests/ext4/017 b/tests/ext4/017 new file mode 100755 index 00000000..4e3f7da4 --- /dev/null +++ b/tests/ext4/017 @@ -0,0 +1,99 @@ +#! /bin/bash +# FS QA Test No. 017 +# +# Create and populate an ext4 filesystem, corrupt a htree block, then +# see how the kernel and e2fsck deal with it. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015 Oracle, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +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 15 + +_cleanup() +{ + cd / + #rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr + +# real QA test starts here +_supported_fs ext4 +_supported_os Linux + +_require_scratch +test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc +_require_attrs + +rm -f $seqres.full +TESTDIR="${SCRATCH_MNT}/scratchdir" +TESTFILE="${TESTDIR}/testfile" + +echo "+ create scratch fs" +_scratch_mkfs_ext4 > /dev/null 2>&1 + +echo "+ mount fs image" +_scratch_mount +blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")" + +echo "+ make some files" +mkdir -p "${SCRATCH_MNT}/test/" +for x in `seq 1 $((blksz * 4 / 256))`; do + fname="$(printf "%.255s\n" "$(perl -e "print \"${x}_\" x 500;")")" + touch "${SCRATCH_MNT}/test/${fname}" +done +umount "${SCRATCH_MNT}" + +echo "+ check fs" +e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" + +echo "+ corrupt image" +debugfs -w -R "zap -f /test 0" "${SCRATCH_DEV}" 2> /dev/null + +echo "+ mount image" +_scratch_mount + +echo "+ modify dirs" +mkdir -p "${SCRATCH_MNT}/test/newdir" 2> /dev/null && _fail "htree should be corrupt" +umount "${SCRATCH_MNT}" + +echo "+ repair fs" +e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1 + +echo "+ mount image (2)" +_scratch_mount + +echo "+ modify dirs (2)" +mkdir -p "${SCRATCH_MNT}/test/newdir" || _fail "htree should not be corrupt" +umount "${SCRATCH_MNT}" + +echo "+ check fs (2)" +e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" + +status=0 +exit diff --git a/tests/ext4/017.out b/tests/ext4/017.out new file mode 100644 index 00000000..532bd631 --- /dev/null +++ b/tests/ext4/017.out @@ -0,0 +1,12 @@ +QA output created by 017 ++ create scratch fs ++ mount fs image ++ make some files ++ check fs ++ corrupt image ++ mount image ++ modify dirs ++ repair fs ++ mount image (2) ++ modify dirs (2) ++ check fs (2) diff --git a/tests/ext4/018 b/tests/ext4/018 new file mode 100755 index 00000000..8df6112c --- /dev/null +++ b/tests/ext4/018 @@ -0,0 +1,97 @@ +#! /bin/bash +# FS QA Test No. 018 +# +# Create and populate an ext4 filesystem, corrupt a xattr block, then +# see how the kernel and e2fsck deal with it. +# +#----------------------------------------------------------------------- +# Copyright (c) 2015 Oracle, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +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 15 + +_cleanup() +{ + cd / + #rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr + +# real QA test starts here +_supported_fs ext4 +_supported_os Linux + +_require_scratch +test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc +_require_attrs + +rm -f $seqres.full +TESTDIR="${SCRATCH_MNT}/scratchdir" +TESTFILE="${TESTDIR}/testfile" + +echo "+ create scratch fs" +_scratch_mkfs_ext4 > /dev/null 2>&1 + +echo "+ mount fs image" +_scratch_mount +blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")" + +echo "+ make some files" +$XFS_IO_PROG -f -c "pwrite -S 0x62 0 ${blksz}" "${SCRATCH_MNT}/attrfile" >> $seqres.full +setfattr -n user.key -v "$(perl -e 'print "v" x 300;')" "${SCRATCH_MNT}/attrfile" +umount "${SCRATCH_MNT}" + +echo "+ check fs" +e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" + +echo "+ corrupt image" +blk="$(debugfs -R 'stat /attrfile' "${SCRATCH_DEV}" 2> /dev/null | grep 'File ACL:' | sed -e 's/^.*File ACL: \([0-9]*\).*Directory.*$/\1/g')" +$XFS_IO_PROG -f -c "pwrite -S 0x62 $((blk * blksz + 20)) 8" "${SCRATCH_DEV}" >> $seqres.full + +echo "+ mount image" +_scratch_mount + +echo "+ modify attrs" +setfattr -n user.newkey -v "$(perl -e 'print "v" x 300;')" "${SCRATCH_MNT}/attrfile" 2> /dev/null && _fail "xattr should be corrupt" +umount "${SCRATCH_MNT}" + +echo "+ repair fs" +e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1 + +echo "+ mount image (2)" +_scratch_mount + +echo "+ modify attrs (2)" +setfattr -n user.newkey -v "$(perl -e 'print "v" x 300;')" "${SCRATCH_MNT}/attrfile" || _fail "xattr should not be corrupt" +umount "${SCRATCH_MNT}" + +echo "+ check fs (2)" +e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" + +status=0 +exit diff --git a/tests/ext4/018.out b/tests/ext4/018.out new file mode 100644 index 00000000..72331bcd --- /dev/null +++ b/tests/ext4/018.out @@ -0,0 +1,12 @@ +QA output created by 018 ++ create scratch fs ++ mount fs image ++ make some files ++ check fs ++ corrupt image ++ mount image ++ modify attrs ++ repair fs ++ mount image (2) ++ modify attrs (2) ++ check fs (2) diff --git a/tests/ext4/019 b/tests/ext4/019 new file mode 100755 index 00000000..8eb50416 --- /dev/null +++ b/tests/ext4/019 @@ -0,0 +1,95 @@ +#! /bin/bash +# FS QA Test No. 019 +# +# Create and populate an ext4 filesystem, corrupt a big symlink, then +# see how the kernel and e2fsck deal with it. (They won't) +# +#----------------------------------------------------------------------- +# Copyright (c) 2015 Oracle, Inc. All Rights Reserved. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it would be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +#----------------------------------------------------------------------- +# + +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 15 + +_cleanup() +{ + cd / + #rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/attr + +# real QA test starts here +_supported_fs ext4 +_supported_os Linux + +_require_scratch +test -n "${FORCE_FUZZ}" || _require_scratch_ext4_crc +_require_attrs + +rm -f $seqres.full +TESTDIR="${SCRATCH_MNT}/scratchdir" +TESTFILE="${TESTDIR}/testfile" + +echo "+ create scratch fs" +_scratch_mkfs_ext4 -O journal > /dev/null 2>&1 + +echo "+ mount fs image" +_scratch_mount +blksz="$(stat -f -c '%s' "${SCRATCH_MNT}")" +test "${blksz}" -gt 4096 && blksz=4096 + +echo "+ make some files" +echo "file contents: moo" > "${SCRATCH_MNT}/x" +str="$(perl -e "print './' x $(( (blksz / 2) - 16));")x" +(cd $SCRATCH_MNT; ln -s "${str}" "long_symlink") +cat "${SCRATCH_MNT}/long_symlink" +umount "${SCRATCH_MNT}" + +echo "+ check fs" +e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" + +echo "+ corrupt image" +debugfs -w -R 'zap -f /long_symlink -p 0x62 0' "${SCRATCH_DEV}" 2> /dev/null + +echo "+ mount image" +_scratch_mount 2> /dev/null +cat "${SCRATCH_MNT}/long_symlink" 2>/dev/null && _fail "symlink should be broken" +umount "${SCRATCH_MNT}" + +echo "+ repair fs" +e2fsck -fy "${SCRATCH_DEV}" >> $seqres.full 2>&1 + +echo "+ mount image (2)" +_scratch_mount +cat "${SCRATCH_MNT}/long_symlink" 2>/dev/null && _fail "symlink should be broken" +umount "${SCRATCH_MNT}" + +echo "+ check fs (2)" +e2fsck -fn "${SCRATCH_DEV}" >> $seqres.full 2>&1 || _fail "fsck should not fail" + +status=0 +exit diff --git a/tests/ext4/019.out b/tests/ext4/019.out new file mode 100644 index 00000000..9c7d2954 --- /dev/null +++ b/tests/ext4/019.out @@ -0,0 +1,11 @@ +QA output created by 019 ++ create scratch fs ++ mount fs image ++ make some files +file contents: moo ++ check fs ++ corrupt image ++ mount image ++ repair fs ++ mount image (2) ++ check fs (2) diff --git a/tests/ext4/group b/tests/ext4/group index b2c01c63..c947db63 100644 --- a/tests/ext4/group +++ b/tests/ext4/group @@ -15,6 +15,13 @@ 010 fuzzers 011 fuzzers 012 fuzzers +013 fuzzers +014 fuzzers +015 fuzzers +016 fuzzers +017 fuzzers +018 fuzzers +019 fuzzers 271 auto rw quick 301 aio dangerous ioctl rw stress 302 aio dangerous ioctl rw stress -- 2.39.5