From: Theodore Ts'o Date: Fri, 28 Jun 2019 22:59:08 +0000 (-0400) Subject: shared,ext4: move ext[234]-specific tests out of shared/ X-Git-Tag: v2022.05.01~1105 X-Git-Url: http://git.apps.os.sepia.ceph.com/?p=xfstests-dev.git;a=commitdiff_plain;h=6cbaba4a08b7e1b827d63c829b05ce3b9c5aadf7 shared,ext4: move ext[234]-specific tests out of shared/ Move the following tests: shared/005 --> ext4/040 shared/007 --> ext4/041 shared/289 --> ext4/042 Signed-off-by: Theodore Ts'o Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- diff --git a/tests/ext4/040 b/tests/ext4/040 new file mode 100755 index 00000000..3e475f7d --- /dev/null +++ b/tests/ext4/040 @@ -0,0 +1,65 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2017 Oracle, Inc. All Rights Reserved. +# +# FSQA Test No. ext4/040 (was shared/005) +# +# Since loff_t is a signed type, it is invalid for a filesystem to load +# an inode with i_size = -1ULL. Unfortunately, nobody checks this, +# which means that we can trivially DoS the VFS by creating such a file +# and appending to it. This causes an integer overflow in the routines +# underlying writeback, which results in the kernel locking up. +# +# So, create this malformed inode and try a buffered append to make +# sure we catch this situation. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +PIDS="" +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_os Linux +_supported_fs ext2 ext3 ext4 +_require_scratch_nocheck +_disable_dmesg_check +_require_command "$DEBUGFS_PROG" + +rm -f $seqres.full + +echo "Format and mount" +_scratch_mkfs >> $seqres.full 2>&1 +_scratch_mount + +testdir=$SCRATCH_MNT +echo m > $testdir/a + +echo "Corrupt filesystem" +_scratch_unmount +$DEBUGFS_PROG -w -R "sif /a size -1" $SCRATCH_DEV >> $seqres.full 2>&1 + +# check whether debugfs succeeds to set i_size to -1 or not +$DEBUGFS_PROG -R "stat /a" $SCRATCH_DEV 2>&1 | grep -q "Size: 18446744073709551615" || \ + _notrun "Could not set i_size to -1 successfully, skip test." + +echo "Remount, try to append" +_scratch_mount +dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)." +sync + +# success, all done +status=0 +exit diff --git a/tests/ext4/040.out b/tests/ext4/040.out new file mode 100644 index 00000000..dbccb495 --- /dev/null +++ b/tests/ext4/040.out @@ -0,0 +1,5 @@ +QA output created by 040 +Format and mount +Corrupt filesystem +Remount, try to append +Write did not succeed (ok). diff --git a/tests/ext4/041 b/tests/ext4/041 new file mode 100755 index 00000000..5c9c0713 --- /dev/null +++ b/tests/ext4/041 @@ -0,0 +1,67 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2017 Oracle, Inc. All Rights Reserved. +# +# FSQA Test No. ext4/041 (was shared/007) +# +# Since loff_t is a signed type, it is invalid for a filesystem to load +# an inode with i_size = -1ULL. Unfortunately, nobody checks this, +# which means that we can trivially DoS the VFS by creating such a file +# and appending to it. This causes an integer overflow in the routines +# underlying writeback, which results in the kernel locking up. +# +# So, create this malformed inode and try a dio append to make sure we +# catch this situation. +# +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +PIDS="" +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + rm -f $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# real QA test starts here +_supported_os Linux +_supported_fs ext2 ext3 ext4 +_require_scratch_nocheck +_disable_dmesg_check +_require_command "$DEBUGFS_PROG" + +rm -f $seqres.full + +echo "Format and mount" +_scratch_mkfs >> $seqres.full 2>&1 +_scratch_mount + +testdir=$SCRATCH_MNT +echo m > $testdir/a + +echo "Corrupt filesystem" +_scratch_unmount +# Set the file size to the highest multiple of 512 below +# -1 so that we can perform a dio write. +$DEBUGFS_PROG -w -R "sif /a size 0xFFFFFFFFFFFFFE00" $SCRATCH_DEV >> $seqres.full 2>&1 + +# check whether debugfs succeeds to set i_size to -512 or not +$DEBUGFS_PROG -R "stat /a" $SCRATCH_DEV 2>&1 | grep -q "Size: 18446744073709551104" || \ + _notrun "Could not set i_size to -512 successfully, skip test." + +echo "Remount, try to append" +_scratch_mount +dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=direct,append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)." +sync + +# success, all done +status=0 +exit diff --git a/tests/ext4/041.out b/tests/ext4/041.out new file mode 100644 index 00000000..97480072 --- /dev/null +++ b/tests/ext4/041.out @@ -0,0 +1,5 @@ +QA output created by 041 +Format and mount +Corrupt filesystem +Remount, try to append +Write did not succeed (ok). diff --git a/tests/ext4/042 b/tests/ext4/042 new file mode 100755 index 00000000..17d482a1 --- /dev/null +++ b/tests/ext4/042 @@ -0,0 +1,84 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2012 Red Hat, Inc. All Rights Reserved. +# +# FS QA Test No. ext4/042 (was shared/289) +# +# Test overhead & df output for extN filesystems +# +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 + +# real QA test starts here + +# Modify as appropriate. +_supported_fs ext2 ext3 ext4 +_supported_os Linux +_require_scratch + +rm -f $seqres.full + +_scratch_mkfs >> $seqres.full 2>&1 + +# Get the honest truth about block counts straight from metadata on disk +TOTAL_BLOCKS=`dumpe2fs -h $SCRATCH_DEV 2>/dev/null \ + | awk '/Block count:/{print $3}'` + +FREE_BLOCKS=`dumpe2fs -h $SCRATCH_DEV 2>/dev/null \ + | awk '/Free blocks:/{print $3}'` + +OVERHEAD=$(($TOTAL_BLOCKS-$FREE_BLOCKS)) + +# bsddf|minixdf +# Set the behaviour for the statfs system call. The minixdf +# behaviour is to return in the f_blocks field the total number of +# blocks of the filesystem, while the bsddf behaviour (which is +# the default) is to subtract the overhead blocks used by the ext2 +# filesystem and not available for file storage. + +# stat -f output looks like this; we get f_blocks from that, which +# varies depending on the df mount options used below: + +# File: "/mnt/test" +# ID: affc5f2b2f57652 Namelen: 255 Type: ext2/ext3 +# Block size: 4096 Fundamental block size: 4096 +# Blocks: Total: 5162741 Free: 5118725 Available: 4856465 +# Inodes: Total: 1313760 Free: 1313749 + +_scratch_mount "-o minixdf" +MINIX_F_BLOCKS=`stat -f $SCRATCH_MNT | awk '/^Blocks/{print $3}'` +_scratch_unmount + +_scratch_mount "-o bsddf" +BSD_F_BLOCKS=`stat -f $SCRATCH_MNT | awk '/^Blocks/{print $3}'` +_scratch_unmount + +# Echo data to $seqres.full for analysis +echo "Overhead is $OVERHEAD blocks out of $TOTAL_BLOCKS ($FREE_BLOCKS free)" >> $seqres.full +echo "MINIX free blocks $MINIX_F_BLOCKS" >> $seqres.full +echo "BSD free blocks $BSD_F_BLOCKS" >> $seqres.full + +# minix should be exactly equal (hence tolerance of 0) +_within_tolerance "minix f_blocks" $MINIX_F_BLOCKS $TOTAL_BLOCKS 0 -v +# bsd should be within ... we'll say 1% for some slop +_within_tolerance "bsd f_blocks" $BSD_F_BLOCKS $(($TOTAL_BLOCKS-$OVERHEAD)) 1% -v + +# success, all done +status=0 +exit diff --git a/tests/ext4/042.out b/tests/ext4/042.out new file mode 100644 index 00000000..1bd6f82a --- /dev/null +++ b/tests/ext4/042.out @@ -0,0 +1,3 @@ +QA output created by 042 +minix f_blocks is in range +bsd f_blocks is in range diff --git a/tests/ext4/group b/tests/ext4/group index 6418d82d..9dfc0d35 100644 --- a/tests/ext4/group +++ b/tests/ext4/group @@ -42,6 +42,9 @@ 037 auto quick 038 auto quick 039 auto enospc rw +040 dangerous_fuzzers +041 dangerous_fuzzers +042 auto quick 271 auto rw quick 301 aio auto ioctl rw stress defrag 302 aio auto ioctl rw stress defrag diff --git a/tests/shared/005 b/tests/shared/005 deleted file mode 100755 index 67940dd0..00000000 --- a/tests/shared/005 +++ /dev/null @@ -1,65 +0,0 @@ -#! /bin/bash -# SPDX-License-Identifier: GPL-2.0 -# Copyright (c) 2017 Oracle, Inc. All Rights Reserved. -# -# FSQA Test No. 005 -# -# Since loff_t is a signed type, it is invalid for a filesystem to load -# an inode with i_size = -1ULL. Unfortunately, nobody checks this, -# which means that we can trivially DoS the VFS by creating such a file -# and appending to it. This causes an integer overflow in the routines -# underlying writeback, which results in the kernel locking up. -# -# So, create this malformed inode and try a buffered append to make -# sure we catch this situation. -# -seq=`basename $0` -seqres=$RESULT_DIR/$seq -echo "QA output created by $seq" - -PIDS="" -tmp=/tmp/$$ -status=1 # failure is the default! -trap "_cleanup; exit \$status" 0 1 2 3 15 - -_cleanup() -{ - rm -f $tmp.* -} - -# get standard environment, filters and checks -. ./common/rc -. ./common/filter - -# real QA test starts here -_supported_os Linux -_supported_fs ext2 ext3 ext4 -_require_scratch_nocheck -_disable_dmesg_check -_require_command "$DEBUGFS_PROG" - -rm -f $seqres.full - -echo "Format and mount" -_scratch_mkfs >> $seqres.full 2>&1 -_scratch_mount - -testdir=$SCRATCH_MNT -echo m > $testdir/a - -echo "Corrupt filesystem" -_scratch_unmount -$DEBUGFS_PROG -w -R "sif /a size -1" $SCRATCH_DEV >> $seqres.full 2>&1 - -# check whether debugfs succeeds to set i_size to -1 or not -$DEBUGFS_PROG -R "stat /a" $SCRATCH_DEV 2>&1 | grep -q "Size: 18446744073709551615" || \ - _notrun "Could not set i_size to -1 successfully, skip test." - -echo "Remount, try to append" -_scratch_mount -dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)." -sync - -# success, all done -status=0 -exit diff --git a/tests/shared/005.out b/tests/shared/005.out deleted file mode 100644 index 06e3fcdc..00000000 --- a/tests/shared/005.out +++ /dev/null @@ -1,5 +0,0 @@ -QA output created by 005 -Format and mount -Corrupt filesystem -Remount, try to append -Write did not succeed (ok). diff --git a/tests/shared/007 b/tests/shared/007 deleted file mode 100755 index 65cb5273..00000000 --- a/tests/shared/007 +++ /dev/null @@ -1,67 +0,0 @@ -#! /bin/bash -# SPDX-License-Identifier: GPL-2.0 -# Copyright (c) 2017 Oracle, Inc. All Rights Reserved. -# -# FSQA Test No. 007 -# -# Since loff_t is a signed type, it is invalid for a filesystem to load -# an inode with i_size = -1ULL. Unfortunately, nobody checks this, -# which means that we can trivially DoS the VFS by creating such a file -# and appending to it. This causes an integer overflow in the routines -# underlying writeback, which results in the kernel locking up. -# -# So, create this malformed inode and try a dio append to make sure we -# catch this situation. -# -seq=`basename $0` -seqres=$RESULT_DIR/$seq -echo "QA output created by $seq" - -PIDS="" -tmp=/tmp/$$ -status=1 # failure is the default! -trap "_cleanup; exit \$status" 0 1 2 3 15 - -_cleanup() -{ - rm -f $tmp.* -} - -# get standard environment, filters and checks -. ./common/rc -. ./common/filter - -# real QA test starts here -_supported_os Linux -_supported_fs ext2 ext3 ext4 -_require_scratch_nocheck -_disable_dmesg_check -_require_command "$DEBUGFS_PROG" - -rm -f $seqres.full - -echo "Format and mount" -_scratch_mkfs >> $seqres.full 2>&1 -_scratch_mount - -testdir=$SCRATCH_MNT -echo m > $testdir/a - -echo "Corrupt filesystem" -_scratch_unmount -# Set the file size to the highest multiple of 512 below -# -1 so that we can perform a dio write. -$DEBUGFS_PROG -w -R "sif /a size 0xFFFFFFFFFFFFFE00" $SCRATCH_DEV >> $seqres.full 2>&1 - -# check whether debugfs succeeds to set i_size to -512 or not -$DEBUGFS_PROG -R "stat /a" $SCRATCH_DEV 2>&1 | grep -q "Size: 18446744073709551104" || \ - _notrun "Could not set i_size to -512 successfully, skip test." - -echo "Remount, try to append" -_scratch_mount -dd if=/dev/zero of=$testdir/a bs=512 count=1 oflag=direct,append conv=notrunc >> $seqres.full 2>&1 || echo "Write did not succeed (ok)." -sync - -# success, all done -status=0 -exit diff --git a/tests/shared/007.out b/tests/shared/007.out deleted file mode 100644 index 3afba59a..00000000 --- a/tests/shared/007.out +++ /dev/null @@ -1,5 +0,0 @@ -QA output created by 007 -Format and mount -Corrupt filesystem -Remount, try to append -Write did not succeed (ok). diff --git a/tests/shared/289 b/tests/shared/289 deleted file mode 100755 index 94b64430..00000000 --- a/tests/shared/289 +++ /dev/null @@ -1,84 +0,0 @@ -#! /bin/bash -# SPDX-License-Identifier: GPL-2.0 -# Copyright (c) 2012 Red Hat, Inc. All Rights Reserved. -# -# FS QA Test No. 289 -# -# Test overhead & df output for extN filesystems -# -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 - -# real QA test starts here - -# Modify as appropriate. -_supported_fs ext2 ext3 ext4 -_supported_os Linux -_require_scratch - -rm -f $seqres.full - -_scratch_mkfs >> $seqres.full 2>&1 - -# Get the honest truth about block counts straight from metadata on disk -TOTAL_BLOCKS=`dumpe2fs -h $SCRATCH_DEV 2>/dev/null \ - | awk '/Block count:/{print $3}'` - -FREE_BLOCKS=`dumpe2fs -h $SCRATCH_DEV 2>/dev/null \ - | awk '/Free blocks:/{print $3}'` - -OVERHEAD=$(($TOTAL_BLOCKS-$FREE_BLOCKS)) - -# bsddf|minixdf -# Set the behaviour for the statfs system call. The minixdf -# behaviour is to return in the f_blocks field the total number of -# blocks of the filesystem, while the bsddf behaviour (which is -# the default) is to subtract the overhead blocks used by the ext2 -# filesystem and not available for file storage. - -# stat -f output looks like this; we get f_blocks from that, which -# varies depending on the df mount options used below: - -# File: "/mnt/test" -# ID: affc5f2b2f57652 Namelen: 255 Type: ext2/ext3 -# Block size: 4096 Fundamental block size: 4096 -# Blocks: Total: 5162741 Free: 5118725 Available: 4856465 -# Inodes: Total: 1313760 Free: 1313749 - -_scratch_mount "-o minixdf" -MINIX_F_BLOCKS=`stat -f $SCRATCH_MNT | awk '/^Blocks/{print $3}'` -_scratch_unmount - -_scratch_mount "-o bsddf" -BSD_F_BLOCKS=`stat -f $SCRATCH_MNT | awk '/^Blocks/{print $3}'` -_scratch_unmount - -# Echo data to $seqres.full for analysis -echo "Overhead is $OVERHEAD blocks out of $TOTAL_BLOCKS ($FREE_BLOCKS free)" >> $seqres.full -echo "MINIX free blocks $MINIX_F_BLOCKS" >> $seqres.full -echo "BSD free blocks $BSD_F_BLOCKS" >> $seqres.full - -# minix should be exactly equal (hence tolerance of 0) -_within_tolerance "minix f_blocks" $MINIX_F_BLOCKS $TOTAL_BLOCKS 0 -v -# bsd should be within ... we'll say 1% for some slop -_within_tolerance "bsd f_blocks" $BSD_F_BLOCKS $(($TOTAL_BLOCKS-$OVERHEAD)) 1% -v - -# success, all done -status=0 -exit diff --git a/tests/shared/289.out b/tests/shared/289.out deleted file mode 100644 index a4de760a..00000000 --- a/tests/shared/289.out +++ /dev/null @@ -1,3 +0,0 @@ -QA output created by 289 -minix f_blocks is in range -bsd f_blocks is in range diff --git a/tests/shared/group b/tests/shared/group index 6f184946..3507d7d4 100644 --- a/tests/shared/group +++ b/tests/shared/group @@ -4,13 +4,10 @@ # - comment line before each group is "new" description # 002 auto metadata quick log -005 dangerous_fuzzers 006 auto enospc -007 dangerous_fuzzers 008 auto stress dedupe 009 auto stress dedupe 010 auto stress dedupe 011 auto quick 032 mkfs auto quick -289 auto quick 298 auto trim