From: Eryu Guan <guaneryu@gmail.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org
Subject: Re: [PATCH 2/2] xfs: make sure the kernel and repair tools catch bad names
Date: Wed, 23 Oct 2019 23:45:57 +0800 [thread overview]
Message-ID: <20191023154552.GD2543@desktop> (raw)
In-Reply-To: <157170899277.1172383.10473571682266133494.stgit@magnolia>
On Mon, Oct 21, 2019 at 06:49:52PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
>
> Make sure we actually catch bad names in the kernel.
>
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
> tests/xfs/749 | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> tests/xfs/749.out | 4 ++
> tests/xfs/group | 1 +
> 3 files changed, 108 insertions(+)
> create mode 100755 tests/xfs/749
> create mode 100644 tests/xfs/749.out
>
>
> diff --git a/tests/xfs/749 b/tests/xfs/749
> new file mode 100755
> index 00000000..de219979
> --- /dev/null
> +++ b/tests/xfs/749
> @@ -0,0 +1,103 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0-or-newer
> +# Copyright (c) 2019, Oracle and/or its affiliates. All Rights Reserved.
> +#
> +# FS QA Test No. 749
> +#
> +# See if we catch corrupt directory names or attr names with nulls or slashes
> +# in them.
> +
> +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 /
> + umount $mntpt > /dev/null 2>&1
$UMOUNT_PROG
> + test -n "$loopdev" && _destroy_loop_device $loopdev > /dev/null 2>&1
> + rm -r -f $imgfile $mntpt $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs xfs
> +_supported_os Linux
> +_require_test
_require_attrs is also needed
> +
> +rm -f $seqres.full
> +
> +imgfile=$TEST_DIR/img-$seq
> +mntpt=$TEST_DIR/mount-$seq
> +testdir=$mntpt/testdir
> +testfile=$mntpt/testfile
> +nullstr="too_many_beans"
> +slashstr="are_bad_for_you"
> +
> +# Format image file
> +truncate -s 40m $imgfile
$XFS_IO_PROG -fc "truncate 40m" $imgfile
> +loopdev=$(_create_loop_device $imgfile)
> +$MKFS_XFS_PROG $loopdev >> $seqres.full
_mkfs_dev $loopdev ?
> +
> +# Mount image file
> +mkdir -p $mntpt
> +mount $loopdev $mntpt
_mount $loopdev $mntpt
> +
> +# Create directory entries
> +mkdir -p $testdir
> +touch $testdir/$nullstr
> +touch $testdir/$slashstr
> +
> +# Create attrs
> +touch $testfile
> +$ATTR_PROG -s $nullstr -V heh $testfile >> $seqres.full
> +$ATTR_PROG -s $slashstr -V heh $testfile >> $seqres.full
> +
> +# Corrupt the entries
> +umount $mntpt
$UMOUNT_PROG $mntpt
> +_destroy_loop_device $loopdev
> +cp $imgfile $imgfile.old
> +sed -b \
> + -e "s/$nullstr/too_many\x00beans/g" \
> + -e "s/$slashstr/are_bad\/for_you/g" \
> + -i $imgfile
> +test "$(md5sum < $imgfile)" != "$(md5sum < $imgfile.old)" ||
> + _fail "sed failed to change the image file?"
> +rm -f $imgfile.old
> +loopdev=$(_create_loop_device $imgfile)
> +mount $loopdev $mntpt
_mount $loopdev $mntpt
> +
> +# Try to access the corrupt metadata
> +ls $testdir >> $seqres.full 2> $tmp.err
> +attr -l $testfile >> $seqres.full 2>> $tmp.err
$ATTR_PROG
> +cat $tmp.err | _filter_test_dir
> +
> +# Does scrub complain about this?
> +if _supports_xfs_scrub $mntpt $loopdev; then
> + $XFS_SCRUB_PROG -n $mntpt >> $seqres.full 2>&1
> + res=$?
> + test $((res & 1)) -eq 0 && \
> + echo "scrub failed to report corruption ($res)"
> +fi
> +
> +# Does repair complain about this?
> +umount $mntpt
$UMOUNT_PROG
> +$XFS_REPAIR_PROG -n $loopdev >> $seqres.full 2>&1
> +res=$?
> +test $res -eq 1 || \
> + echo "repair failed to report corruption ($res)"
> +
> +_destroy_loop_device $loopdev
> +loopdev=
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/xfs/749.out b/tests/xfs/749.out
> new file mode 100644
> index 00000000..db704c87
> --- /dev/null
> +++ b/tests/xfs/749.out
> @@ -0,0 +1,4 @@
> +QA output created by 749
> +ls: cannot access 'TEST_DIR/mount-749/testdir': Structure needs cleaning
> +attr_list: Structure needs cleaning
> +Could not list "(null)" for TEST_DIR/mount-749/testfile
I got the following diff on my fedora 30 test vm, where attr version is
attr-2.4.48-5.fc30.x86_64, perhaps the attr output has been changed?
Looks like we need a filter, or use _getfattr?
-Could not list "(null)" for TEST_DIR/mount-148/testfile
+Could not list TEST_DIR/mount-148/testfile
Thanks,
Eryu
> diff --git a/tests/xfs/group b/tests/xfs/group
> index f4ebcd8c..9600cb4e 100644
> --- a/tests/xfs/group
> +++ b/tests/xfs/group
> @@ -507,3 +507,4 @@
> 509 auto ioctl
> 510 auto ioctl quick
> 511 auto quick quota
> +749 auto quick fuzzers
>
next prev parent reply other threads:[~2019-10-23 15:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-22 1:49 [PATCH 0/2] fstests: random fixes Darrick J. Wong
2019-10-22 1:49 ` [PATCH 1/2] xfs/435: disable dmesg checks Darrick J. Wong
2019-10-22 1:49 ` [PATCH 2/2] xfs: make sure the kernel and repair tools catch bad names Darrick J. Wong
2019-10-23 15:45 ` Eryu Guan [this message]
2019-10-24 0:30 ` Darrick J. Wong
2019-10-24 0:31 ` [PATCH v2 " Darrick J. Wong
2019-10-24 4:52 ` Darrick J. Wong
2019-10-24 0:33 ` [PATCH 3/2] generic: check storing and re-reading timestamps Darrick J. Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191023154552.GD2543@desktop \
--to=guaneryu@gmail.com \
--cc=darrick.wong@oracle.com \
--cc=fstests@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox