xfs/530: skip test if user MKFS_OPTIONS screw up formatting
[xfstests-dev.git] / tests / xfs / 133
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Oracle, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 133
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 buffered append to make
14 # sure we 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 xfs
26 _require_scratch_nocheck
27 _disable_dmesg_check
28
29 echo "Format and mount"
30 _scratch_mkfs  >> $seqres.full 2>&1
31 _scratch_mount
32
33 testdir=$SCRATCH_MNT
34 echo m > $testdir/a
35 inum=$(stat -c "%i" $testdir/a)
36
37 echo "Corrupt filesystem"
38 _scratch_unmount
39
40 # run two xfs_db commands to set core.size regardless of the special argument "--"
41 # is needed or not.
42 _scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -1' >> $seqres.full 2>&1
43 _scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -1' >> $seqres.full 2>&1
44
45 # check core.size and _notrun if it's not set correctly
46 i_size=`_scratch_xfs_db -c "inode ${inum}" -c "print core.size" | $AWK_PROG '{print $3}'`
47 if [ $i_size -ne -1 ]; then
48         _notrun "Could not set i_size to -1 successfully, skip test."
49 fi
50
51 echo "Remount, try to append"
52 _scratch_mount
53 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)."
54 sync
55
56 # success, all done
57 status=0
58 exit