Darrick J. Wong
2016-Dec-11 21:52 UTC
[Ocfs2-devel] [PATCH 0/7] xfstests: misc reflink test fixes
Hi all, The following patchset enable the use of xfstests to test reflink functionality under ocfs2. The first patch tests the ability to reflink into and out of inline-data files on ocfs2. Patches 2-6 fix various problems with the tests that came up when qualifying ocfs2. The last patch maliciously corrupts ext4 and xfs filesystems to exploit nonexistent checking of i_size in order to coerce Linux into loading a file with negative size. It then exploits integer overflows in the VFS writeback code to hard lock the kernel. Don't run the tests in this patch ({ext4,xfs}/40[01]) unless you have a fixed kernel (4.10?) Comments and questions are, as always, welcome. --D
Darrick J. Wong
2016-Dec-11 21:52 UTC
[Ocfs2-devel] [PATCH 1/7] ocfs2: test reflinking to inline data files
Make sure that we can handle reflinking from and to inline-data files. Signed-off-by: Darrick J. Wong <darrick.wong at oracle.com> --- common/reflink | 2 + tests/ocfs2/001 | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ocfs2/001.out | 14 ++++++++ tests/ocfs2/Makefile | 20 +++++++++++ tests/ocfs2/group | 1 + 5 files changed, 124 insertions(+), 1 deletion(-) create mode 100755 tests/ocfs2/001 create mode 100644 tests/ocfs2/001.out create mode 100644 tests/ocfs2/Makefile create mode 100644 tests/ocfs2/group diff --git a/common/reflink b/common/reflink index 9d51729..d048045 100644 --- a/common/reflink +++ b/common/reflink @@ -197,7 +197,7 @@ _cp_reflink() { file1="$1" file2="$2" - cp --reflink=always -p "$file1" "$file2" + cp --reflink=always -p -f "$file1" "$file2" } # Reflink some file1 into file2 diff --git a/tests/ocfs2/001 b/tests/ocfs2/001 new file mode 100755 index 0000000..afb9ce9 --- /dev/null +++ b/tests/ocfs2/001 @@ -0,0 +1,88 @@ +#! /bin/bash +# FS QA Test No. 001 +# +# Ensure that reflink works correctly with inline-data files. +# +#----------------------------------------------------------------------- +# Copyright (c) 2016, Oracle and/or its affiliates. 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 -rf $tmp.* +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter +. ./common/reflink + +# real QA test starts here +_supported_os Linux +_supported_fs ocfs2 +_require_scratch_reflink +_require_cp_reflink + +rm -f $seqres.full + +echo "Format and mount" +_scratch_mkfs --fs-features=local,unwritten,refcount,inline-data > $seqres.full 2>&1 +tunefs.ocfs2 --query '%H' $SCRATCH_DEV | grep -q 'inline-data' || \ + _notrun "Inline data is not supported." +_scratch_mount >> $seqres.full 2>&1 + +testdir=$SCRATCH_MNT/test-$seq +mkdir $testdir + +sz=65536 +echo "Create the original files" +$XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full +echo x > $testdir/file2 +echo x > $testdir/file3 +echo y > $testdir/file4 +$XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file5 >> $seqres.full +echo a > $testdir/file6 +_scratch_cycle_mount + +echo "reflink into the start of file2" +_cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full + +echo "reflink past the stuff in file3" +_reflink_range $testdir/file1 0 $testdir/file3 $sz $sz >> $seqres.full + +echo "reflink an inline-data file to a regular one" +_cp_reflink $testdir/file4 $testdir/file5 >> $seqres.full + +echo "reflink an inline-data file to another inline-data file" +_cp_reflink $testdir/file4 $testdir/file6 >> $seqres.full + +echo "Verify the whole mess" +_scratch_cycle_mount +md5sum $testdir/file* | _filter_scratch + +# success, all done +status=0 +exit diff --git a/tests/ocfs2/001.out b/tests/ocfs2/001.out new file mode 100644 index 0000000..99fa43a --- /dev/null +++ b/tests/ocfs2/001.out @@ -0,0 +1,14 @@ +QA output created by 001 +Format and mount +Create the original files +reflink into the start of file2 +reflink past the stuff in file3 +reflink an inline-data file to a regular one +reflink an inline-data file to another inline-data file +Verify the whole mess +2d61aa54b58c2e94403fb092c3dbc027 SCRATCH_MNT/test-001/file1 +2d61aa54b58c2e94403fb092c3dbc027 SCRATCH_MNT/test-001/file2 +4e68a2e24b6b0f386ab39d01d902293d SCRATCH_MNT/test-001/file3 +009520053b00386d1173f3988c55d192 SCRATCH_MNT/test-001/file4 +009520053b00386d1173f3988c55d192 SCRATCH_MNT/test-001/file5 +009520053b00386d1173f3988c55d192 SCRATCH_MNT/test-001/file6 diff --git a/tests/ocfs2/Makefile b/tests/ocfs2/Makefile new file mode 100644 index 0000000..70a4f16 --- /dev/null +++ b/tests/ocfs2/Makefile @@ -0,0 +1,20 @@ +# +# Copyright (c) 2016 Oracle. All Rights Reserved. +# + +TOPDIR = ../.. +include $(TOPDIR)/include/builddefs + +OCFS2_DIR = ocfs2 +TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(OCFS2_DIR) + +include $(BUILDRULES) + +install: + $(INSTALL) -m 755 -d $(TARGET_DIR) + $(INSTALL) -m 755 $(TESTS) $(TARGET_DIR) + $(INSTALL) -m 644 group $(TARGET_DIR) + $(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR) + +# Nothing. +install-dev install-lib: diff --git a/tests/ocfs2/group b/tests/ocfs2/group new file mode 100644 index 0000000..28e6807 --- /dev/null +++ b/tests/ocfs2/group @@ -0,0 +1 @@ +001 auto quick clone
Darrick J. Wong
2016-Dec-11 21:52 UTC
[Ocfs2-devel] [PATCH 2/7] ocfs2/reflink: fix file block size reporting
Some of the reflink tests try to require a specific filesystem block size so that they can test file block manipulation functions. That's straightforward for most filesystems but ocfs2 throws in the additional twist that data fork block mappings are stored in units of clusters, not blocks, which causes these reflink tests to fail. Therefore, introduce a new helper that retrieves the file minimum block size and adapt the reflink tests to use that instead. Signed-off-by: Darrick J. Wong <darrick.wong at oracle.com> --- common/rc | 21 +++++++++++++++++++-- tests/generic/205 | 2 +- tests/generic/206 | 2 +- tests/generic/216 | 2 +- tests/generic/217 | 2 +- tests/generic/218 | 2 +- tests/generic/220 | 2 +- tests/generic/222 | 2 +- tests/generic/227 | 2 +- tests/generic/229 | 2 +- tests/generic/238 | 2 +- 11 files changed, 29 insertions(+), 12 deletions(-) diff --git a/common/rc b/common/rc index 2639fbd..30111d4 100644 --- a/common/rc +++ b/common/rc @@ -925,7 +925,7 @@ _scratch_mkfs_blocksized() ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV ;; ocfs2) - yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize $SCRATCH_DEV + yes | ${MKFS_PROG}.$FSTYP -F $MKFS_OPTIONS -b $blocksize -C $blocksize $SCRATCH_DEV ;; *) _notrun "Filesystem $FSTYP not supported in _scratch_mkfs_blocksized" @@ -3029,13 +3029,30 @@ _sysfs_dev() echo /sys/dev/block/$_maj:$_min } +# Get the minimum block size of a file. Usually this is the +# minimum fs block size, but some filesystems (ocfs2) do block +# mappings in larger units. +get_file_block_size() +{ + if [ -z $1 ] || [ ! -d $1 ]; then + echo "Missing mount point argument for get_file_block_size" + exit 1 + fi + if [ "$FSTYP" = "ocfs2" ]; then + stat -c '%o' $1 + else + stat -f -c '%S' $1 + fi +} + +# Get the minimum block size of an fs. get_block_size() { if [ -z $1 ] || [ ! -d $1 ]; then echo "Missing mount point argument for get_block_size" exit 1 fi - echo `stat -f -c %S $1` + stat -f -c %S $1 } get_page_size() diff --git a/tests/generic/205 b/tests/generic/205 index cfda8c3..7889ca4 100755 --- a/tests/generic/205 +++ b/tests/generic/205 @@ -60,7 +60,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/206 b/tests/generic/206 index 909956f..f82e146 100755 --- a/tests/generic/206 +++ b/tests/generic/206 @@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/216 b/tests/generic/216 index d9b868a..cbff75f 100755 --- a/tests/generic/216 +++ b/tests/generic/216 @@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/217 b/tests/generic/217 index 65113d9..5f59fd8 100755 --- a/tests/generic/217 +++ b/tests/generic/217 @@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/218 b/tests/generic/218 index 21029ef..bdce367 100755 --- a/tests/generic/218 +++ b/tests/generic/218 @@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/220 b/tests/generic/220 index c54bf06..29d2f04 100755 --- a/tests/generic/220 +++ b/tests/generic/220 @@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/222 b/tests/generic/222 index d7ee57e..3052a22 100755 --- a/tests/generic/222 +++ b/tests/generic/222 @@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/227 b/tests/generic/227 index fa6a33e..18441cf 100755 --- a/tests/generic/227 +++ b/tests/generic/227 @@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." echo "Create the original files" diff --git a/tests/generic/229 b/tests/generic/229 index 3e2c6f4..99eb774 100755 --- a/tests/generic/229 +++ b/tests/generic/229 @@ -61,7 +61,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." runtest() { diff --git a/tests/generic/238 b/tests/generic/238 index a2f44e8..5419a30 100755 --- a/tests/generic/238 +++ b/tests/generic/238 @@ -62,7 +62,7 @@ _scratch_mount >> $seqres.full 2>&1 testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -real_blksz=$(get_block_size $testdir) +real_blksz=$(get_file_block_size $testdir) test $real_blksz != $blksz && _notrun "Failed to format with small blocksize." runtest() {
Darrick J. Wong
2016-Dec-11 21:53 UTC
[Ocfs2-devel] [PATCH 3/7] reflink: fix quota tests to work properly
Fix the reflink quota tests to su to the fsgqa user so that we actually test enforcement of quotas. Seems that XFS enforces user quotas even if root is writing to a user file, whereas everything else lets root writes through. Also clean up some of the variable usage and _require_user. Signed-off-by: Darrick J. Wong <darrick.wong at oracle.com> --- tests/generic/305 | 2 +- tests/generic/305.out | 30 +++++++++++++++--------------- tests/generic/326 | 2 +- tests/generic/326.out | 30 +++++++++++++++--------------- tests/generic/327 | 12 +++++++----- tests/generic/327.out | 12 ++++++------ tests/generic/328 | 14 ++++++++------ tests/generic/328.out | 28 ++++++++++++++-------------- 8 files changed, 67 insertions(+), 63 deletions(-) diff --git a/tests/generic/305 b/tests/generic/305 index d73d87f..9c3489b 100755 --- a/tests/generic/305 +++ b/tests/generic/305 @@ -51,7 +51,7 @@ _require_quota _require_nobody _repquota() { - repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)' + repquota -O csv $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)' | awk -F ',' '{print $1, $4, $5, $6}' } rm -f $seqres.full diff --git a/tests/generic/305.out b/tests/generic/305.out index 0bfd620..fbd4e24 100644 --- a/tests/generic/305.out +++ b/tests/generic/305.out @@ -1,22 +1,22 @@ QA output created by 305 Format and mount Create the original files -root -- 3072 0 0 7 0 0 -nobody -- 0 0 0 1 0 0 -fsgqa -- 0 0 0 1 0 0 +root 3072 0 0 +nobody 0 0 0 +fsgqa 0 0 0 Change file ownership -root -- 0 0 0 4 0 0 -nobody -- 0 0 0 1 0 0 -fsgqa -- 3072 0 0 4 0 0 +root 0 0 0 +nobody 0 0 0 +fsgqa 3072 0 0 CoW one of the files -root -- 0 0 0 4 0 0 -nobody -- 0 0 0 1 0 0 -fsgqa -- 3072 0 0 4 0 0 +root 0 0 0 +nobody 0 0 0 +fsgqa 3072 0 0 Remount the FS to see if accounting changes -root -- 0 0 0 4 0 0 -nobody -- 0 0 0 1 0 0 -fsgqa -- 3072 0 0 4 0 0 +root 0 0 0 +nobody 0 0 0 +fsgqa 3072 0 0 Chown one of the files -root -- 0 0 0 4 0 0 -nobody -- 1024 0 0 2 0 0 -fsgqa -- 2048 0 0 3 0 0 +root 0 0 0 +nobody 1024 0 0 +fsgqa 2048 0 0 diff --git a/tests/generic/326 b/tests/generic/326 index 8afc6a2..b86f6a2 100755 --- a/tests/generic/326 +++ b/tests/generic/326 @@ -52,7 +52,7 @@ _require_nobody _require_odirect _repquota() { - repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)' + repquota -O csv $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)' | awk -F ',' '{print $1, $4, $5, $6}' } rm -f $seqres.full diff --git a/tests/generic/326.out b/tests/generic/326.out index e771eb7..de7f20b 100644 --- a/tests/generic/326.out +++ b/tests/generic/326.out @@ -1,22 +1,22 @@ QA output created by 326 Format and mount Create the original files -root -- 3072 0 0 7 0 0 -nobody -- 0 0 0 1 0 0 -fsgqa -- 0 0 0 1 0 0 +root 3072 0 0 +nobody 0 0 0 +fsgqa 0 0 0 Change file ownership -root -- 0 0 0 4 0 0 -nobody -- 0 0 0 1 0 0 -fsgqa -- 3072 0 0 4 0 0 +root 0 0 0 +nobody 0 0 0 +fsgqa 3072 0 0 CoW one of the files -root -- 0 0 0 4 0 0 -nobody -- 0 0 0 1 0 0 -fsgqa -- 3072 0 0 4 0 0 +root 0 0 0 +nobody 0 0 0 +fsgqa 3072 0 0 Remount the FS to see if accounting changes -root -- 0 0 0 4 0 0 -nobody -- 0 0 0 1 0 0 -fsgqa -- 3072 0 0 4 0 0 +root 0 0 0 +nobody 0 0 0 +fsgqa 3072 0 0 Chown one of the files -root -- 0 0 0 4 0 0 -nobody -- 1024 0 0 2 0 0 -fsgqa -- 2048 0 0 3 0 0 +root 0 0 0 +nobody 1024 0 0 +fsgqa 2048 0 0 diff --git a/tests/generic/327 b/tests/generic/327 index c165ad5..29706e9 100755 --- a/tests/generic/327 +++ b/tests/generic/327 @@ -48,9 +48,10 @@ _require_cp_reflink _require_fiemap _require_quota _require_nobody +_require_user _repquota() { - repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)' + repquota -O csv $SCRATCH_MNT | egrep "^($qa_user|root|nobody)" | awk -F ',' '{print $1, $4, $5, $6}' } rm -f $seqres.full @@ -67,19 +68,20 @@ mkdir $testdir sz=1048576 echo "Create the original files" $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full -chown fsgqa $testdir/file1 +chown $qa_user $testdir/file1 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full _repquota _scratch_cycle_mount +quotaon $SCRATCH_MNT 2> /dev/null echo "Set hard quota to prevent third reflink" -setquota -u fsgqa 0 1024 0 0 $SCRATCH_MNT +setquota -u $qa_user 0 1024 0 0 $SCRATCH_MNT _repquota echo "Try to reflink again" touch $testdir/file3 -chown fsgqa $testdir/file3 -_cp_reflink $testdir/file1 $testdir/file3 2>&1 | _filter_scratch +chown $qa_user $testdir/file3 +su $qa_user -c "cp --reflink=always -f $testdir/file1 $testdir/file3" 2>&1 | _filter_scratch _repquota # success, all done diff --git a/tests/generic/327.out b/tests/generic/327.out index 7160ff2..f4e145a 100644 --- a/tests/generic/327.out +++ b/tests/generic/327.out @@ -1,12 +1,12 @@ QA output created by 327 Format and mount Create the original files -root -- 0 0 0 4 0 0 -fsgqa -- 2048 0 0 2 0 0 +root 0 0 0 +fsgqa 2048 0 0 Set hard quota to prevent third reflink -root -- 0 0 0 4 0 0 -fsgqa +- 2048 0 1024 2 0 0 +root 0 0 0 +fsgqa 2048 0 1024 Try to reflink again cp: failed to clone 'SCRATCH_MNT/test-327/file3' from 'SCRATCH_MNT/test-327/file1': Disk quota exceeded -root -- 0 0 0 4 0 0 -fsgqa +- 2048 0 1024 3 0 0 +root 0 0 0 +fsgqa 2048 0 1024 diff --git a/tests/generic/328 b/tests/generic/328 index 705368e..7800246 100755 --- a/tests/generic/328 +++ b/tests/generic/328 @@ -49,9 +49,10 @@ _require_fiemap _require_quota _require_nobody _require_odirect +_require_user _repquota() { - repquota $SCRATCH_MNT | egrep '^(fsgqa|root|nobody)' + repquota -O csv $SCRATCH_MNT | egrep "^($qa_user|root|nobody)" | awk -F ',' '{print $1, $4, $5, $6}' } rm -f $seqres.full @@ -68,28 +69,29 @@ mkdir $testdir sz=1048576 echo "Create the original files" $XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full -chown fsgqa $testdir/file1 +chown $qa_user $testdir/file1 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full _repquota _scratch_cycle_mount +quotaon $SCRATCH_MNT 2> /dev/null echo "Set hard quota to prevent rewrite" -setquota -u fsgqa 0 1024 0 0 $SCRATCH_MNT +setquota -u $qa_user 0 1024 0 0 $SCRATCH_MNT _repquota echo "Try to dio write the whole file" -_pwrite_byte 0x62 0 $sz $testdir/file1 -d 2>&1 >> $seqres.full | \ +su $qa_user -c '$XFS_IO_PROG -d -c "pwrite 0 '$((sz+65536))'" '$testdir'/file1' 2>&1 >> $seqres.full | \ _filter_xfs_io_error _repquota echo "Try to write the whole file" -_pwrite_byte 0x62 0 $sz $testdir/file1 2>&1 >> $seqres.full | \ +su $qa_user -c '$XFS_IO_PROG -c "pwrite 0 '$((sz+65536))'" '$testdir'/file1' 2>&1 >> $seqres.full | \ _filter_xfs_io_error _repquota echo "Set hard quota to allow rewrite" -setquota -u fsgqa 0 8192 0 0 $SCRATCH_MNT +setquota -u $qa_user 0 8192 0 0 $SCRATCH_MNT _repquota echo "Try to dio write the whole file" diff --git a/tests/generic/328.out b/tests/generic/328.out index 4630151..b7fe9f8 100644 --- a/tests/generic/328.out +++ b/tests/generic/328.out @@ -1,25 +1,25 @@ QA output created by 328 Format and mount Create the original files -root -- 0 0 0 4 0 0 -fsgqa -- 3072 0 0 3 0 0 +root 0 0 0 +fsgqa 3072 0 0 Set hard quota to prevent rewrite -root -- 0 0 0 4 0 0 -fsgqa +- 3072 0 1024 3 0 0 +root 0 0 0 +fsgqa 3072 0 1024 Try to dio write the whole file pwrite: Disk quota exceeded -root -- 0 0 0 4 0 0 -fsgqa +- 3072 0 1024 3 0 0 +root 0 0 0 +fsgqa 3072 0 1024 Try to write the whole file pwrite: Disk quota exceeded -root -- 0 0 0 4 0 0 -fsgqa +- 3072 0 1024 3 0 0 +root 0 0 0 +fsgqa 3072 0 1024 Set hard quota to allow rewrite -root -- 0 0 0 4 0 0 -fsgqa -- 3072 0 8192 3 0 0 +root 0 0 0 +fsgqa 3072 0 8192 Try to dio write the whole file -root -- 0 0 0 4 0 0 -fsgqa -- 3072 0 8192 3 0 0 +root 0 0 0 +fsgqa 3072 0 8192 Try to write the whole file -root -- 0 0 0 4 0 0 -fsgqa -- 3072 0 8192 3 0 0 +root 0 0 0 +fsgqa 3072 0 8192
Darrick J. Wong
2016-Dec-11 21:53 UTC
[Ocfs2-devel] [PATCH 4/7] reflink: fix space consumption tests
Some of the tests try to check that we can't COW when we're out of space, but some tricky filesystems make this hard because writing N blocks doesn't increase used blocks by N.... Signed-off-by: Darrick J. Wong <darrick.wong at oracle.com> --- common/populate | 14 ++++++++++++++ tests/generic/171 | 5 ++--- tests/generic/173 | 5 ++--- tests/generic/174 | 5 ++--- tests/generic/282 | 3 +-- 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/common/populate b/common/populate index d0003c5..9811d21 100644 --- a/common/populate +++ b/common/populate @@ -30,6 +30,20 @@ _require_xfs_db_blocktrash_z_command() { $XFS_DB_PROG -x -f -c 'blocktrash -z' "${TEST_DEV}" | grep -q 'nothing on stack' || _notrun "blocktrash -z not supported" } +# Eat free space until we can't anymore. +_consume_free_space() { + dir=$1 + + old_nr_free=0 + nr_free=$(stat -f -c '%f' $dir) + x=0 + while [ $nr_free -gt 0 ] && [ $old_nr_free != $nr_free ]; do + $XFS_IO_PROG -f -c "pwrite -b 4194304 0 $((blksz * nr_free))" $dir/eat_my_space.$((x++)) + old_nr_free=$nr_free + nr_free=$(stat -f -c '%f' $dir) + done +} + # Attempt to make files of "every" format for data, dirs, attrs etc. # (with apologies to Eric Sandeen for mutating xfser.sh) diff --git a/tests/generic/171 b/tests/generic/171 index b01dbd5..d96fd17 100755 --- a/tests/generic/171 +++ b/tests/generic/171 @@ -41,6 +41,7 @@ _cleanup() . ./common/filter . ./common/attr . ./common/reflink +. ./common/populate # real QA test starts here _supported_os Linux @@ -75,9 +76,7 @@ _cp_reflink $testdir/bigfile $testdir/clonefile sync echo "Allocate the rest of the space" -nr_free=$(stat -f -c '%f' $testdir) -touch $testdir/file0 $testdir/file1 -_pwrite_byte 0x61 0 $((blksz * nr_free)) $testdir/eat_my_space >> $seqres.full 2>&1 +_consume_free_space $testdir >> $seqres.full 2>&1 sync echo "CoW the big file" diff --git a/tests/generic/173 b/tests/generic/173 index e35597f..20c6091 100755 --- a/tests/generic/173 +++ b/tests/generic/173 @@ -41,6 +41,7 @@ _cleanup() . ./common/filter . ./common/attr . ./common/reflink +. ./common/populate # real QA test starts here _supported_os Linux @@ -75,9 +76,7 @@ _cp_reflink $testdir/bigfile $testdir/clonefile sync echo "Allocate the rest of the space" -nr_free=$(stat -f -c '%f' $testdir) -touch $testdir/file0 $testdir/file1 -_pwrite_byte 0x61 0 $((blksz * nr_free)) $testdir/eat_my_space >> $seqres.full 2>&1 +_consume_free_space $testdir >> $seqres.full 2>&1 sync echo "mmap CoW the big file" diff --git a/tests/generic/174 b/tests/generic/174 index 38fad1d..d811307 100755 --- a/tests/generic/174 +++ b/tests/generic/174 @@ -41,6 +41,7 @@ _cleanup() . ./common/filter . ./common/attr . ./common/reflink +. ./common/populate # real QA test starts here _supported_os Linux @@ -76,9 +77,7 @@ _cp_reflink $testdir/bigfile $testdir/clonefile sync echo "Allocate the rest of the space" -nr_free=$(stat -f -c '%f' $testdir) -touch $testdir/file0 $testdir/file1 -_pwrite_byte 0x61 0 $((blksz * nr_free)) $testdir/eat_my_space >> $seqres.full 2>&1 +_consume_free_space $testdir >> $seqres.full 2>&1 sync echo "CoW the big file" diff --git a/tests/generic/282 b/tests/generic/282 index 6452025..8a30811 100755 --- a/tests/generic/282 +++ b/tests/generic/282 @@ -80,8 +80,7 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" sync _dmerror_load_error_table -urk=$($XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" $testdir/file2 > $TEST_DIR/mwrite.out 2>&1) -cat $TEST_DIR/mwrite.out | tee -a $seqres.full +$XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" $testdir/file2 >> $seqres.full 2>&1 _dmerror_load_working_table rm -rf $testdir/file2 >> $seqres.full 2>&1 _dmerror_unmount
Darrick J. Wong
2016-Dec-11 21:53 UTC
[Ocfs2-devel] [PATCH 5/7] reflink: make error reporting consistent
When we're using dm-error to simulate failed devices, we don't really know if the write or the fdatasync is going to receive the EIO. So, capture the entire output and just look for the word error instead of enshrining it in the golden output. Signed-off-by: Darrick J. Wong <darrick.wong at oracle.com> --- tests/generic/265 | 6 +++++- tests/generic/265.out | 1 - tests/generic/266 | 5 ++++- tests/generic/266.out | 1 - tests/generic/267 | 2 +- tests/generic/268 | 5 ++++- tests/generic/268.out | 1 - tests/generic/271 | 5 +++-- tests/generic/271.out | 1 - tests/generic/272 | 5 +++-- tests/generic/272.out | 1 - tests/generic/276 | 2 +- tests/generic/276.out | 1 - tests/generic/278 | 5 +++-- tests/generic/278.out | 1 - tests/generic/279 | 4 ++-- tests/generic/279.out | 1 - tests/generic/281 | 4 ++-- tests/generic/281.out | 1 - tests/generic/283 | 6 ++++-- tests/generic/283.out | 1 - 21 files changed, 32 insertions(+), 27 deletions(-) diff --git a/tests/generic/265 b/tests/generic/265 index 8e9d5bc..ceddfbe 100755 --- a/tests/generic/265 +++ b/tests/generic/265 @@ -80,7 +80,11 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" sync _dmerror_load_error_table -$XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" -c "fdatasync" $testdir/file2 >> $seqres.full +urk=$($XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" \ + -c "fdatasync" $testdir/file2 2>&1) +echo $urk >> $seqres.full +echo "$urk" | grep -q "error" || _fail "pwrite did not fail" + _dmerror_load_working_table _dmerror_unmount _dmerror_mount diff --git a/tests/generic/265.out b/tests/generic/265.out index 1b67114..31eb4e9 100644 --- a/tests/generic/265.out +++ b/tests/generic/265.out @@ -5,7 +5,6 @@ Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-265/file1 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-265/file2 CoW and unmount -fdatasync: Input/output error Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-265/file1 Check for damage diff --git a/tests/generic/266 b/tests/generic/266 index 4f9816a..09541c8 100755 --- a/tests/generic/266 +++ b/tests/generic/266 @@ -80,7 +80,10 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" sync _dmerror_load_error_table -$XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" -c "fdatasync" $testdir/file2 >> $seqres.full +urk=$($XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" \ + -c "fdatasync" $testdir/file2 2>&1) +echo $urk >> $seqres.full +echo "$urk" | grep -q "error" || _fail "pwrite did not fail" echo "Clean up the mess" _dmerror_unmount diff --git a/tests/generic/266.out b/tests/generic/266.out index dd34ad3..1641654 100644 --- a/tests/generic/266.out +++ b/tests/generic/266.out @@ -5,7 +5,6 @@ Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-266/file1 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-266/file2 CoW and unmount -fdatasync: Input/output error Clean up the mess Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-266/file1 diff --git a/tests/generic/267 b/tests/generic/267 index e3a6b0c..2ec6ad9 100755 --- a/tests/generic/267 +++ b/tests/generic/267 @@ -80,7 +80,7 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" sync _dmerror_load_error_table -$XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 >> $seqres.full +$XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 >> $seqres.full 2>&1 _dmerror_load_working_table rm -rf $testdir/file2 >> $seqres.full 2>&1 _dmerror_unmount diff --git a/tests/generic/268 b/tests/generic/268 index c7dcd57..b7d16ab 100755 --- a/tests/generic/268 +++ b/tests/generic/268 @@ -81,7 +81,10 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" sync _dmerror_load_error_table -$XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" -c "fdatasync" $testdir/file2 >> $seqres.full +urk=$($XFS_IO_PROG -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" \ + -c "fdatasync" $testdir/file2 2>&1) +echo $urk >> $seqres.full +echo "$urk" | grep -q "error" || _fail "pwrite did not fail" _dmerror_load_working_table echo "Rewrite" diff --git a/tests/generic/268.out b/tests/generic/268.out index 234e8be..1a3b39a 100644 --- a/tests/generic/268.out +++ b/tests/generic/268.out @@ -5,7 +5,6 @@ Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-268/file1 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-268/file2 CoW and unmount -fdatasync: Input/output error Rewrite Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-268/file1 diff --git a/tests/generic/271 b/tests/generic/271 index ded8854..9439327 100755 --- a/tests/generic/271 +++ b/tests/generic/271 @@ -81,8 +81,9 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" sync _dmerror_load_error_table -$XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 \ - 2>&1 >> $seqres.full | _filter_xfs_io_error +urk=$($XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 2>&1) +echo $urk >> $seqres.full +echo "$urk" | grep -q "error" || _fail "dio pwrite did not fail" _dmerror_load_working_table _dmerror_unmount _dmerror_mount diff --git a/tests/generic/271.out b/tests/generic/271.out index 54d5b0d..9b44ee7 100644 --- a/tests/generic/271.out +++ b/tests/generic/271.out @@ -5,7 +5,6 @@ Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-271/file1 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-271/file2 CoW and unmount -pwrite: Input/output error Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-271/file1 Check for damage diff --git a/tests/generic/272 b/tests/generic/272 index 5bc5b39..243adf5 100755 --- a/tests/generic/272 +++ b/tests/generic/272 @@ -81,8 +81,9 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" sync _dmerror_load_error_table -$XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 \ - 2>&1 >> $seqres.full | _filter_xfs_io_error +urk=$($XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 2>&1) +echo $urk >> $seqres.full +echo "$urk" | grep -q "error" || _fail "dio pwrite did not fail" echo "Clean up the mess" _dmerror_unmount diff --git a/tests/generic/272.out b/tests/generic/272.out index 0b8bdca..10ecda9 100644 --- a/tests/generic/272.out +++ b/tests/generic/272.out @@ -5,7 +5,6 @@ Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-272/file1 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-272/file2 CoW and unmount -pwrite: Input/output error Clean up the mess Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-272/file1 diff --git a/tests/generic/276 b/tests/generic/276 index 83b902e..34b0029 100755 --- a/tests/generic/276 +++ b/tests/generic/276 @@ -82,7 +82,7 @@ echo "CoW and unmount" sync _dmerror_load_error_table $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 \ - 2>&1 >> $seqres.full | _filter_xfs_io_error + >> $seqres.full 2>&1 _dmerror_load_working_table rm -rf $testdir/file2 >> $seqres.full 2>&1 _dmerror_unmount diff --git a/tests/generic/276.out b/tests/generic/276.out index 88a0162..a080dd0 100644 --- a/tests/generic/276.out +++ b/tests/generic/276.out @@ -5,7 +5,6 @@ Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-276/file1 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-276/file2 CoW and unmount -pwrite: Input/output error Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-276/file1 Check for damage diff --git a/tests/generic/278 b/tests/generic/278 index 415742a..d751f01 100755 --- a/tests/generic/278 +++ b/tests/generic/278 @@ -82,8 +82,9 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" sync _dmerror_load_error_table -$XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 \ - 2>&1 >> $seqres.full | _filter_xfs_io_error +urk=$($XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $bufsize 0 $filesize" $testdir/file2 2>&1) +echo $urk >> $seqres.full +echo "$urk" | grep -q "error" || _fail "dio pwrite did not fail" _dmerror_load_working_table echo "Rewrite" diff --git a/tests/generic/278.out b/tests/generic/278.out index 9ead4ac..cd22fcd 100644 --- a/tests/generic/278.out +++ b/tests/generic/278.out @@ -5,7 +5,6 @@ Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-278/file1 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-278/file2 CoW and unmount -pwrite: Input/output error Rewrite Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-278/file1 diff --git a/tests/generic/279 b/tests/generic/279 index 2f1ec4f..4541de3 100755 --- a/tests/generic/279 +++ b/tests/generic/279 @@ -80,8 +80,8 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" sync _dmerror_load_error_table -urk=$($XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" -c "msync -s 0 $filesize" $testdir/file2 > $TEST_DIR/mwrite.out 2>&1) -cat $TEST_DIR/mwrite.out | tee -a $seqres.full +$XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" \ + -c "msync -s 0 $filesize" $testdir/file2 >> $seqres.full 2>&1 _dmerror_load_working_table _dmerror_unmount _dmerror_mount diff --git a/tests/generic/279.out b/tests/generic/279.out index f34c2b2..009f05e 100644 --- a/tests/generic/279.out +++ b/tests/generic/279.out @@ -5,7 +5,6 @@ Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-279/file1 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-279/file2 CoW and unmount -msync: Input/output error Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-279/file1 Check for damage diff --git a/tests/generic/281 b/tests/generic/281 index c95acf2..e8e1661 100755 --- a/tests/generic/281 +++ b/tests/generic/281 @@ -80,8 +80,8 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" sync _dmerror_load_error_table -urk=$($XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" -c "msync -s 0 $filesize" $testdir/file2 > $TEST_DIR/mwrite.out 2>&1) -cat $TEST_DIR/mwrite.out | tee -a $seqres.full +$XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" \ + -c "msync -s 0 $filesize" $testdir/file2 >> $seqres.full 2>&1 echo "Clean up the mess" _dmerror_unmount diff --git a/tests/generic/281.out b/tests/generic/281.out index a2d8e3f..1bae187 100644 --- a/tests/generic/281.out +++ b/tests/generic/281.out @@ -5,7 +5,6 @@ Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-281/file1 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-281/file2 CoW and unmount -msync: Input/output error Clean up the mess Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-281/file1 diff --git a/tests/generic/283 b/tests/generic/283 index 8d56ac3..7bfdb4d 100755 --- a/tests/generic/283 +++ b/tests/generic/283 @@ -81,8 +81,10 @@ md5sum $testdir/file2 | _filter_scratch echo "CoW and unmount" sync _dmerror_load_error_table -urk=$($XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" -c "msync -s 0 $filesize" $testdir/file2 > $TEST_DIR/mwrite.out 2>&1) -cat $TEST_DIR/mwrite.out | tee -a $seqres.full +urk=$($XFS_IO_PROG -f -c "mmap -rw 0 $filesize" -c "mwrite -S 0x63 0 $filesize" \ + -c "msync -s 0 $filesize" $testdir/file2 2>&1) +echo $urk >> $seqres.full +echo "$urk" | grep -q "error" || _fail "mwrite did not fail" _dmerror_load_working_table echo "Rewrite" diff --git a/tests/generic/283.out b/tests/generic/283.out index f9fd5c8..b475054 100644 --- a/tests/generic/283.out +++ b/tests/generic/283.out @@ -5,7 +5,6 @@ Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-283/file1 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-283/file2 CoW and unmount -msync: Input/output error Rewrite Compare files 1886e67cf8783e89ce6ddc5bb09a3944 SCRATCH_MNT/test-283/file1
Darrick J. Wong
2016-Dec-11 21:53 UTC
[Ocfs2-devel] [PATCH 6/7] reflink: don't test disjoint block sharing sets
Unlike xfs/btrfs which store refcounting information as part of the space metadata, ocfs2 implements block sharing (reflink) by creating refcount btrees that are shared between subsets of files. Effectively, this means that a ocfs2 can have multiple disjoint sets of files that share blocks, which also means that blocks cannot be reflinked between two disjoint refcounted-file-sets. generic/119 tests the ability to do this, so we cannot run it for ocfs2. Create a _require helper to check for this. Signed-off-by: Darrick J. Wong <darrick.wong at oracle.com> --- common/reflink | 9 +++++++++ tests/generic/119 | 1 + 2 files changed, 10 insertions(+) diff --git a/common/reflink b/common/reflink index d048045..55d82ac 100644 --- a/common/reflink +++ b/common/reflink @@ -28,6 +28,15 @@ _require_cp_reflink() _notrun "This test requires a cp with --reflink support." } +# Can we reflink between arbitrary file sets? +# i.e. if we reflink a->b and c->d, can we later share +# blocks between b & c? +_require_arbitrary_fileset_reflink() +{ + test "$FSTYP" = "ocfs2" && \ + _notrun "reflink between arbitrary file groups not supported in $FSTYP" +} + # Given 2 files, verify that they have the same mapping but different # inodes - i.e. an undisturbed reflink # Silent if so, make noise if not diff --git a/tests/generic/119 b/tests/generic/119 index e6a6f59..b28e044 100755 --- a/tests/generic/119 +++ b/tests/generic/119 @@ -47,6 +47,7 @@ _cleanup() # real QA test starts here _supported_os Linux _require_test_reflink +_require_arbitrary_fileset_reflink rm -f $seqres.full
Darrick J. Wong
2016-Dec-11 21:53 UTC
[Ocfs2-devel] [PATCH 7/7] xfs/ext4: check negative inode size
Craft a malicious filesystem image with a negative inode size, then try to trigger a kernel DoS by appending data to the file. Ideally this should trigger verifier errors instead of hanging. Signed-off-by: Darrick J. Wong <darrick.wong at oracle.com> --- tests/ext4/400 | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/401 | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/ext4/group | 2 ++ tests/xfs/400 | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/401 | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/group | 2 ++ 6 files changed, 290 insertions(+) create mode 100755 tests/ext4/400 create mode 100755 tests/ext4/401 create mode 100755 tests/xfs/400 create mode 100755 tests/xfs/401 diff --git a/tests/ext4/400 b/tests/ext4/400 new file mode 100755 index 0000000..5857549 --- /dev/null +++ b/tests/ext4/400 @@ -0,0 +1,71 @@ +#! /bin/bash +# FSQA Test No. 400 +# +# 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. +# +#----------------------------------------------------------------------- +# Copyright (c) 2016-2017 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" + +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 + +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 -w -R "sif /a size -1" $SCRATCH_DEV >> $seqres.full 2>&1 + +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/401 b/tests/ext4/401 new file mode 100755 index 0000000..ee7ecf3 --- /dev/null +++ b/tests/ext4/401 @@ -0,0 +1,71 @@ +#! /bin/bash +# FSQA Test No. 401 +# +# 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. +# +#----------------------------------------------------------------------- +# Copyright (c) 2016-2017 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" + +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 + +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 -w -R "sif /a size 0xFFFFFFFFFFFFFE00" $SCRATCH_DEV >> $seqres.full 2>&1 + +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/group b/tests/ext4/group index 53fe03e..43b2d06 100644 --- a/tests/ext4/group +++ b/tests/ext4/group @@ -34,3 +34,5 @@ 306 auto rw resize quick 307 auto ioctl rw 308 auto ioctl rw prealloc quick +400 dangerous_fuzzers +401 dangerous_fuzzers diff --git a/tests/xfs/400 b/tests/xfs/400 new file mode 100755 index 0000000..498c024 --- /dev/null +++ b/tests/xfs/400 @@ -0,0 +1,72 @@ +#! /bin/bash +# FSQA Test No. 400 +# +# 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. +# +#----------------------------------------------------------------------- +# Copyright (c) 2016-2017 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" + +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 xfs +_require_scratch_nocheck +_disable_dmesg_check + +rm -f $seqres.full + +echo "Format and mount" +_scratch_mkfs >> $seqres.full 2>&1 +_scratch_mount + +testdir=$SCRATCH_MNT +echo m > $testdir/a +inum=$(stat -c "%i" $testdir/a) + +echo "Corrupt filesystem" +_scratch_unmount +_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -1' >> $seqres.full + +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/xfs/401 b/tests/xfs/401 new file mode 100755 index 0000000..41b262d --- /dev/null +++ b/tests/xfs/401 @@ -0,0 +1,72 @@ +#! /bin/bash +# FSQA Test No. 401 +# +# 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. +# +#----------------------------------------------------------------------- +# Copyright (c) 2016-2017 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" + +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 xfs +_require_scratch_nocheck +_disable_dmesg_check + +rm -f $seqres.full + +echo "Format and mount" +_scratch_mkfs >> $seqres.full 2>&1 +_scratch_mount + +testdir=$SCRATCH_MNT +echo m > $testdir/a +inum=$(stat -c "%i" $testdir/a) + +echo "Corrupt filesystem" +_scratch_unmount +_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -1' >> $seqres.full + +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/xfs/group b/tests/xfs/group index c237b50..10ba27b 100644 --- a/tests/xfs/group +++ b/tests/xfs/group @@ -334,3 +334,5 @@ 345 auto quick clone 346 auto quick clone 347 auto quick clone +400 dangerous_fuzzers +401 dangerous_fuzzers