4 # Since loff_t is a signed type, it is invalid for a filesystem to load
5 # an inode with i_size = -1ULL. Unfortunately, nobody checks this,
6 # which means that we can trivially DoS the VFS by creating such a file
7 # and appending to it. This causes an integer overflow in the routines
8 # underlying writeback, which results in the kernel locking up.
10 # So, create this malformed inode and try a dio append to make sure we
11 # catch this situation.
13 #-----------------------------------------------------------------------
14 # Copyright (c) 2017 Oracle, Inc. All Rights Reserved.
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License as
18 # published by the Free Software Foundation.
20 # This program is distributed in the hope that it would be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write the Free Software Foundation,
27 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28 #-----------------------------------------------------------------------
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
36 status=1 # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
44 # get standard environment, filters and checks
48 # real QA test starts here
50 _supported_fs ext2 ext3 ext4
51 _require_scratch_nocheck
53 _require_command "$DEBUGFS_PROG"
57 echo "Format and mount"
58 _scratch_mkfs >> $seqres.full 2>&1
64 echo "Corrupt filesystem"
66 # Set the file size to the highest multiple of 512 below
67 # -1 so that we can perform a dio write.
68 $DEBUGFS_PROG -w -R "sif /a size 0xFFFFFFFFFFFFFE00" $SCRATCH_DEV >> $seqres.full 2>&1
70 echo "Remount, try to append"
72 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)."