check: use generated group files
[xfstests-dev.git] / tests / ext4 / 041
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Oracle, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. ext4/041 (was shared/007)
6 #
7 # Since loff_t is a signed type, it is invalid for a filesystem to load
8 # an inode with i_size = -1ULL.  Unfortunately, nobody checks this,
9 # which means that we can trivially DoS the VFS by creating such a file
10 # and appending to it.  This causes an integer overflow in the routines
11 # underlying writeback, which results in the kernel locking up.
12 #
13 # So, create this malformed inode and try a dio append to make sure we
14 # catch this situation.
15 #
16 . ./common/preamble
17 _begin_fstest dangerous_fuzzers
18
19 PIDS=""
20
21 # Import common functions.
22 . ./common/filter
23
24 # real QA test starts here
25 _supported_fs ext2 ext3 ext4
26 _require_scratch_nocheck
27 _disable_dmesg_check
28 _require_command "$DEBUGFS_PROG"
29
30 echo "Format and mount"
31 _scratch_mkfs  >> $seqres.full 2>&1
32 _scratch_mount
33
34 testdir=$SCRATCH_MNT
35 echo m > $testdir/a
36
37 echo "Corrupt filesystem"
38 _scratch_unmount
39 # Set the file size to the highest multiple of 512 below
40 # -1 so that we can perform a dio write.
41 $DEBUGFS_PROG -w -R "sif /a size 0xFFFFFFFFFFFFFE00" $SCRATCH_DEV >> $seqres.full 2>&1
42
43 # check whether debugfs succeeds to set i_size to -512 or not
44 $DEBUGFS_PROG -R "stat /a" $SCRATCH_DEV 2>&1 | grep -q "Size: 18446744073709551104" || \
45         _notrun "Could not set i_size to -512 successfully, skip test."
46
47 echo "Remount, try to append"
48 _scratch_mount
49 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)."
50 sync
51
52 # success, all done
53 status=0
54 exit