mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
cf895a2a05
1) xfs/133 and xfs/134 work abnornamlly on RHEL6.8GA and RHEL6.9Beta
because xfs_db fails to set negative i_size and reports "usage:
write fieldname value". The special argument "--" is only used to
end option-scanning in getopt(). So we can run two xfs_db commands
to set negative i_size regardless of the special argument "--" is
needed or not. getopt() has been produced by 'commit c9f5e3db22098
("xfs_db: Allow writes of corrupted data")'.
2) xfs/134 passes unexpectedly on RHEL6.8GA due to EINVAL, so we use
touch command to create 512-aligned test file.
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
89 lines
2.8 KiB
Bash
Executable File
89 lines
2.8 KiB
Bash
Executable File
#! /bin/bash
|
|
# FSQA Test No. 134
|
|
#
|
|
# 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.
|
|
#
|
|
#-----------------------------------------------------------------------
|
|
# Copyright (c) 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
|
|
# make sure the write offset is 512-aligned
|
|
touch $testdir/a
|
|
inum=$(stat -c "%i" $testdir/a)
|
|
|
|
echo "Corrupt filesystem"
|
|
_scratch_unmount
|
|
|
|
# 1) Set the file size to the highest multiple of 512 below -1 so
|
|
# that we can perform a dio write.
|
|
# 2) run two xfs_db commands to set core.size regardless of the special
|
|
# argument "--" is needed or not.
|
|
_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -- -512' >> $seqres.full 2>&1
|
|
_scratch_xfs_db -x -c "inode ${inum}" -c 'write core.size -512' >> $seqres.full 2>&1
|
|
|
|
# check core.size and _notrun if it's not set correctly
|
|
i_size=`_scratch_xfs_db -c "inode ${inum}" -c "print core.size" | $AWK_PROG '{print $3}'`
|
|
if [ $i_size -ne -512 ]; then
|
|
_notrun "Could not set i_size to -512 successfully, skip test."
|
|
fi
|
|
|
|
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
|