xfs/348: test handling of malformed inode mode
v2 cover xfs/348: test handling of malformed inode mode
Eryu,
I beefed up the initial test sent earlier today with more checks on mounted fs.
The original patch testing only xfs_repair remains patch 1 in this series.
Patch 2 adds fstat tests on mounted fs, which are safe on my test system.
Patch 3 is explosive. It exposes an XFS assert, but I left a "safety pin" that needs to be commented out to reproduce the assert.
I will soon post my kernel configs and dmesg logs.
Amir.
v2:
- test fstat with malformed inode mode
- test readlink/readdir with malformed inode mode
v1:
- test xfs_repair with malformed inode mode
Amir Goldstein (3):
xfs/348: test handling of invalid inode modes xfs/348: test fstat with malformed inode mode xfs/348: test readlink/readdir with malformed inode mode
tests/xfs/348 | 154 +++++++++++++++++++++++++++ tests/xfs/348.out | 312 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/group | 1 + 3 files changed, 467 insertions(+) create mode 100755 tests/xfs/348 create mode 100644 tests/xfs/348.out
Signature · 1 line
2.7.4
PATCH v2 1/3 xfs/348: test handling of invalid inode modes
Set all possible file type values for different types of files and verify that xfs_repair detects the correct errors.
When setting invalid file type values (e.g. core.mode = 0170644), all files are expected to have been junked by xfs_repair.
When setting valid file type values to non matching file types, xfs_repair would either detect wrong format and junk the file, e.g.:
would have junked entry "FILE" in directory PARENT_INO
or detect a ftype mismatch error, e.g.:
would fix ftype mismatch (5/3) in directory/child PARENT_INO/FIFO_INO
If ftype feature is enabled, when setting file type to one of the special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)), xfs_repair is expected to detect ftype mismatch error. Otherewise, xfs_repair is not expected to detect ftype mismatch error.
--- tests/xfs/348 | 128 ++++++++++++++++++++++++++++++++ tests/xfs/348.out | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/group | 1 + 3 files changed, 345 insertions(+) create mode 100755 tests/xfs/348 create mode 100644 tests/xfs/348.out
tests/xfs/348 new file +128 -0
@@ -0,0 +1,128 @@ +#! /bin/bash +# FSQA Test No. 348 +# +# Test handling of invalid inode modes +# +# Set all possible file type values for different types of files +# and verify that xfs_repair detects the correct errors. +# +#----------------------------------------------------------------------- +# +# Copyright (C) 2016 CTERA Networks. All Rights Reserved. +# Author: Amir Goldstein <[email protected]> +# +# 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" + +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 +. ./common/repair + +# real QA test starts here +_supported_fs xfs +_supported_os Linux +_require_scratch + +rm -f $seqres.full + +_scratch_mkfs >>$seqres.full 2>&1 + +_scratch_mount + +# Create our test files. +testdir=$SCRATCH_MNT/test +mkdir -p $testdir +mkdir $testdir/DIR +echo 123 > $testdir/FILE +ln -s $testdir/FILE $testdir/SYMLINK +mknod $testdir/CHRDEV c 1 1 +mknod $testdir/BLKDEV b 1 1 +mknod $testdir/FIFO p + +xfs_info $SCRATCH_MNT | grep -q "ftype=1" && FTYPE_FEATURE=1 + +# Record test dir inode for xfs_repair filter +inode_filter=$tmp.sed +rm -f $inode_filter +pino=$(ls -id $testdir | awk '{print $1}') +echo "s/inode $pino/PARENT_INO/" >> $inode_filter +echo "s/directory $pino/directory PARENT_INO/" >> $inode_filter + +inodes="" +# Record inode numbers for xfs_db commands and xfs_repair filter +for f in DIR FILE SYMLINK CHRDEV BLKDEV FIFO; do + ino=$(ls -id $testdir/$f | awk '{print $1}') + inodes="$inodes $ino" + echo "s/inode $ino/${f}_INO/" >> $inode_filter +done + +_scratch_unmount + +# Possible mode file type values (mode & S_IFMT) >> 12 +dtypes="0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17" +echo "===== Find inode by file type:" +for dt in $dtypes; do + # Set all our test files to dt value + for ino in $inodes; do + _scratch_xfs_db -c "inode $ino" -c "print core.mode" | \ + grep -q "0${dt}0...$" && \ + (echo "dt=$dt => inode $ino" | sed -f $inode_filter) + done +done +for dt in $dtypes; do + echo + echo "===== Setting dt=$dt to all files:" + # Set all our test files to dt value + for ino in $inodes; do + _scratch_xfs_db -x -c "inode $ino" -c "write core.mode 0${dt}0644" + done + # Repair should detect the inconsistencies + # For invalid dt values, all files would have been junked. + # For valid dt values, one test file is expected to be valid. + # The rest would either have wrong format or non matching dir ftype. + _scratch_xfs_repair -n 2>&1 | tee -a $seqres.full | \ + _filter_repair | grep "^would have junked" | sed -f $inode_filter | sort -u + # If ftype feature is enabled, when setting file type to one of the + # special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)), + # xfs_repair is expected to detect ftype mismatch error. Otherewise, + # xfs_repair is not expected to detect ftype mismatch error. + if [ "$FTYPE_FEATURE" = 1 ] && (echo ':1:2:6:14:' | grep -q ":$dt:"); then + _scratch_xfs_repair -n 2>&1 | grep -q "^would fix ftype mismatch" || \ + _fail "xfs_repair should fix ftype mismatch" + else + _scratch_xfs_repair -n 2>&1 | grep -q -v "^would fix ftype mismatch" || \ + _fail "xfs_repair should not fix ftype mismatch" + fi +done + +# Repair should detect and junk all test files +_scratch_xfs_repair 2>&1 >> $seqres.full 2>&1 || _fail "xfs_repair should not fail" + +status=0 +exit
tests/xfs/348.out new file +216 -0
216 lines not on this page · raw message
tests/xfs/group +1 -0
@@ -334,3 +334,4 @@ 345 auto quick clone 346 auto quick clone 347 auto quick clone +348 auto quick repair
Signature · 1 line
2.7.4
Re: [PATCH v2 1/3] xfs/348: test handling of invalid inode modes
Quoted 12 lines · Amir Goldstein
Set all possible file type values for different types of files and verify that
xfs_repairdetects the correct errors.When setting invalid file type values (e.g. core.mode = 0170644), all files are expected to have been junked by
xfs_repair.When setting valid file type values to non matching file types,
xfs_repairwould either detect wrong format and junk the file, e.g.:
would have junked entry "FILE" in directoryPARENT_INO
or detect a ftype mismatch error, e.g.:
would fix ftype mismatch (5/3) in directory/child PARENT_INO/FIFO_INO
Quoted 3 lines
If ftype feature is enabled, when setting file type to one of the special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)),
xfs_repairis expected to detect ftype mismatch error. Otherewise,
"Otherwise"
Quoted 117 lines
xfs_repairis not expected to detect ftype mismatch error.Signed-off-by Amir Goldstein <[email protected]>--- tests/xfs/348 | 128 ++++++++++++++++++++++++++++++++ tests/xfs/348.out | 216 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/group | 1 + 3 files changed, 345 insertions(+) create mode 100755 tests/xfs/348 create mode 100644 tests/xfs/348.outtests/xfs/348 new file +100
-0@@ -0,0 +1,128 @@ +#! /bin/bash +# FSQA Test No. 348 +# +# Test handling of invalid inode modes +# +# Set all possible file type values for different types of files +# and verify that xfs_repair detects the correct errors. +# +#----------------------------------------------------------------------- +# +# Copyright (C) 2016 CTERA Networks. All Rights Reserved. +# Author: Amir Goldstein <[email protected]> +# +# 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" + +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 +. ./common/repair + +# real QA test starts here +_supported_fs xfs +_supported_os Linux +_require_scratch + +rm -f $seqres.full + +_scratch_mkfs >>$seqres.full 2>&1 + +_scratch_mount + +# Create our test files. +testdir=$SCRATCH_MNT/test +mkdir -p $testdir +mkdir $testdir/DIR +echo 123 > $testdir/FILE +ln -s $testdir/FILE $testdir/SYMLINK +mknod $testdir/CHRDEV c 1 1 +mknod $testdir/BLKDEV b 1 1 +mknod $testdir/FIFO p + +xfs_info $SCRATCH_MNT | grep -q "ftype=1" && FTYPE_FEATURE=1 + +# Record test dir inode for xfs_repair filter +inode_filter=$tmp.sed +rm -f $inode_filter +pino=$(ls -id $testdir | awk '{print $1}') +echo "s/inode $pino/PARENT_INO/" >> $inode_filter +echo "s/directory $pino/directory PARENT_INO/" >> $inode_filter + +inodes="" +# Record inode numbers for xfs_db commands and xfs_repair filter +for f in DIR FILE SYMLINK CHRDEV BLKDEV FIFO; do + ino=$(ls -id $testdir/$f | awk '{print $1}') + inodes="$inodes $ino" + echo "s/inode $ino/${f}_INO/" >> $inode_filter +done + +_scratch_unmount + +# Possible mode file type values (mode & S_IFMT) >> 12 +dtypes="0 1 2 3 4 5 6 7 10 11 12 13 14 15 16 17" +echo "===== Find inode by file type:" +for dt in $dtypes; do + # Set all our test files to dt value + for ino in $inodes; do + _scratch_xfs_db -c "inode $ino" -c "print core.mode" | \ + grep -q "0${dt}0...$" && \ + (echo "dt=$dt => inode $ino" | sed -f $inode_filter) + done +done +for dt in $dtypes; do + echo + echo "===== Setting dt=$dt to all files:"
tests/xfs/348 line 110
Quoted 10 lines
tests/xfs/348 new file +10
-0+ # Set all our test files to dt value + for ino in $inodes; do + _scratch_xfs_db -x -c "inode $ino" -c "write core.mode 0${dt}0644" + done + # Repair should detect the inconsistencies + # For invalid dt values, all files would have been junked. + # For valid dt values, one test file is expected to be valid. + # The rest would either have wrong format or non matching dir ftype. + _scratch_xfs_repair -n 2>&1 | tee -a $seqres.full | \ + _filter_repair | grep "^would have junked" | sed -f $inode_filter | sort -u
I would also like to see a second test that scrambles the ftype field in the directory entry (instead of changing the inode core.mode) but xfs_db can't write to dir3 blocks because it doesn't know how to set the dir block CRC.
I'm going to send a patch to add that as part of my xfsprogs 4.11 patchbomb (hopefully next week, but after the xfsprogs 4.9 release) so that test can wait.
tests/xfs/348 line 120
Quoted 10 lines
tests/xfs/348 new file +10
-0+ # If ftype feature is enabled, when setting file type to one of the + # special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)), + # xfs_repair is expected to detect ftype mismatch error. Otherewise, + # xfs_repair is not expected to detect ftype mismatch error. + if [ "$FTYPE_FEATURE" = 1 ] && (echo ':1:2:6:14:' | grep -q ":$dt:"); then + _scratch_xfs_repair -n 2>&1 | grep -q "^would fix ftype mismatch" || \ + _fail "xfs_repair should fix ftype mismatch" + else + _scratch_xfs_repair -n 2>&1 | grep -q -v "^would fix ftype mismatch" || \ + _fail "xfs_repair should not fix ftype mismatch"
Just FYI the whole test will stop as soon as we hit a _fail. Please consider simply echoing a complaint to stdout so that the golden output diff will catch this, and we can see all the failing cases.
--D
Quoted 242 lines
tests/xfs/348 new file +8
-0+ fi +done + +# Repair should detect and junk all test files +_scratch_xfs_repair 2>&1 >> $seqres.full 2>&1 || _fail "xfs_repair should not fail" + +status=0 +exittests/xfs/348.out new file +216
-0@@ -0,0 +1,216 @@ +QA output created by 348 +===== Find inode by file type: +dt=1 => FIFO_INO +dt=2 => CHRDEV_INO +dt=4 => DIR_INO +dt=6 => BLKDEV_INO +dt=10 => FILE_INO +dt=12 => SYMLINK_INO + +===== Setting dt=0 to all files: +core.mode = 0644 +core.mode = 0644 +core.mode = 0644 +core.mode = 0644 +core.mode = 0644 +core.mode = 0644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=1 to all files: +core.mode = 010644 +core.mode = 010644 +core.mode = 010644 +core.mode = 010644 +core.mode = 010644 +core.mode = 010644 +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=2 to all files: +core.mode = 020644 +core.mode = 020644 +core.mode = 020644 +core.mode = 020644 +core.mode = 020644 +core.mode = 020644 +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=3 to all files: +core.mode = 030644 +core.mode = 030644 +core.mode = 030644 +core.mode = 030644 +core.mode = 030644 +core.mode = 030644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=4 to all files: +core.mode = 040644 +core.mode = 040644 +core.mode = 040644 +core.mode = 040644 +core.mode = 040644 +core.mode = 040644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO + +===== Setting dt=5 to all files: +core.mode = 050644 +core.mode = 050644 +core.mode = 050644 +core.mode = 050644 +core.mode = 050644 +core.mode = 050644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=6 to all files: +core.mode = 060644 +core.mode = 060644 +core.mode = 060644 +core.mode = 060644 +core.mode = 060644 +core.mode = 060644 +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=7 to all files: +core.mode = 070644 +core.mode = 070644 +core.mode = 070644 +core.mode = 070644 +core.mode = 070644 +core.mode = 070644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=10 to all files: +core.mode = 0100644 +core.mode = 0100644 +core.mode = 0100644 +core.mode = 0100644 +core.mode = 0100644 +core.mode = 0100644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=11 to all files: +core.mode = 0110644 +core.mode = 0110644 +core.mode = 0110644 +core.mode = 0110644 +core.mode = 0110644 +core.mode = 0110644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=12 to all files: +core.mode = 0120644 +core.mode = 0120644 +core.mode = 0120644 +core.mode = 0120644 +core.mode = 0120644 +core.mode = 0120644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO + +===== Setting dt=13 to all files: +core.mode = 0130644 +core.mode = 0130644 +core.mode = 0130644 +core.mode = 0130644 +core.mode = 0130644 +core.mode = 0130644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=14 to all files: +core.mode = 0140644 +core.mode = 0140644 +core.mode = 0140644 +core.mode = 0140644 +core.mode = 0140644 +core.mode = 0140644 +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=15 to all files: +core.mode = 0150644 +core.mode = 0150644 +core.mode = 0150644 +core.mode = 0150644 +core.mode = 0150644 +core.mode = 0150644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=16 to all files: +core.mode = 0160644 +core.mode = 0160644 +core.mode = 0160644 +core.mode = 0160644 +core.mode = 0160644 +core.mode = 0160644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INO + +===== Setting dt=17 to all files: +core.mode = 0170644 +core.mode = 0170644 +core.mode = 0170644 +core.mode = 0170644 +core.mode = 0170644 +core.mode = 0170644 +would have junked entry "BLKDEV" in directory PARENT_INO +would have junked entry "CHRDEV" in directory PARENT_INO +would have junked entry "DIR" in directory PARENT_INO +would have junked entry "FIFO" in directory PARENT_INO +would have junked entry "FILE" in directory PARENT_INO +would have junked entry "SYMLINK" in directory PARENT_INOtests/xfs/group +1
-0@@ -334,3 +334,4 @@ 345 auto quick clone 346 auto quick clone 347 auto quick clone +348 auto quick repairSignature · 1 line
2.7.4
Re: [PATCH v2 1/3] xfs/348: test handling of invalid inode modes
Quoted 13 lines · Darrick J. Wong
Quoted 12 lines · Amir Goldstein
Set all possible file type values for different types of files and verify that
xfs_repairdetects the correct errors.When setting invalid file type values (e.g. core.mode = 0170644), all files are expected to have been junked by
xfs_repair.When setting valid file type values to non matching file types,
xfs_repairwould either detect wrong format and junk the file, e.g.:
would have junked entry "FILE" in directoryPARENT_INO
or detect a ftype mismatch error, e.g.:
would fix ftype mismatch (5/3) in directory/child PARENT_INO/FIFO_INO
Quoted 6 lines
Quoted 3 lines
If ftype feature is enabled, when setting file type to one of the special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)),
xfs_repairis expected to detect ftype mismatch error. Otherewise,"Otherwise"
thanks
Quoted 9 lines
I would also like to see a second test that scrambles the ftype field in the directory entry (instead of changing the inode core.mode) but
xfs_dbcan't write to dir3 blocks because it doesn't know how to set the dir block CRC.I'm going to send a patch to add that as part of my xfsprogs 4.11 patchbomb (hopefully next week, but after the xfsprogs 4.9 release) so that test can wait.
Sure, I'll beef up the test when that code arrives.
Quoted 11 lines
tests/xfs/348 line 120
Quoted 10 lines
tests/xfs/348 new file +10
-0+ # If ftype feature is enabled, when setting file type to one of the + # special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)), + # xfs_repair is expected to detect ftype mismatch error. Otherewise, + # xfs_repair is not expected to detect ftype mismatch error. + if [ "$FTYPE_FEATURE" = 1 ] && (echo ':1:2:6:14:' | grep -q ":$dt:"); then + _scratch_xfs_repair -n 2>&1 | grep -q "^would fix ftype mismatch" || \ + _fail "xfs_repair should fix ftype mismatch" + else + _scratch_xfs_repair -n 2>&1 | grep -q -v "^would fix ftype mismatch" || \ + _fail "xfs_repair should not fix ftype mismatch"
Quoted 4 lines
Just FYI the whole test will stop as soon as we hit a
_fail. Please consider simply echoing a complaint to stdout so that the golden output diff will catch this, and we can see all the failing cases.
Will do.
Can you please reply to v2 patch series.
It contain 2 more patches beyond this one with additional testing of access to mounted fs with the malformed inodes.
My question is what to do WRT patch 3/3 which triggers an XFS Assert in the kernel (readdir of a phony directory that is really a regular file or symlink).
http://www.spinics.net/lists/linux-xfs/msg03059.html
Is this something of concern to you? Can you instruct me whether the assertion should be fixed or propose a fix yourself?
Or is it just a non issue and we should not add patch 3/3 to this test.
Amir.
Re: [PATCH v2 1/3] xfs/348: test handling of invalid inode modes
Quoted 58 lines · Amir Goldstein
Quoted 13 lines · Darrick J. Wong
Quoted 12 lines · Amir Goldstein
Set all possible file type values for different types of files and verify that
xfs_repairdetects the correct errors.When setting invalid file type values (e.g. core.mode = 0170644), all files are expected to have been junked by
xfs_repair.When setting valid file type values to non matching file types,
xfs_repairwould either detect wrong format and junk the file, e.g.:
would have junked entry "FILE" in directoryPARENT_INO
or detect a ftype mismatch error, e.g.:
would fix ftype mismatch (5/3) in directory/child PARENT_INO/FIFO_INOQuoted 6 lines
Quoted 3 lines
If ftype feature is enabled, when setting file type to one of the special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)),
xfs_repairis expected to detect ftype mismatch error. Otherewise,"Otherwise"
thanks
Quoted 9 lines
I would also like to see a second test that scrambles the ftype field in the directory entry (instead of changing the inode core.mode) but
xfs_dbcan't write to dir3 blocks because it doesn't know how to set the dir block CRC.I'm going to send a patch to add that as part of my xfsprogs 4.11 patchbomb (hopefully next week, but after the xfsprogs 4.9 release) so that test can wait.
Sure, I'll beef up the test when that code arrives.
Quoted 11 lines
tests/xfs/348 line 120
Quoted 10 lines
tests/xfs/348 new file +10
-0+ # If ftype feature is enabled, when setting file type to one of the + # special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)), + # xfs_repair is expected to detect ftype mismatch error. Otherewise, + # xfs_repair is not expected to detect ftype mismatch error. + if [ "$FTYPE_FEATURE" = 1 ] && (echo ':1:2:6:14:' | grep -q ":$dt:"); then + _scratch_xfs_repair -n 2>&1 | grep -q "^would fix ftype mismatch" || \ + _fail "xfs_repair should fix ftype mismatch" + else + _scratch_xfs_repair -n 2>&1 | grep -q -v "^would fix ftype mismatch" || \ + _fail "xfs_repair should not fix ftype mismatch"Quoted 4 lines
Just FYI the whole test will stop as soon as we hit a
_fail. Please consider simply echoing a complaint to stdout so that the golden output diff will catch this, and we can see all the failing cases.Will do.
Can you please reply to v2 patch series.
It contain 2 more patches beyond this one with additional testing of access to mounted fs with the malformed inodes.
Quoted 7 lines
My question is what to do WRT patch 3/3 which triggers an XFS Assert in the kernel (readdir of a phony directory that is really a regular file or symlink).
http://www.spinics.net/lists/linux-xfs/msg03059.htmlIs this something of concern to you? Can you instruct me whether the assertion should be fixed or propose a fix yourself?
Or is it just a non issue and we should not add patch 3/3 to this test.
ASSERTs by definition halt the system, so it's only a crasher bug if CONFIG_XFS_DEBUG=y. However, your test writes garbage to the filesystem, so we must try to avoid interacting with corrupted junk when possible.
I suggest bouncing corruption out to userspace by changing that ASSERT to:
if (rval == 0 || args->dp->i_d.di_size == args->geo->blksize)
return -EFSCORRUPTED;
...and perhaps following it up with a check in _dinode_verify to reject the inode if it has an obviously bogus i_size.
--D
Quoted 6 lines
Amir.
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 2/3 xfs/348: test fstat with malformed inode mode
In reply to Amir GoldsteinIn addition to testing xfs_repair on inodes with malformed mode, also test fstat of those inodes on a mounted fs.
This additional test is quite noisy with dmesg warnings, so check dmesg has been disabled.
--- tests/xfs/348 | 16 ++++++++++ tests/xfs/348.out | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+)
tests/xfs/348 +16 -0
@@ -49,6 +49,10 @@ _supported_fs xfs _supported_os Linux _require_scratch +# This test will corrupt fs intentionally, so there will be WARNINGs +# in dmesg as expected +_disable_dmesg_check + rm -f $seqres.full _scratch_mkfs >>$seqres.full 2>&1
@@ -119,6 +123,18 @@ for dt in $dtypes; do _scratch_xfs_repair -n 2>&1 | grep -q -v "^would fix ftype mismatch" || \ _fail "xfs_repair should not fix ftype mismatch" fi + + _scratch_mount + for file in DIR FILE SYMLINK CHRDEV BLKDEV FIFO; do + rm -f $tmp.stat.err + ftype=$(stat --printf=%F $testdir/$file 2>$tmp.stat.err) + if [ -s $tmp.stat.err ]; then + cat $tmp.stat.err + else + echo "stat: '$testdir/$file' is a $ftype" + fi | _filter_scratch + done + _scratch_unmount done # Repair should detect and junk all test files
tests/xfs/348.out +96 -0
189 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 3/3 xfs/348: test readlink/readdir with malformed inode mode
In reply to Amir GoldsteinIn addition to testing xfs_repair on inodes with malformed mode, and fstat of those inodes on a mounted fs, try to also list content of mock directory and readlink of mock symlink.
Readdir of mock directory triggers XFS assertion on umount:
XFS: Assertion failed: !rwsem_is_locked(&inode->i_rwsem), file:
/home/amir/build/src/linux/fs/xfs/xfs_super.c, line: 951
To reproduce, need to comment out the variable 'safety'.
--- tests/xfs/348 | 10 ++++++++++ 1 file changed, 10 insertions(+)
tests/xfs/348 +10 -0
@@ -132,6 +132,16 @@ for dt in $dtypes; do cat $tmp.stat.err else echo "stat: '$testdir/$file' is a $ftype" + # Verify that readlink of a file posing as a symlink + # and ls of a file posing as a directory does not blow up + safety="-d" + # NOTE that ls DOES blow up with kernel 4.9 on malformed + # directory - remove the safety pin to explode + if [ -d $testdir/$file ]; then + ls "$safety" $testdir/$file &> /dev/null + elif [ -h $testdir/$file ]; then + readlink $testdir/$file &> /dev/null + fi fi | _filter_scratch done _scratch_unmount
Signature · 1 line
2.7.4
Quoted 11 lines · Amir Goldstein
Eryu,
I beefed up the initial test sent earlier today with more checks on mounted fs.
The original patch testing only
xfs_repairremains patch 1 in this series.Patch 2 adds fstat tests on mounted fs, which are safe on my test system.
Patch 3 is explosive. It exposes an XFS assert, but I left a "safety pin" that needs to be commented out to reproduce the assert.
My kenrel config doesn't turn DEBUG on, so I don't see a kernel crash :)
I can push this test out after the fix lands in upstream, then I think there's no need to leave a switch in the test.
Otherwise tests look good to me. But I'd like to have Darrick to review too, as he had written many fuzzer tests and suggested this test :)
Thanks,
Eryu
Quoted 27 lines
I will soon post my kernel configs and dmesg logs.
Amir.
v2:
- test fstat with malformed inode mode
- test readlink/readdir with malformed inode modev1:
- testxfs_repairwith malformed inode modeAmir Goldstein (3):
xfs/348: test handling of invalid inode modes xfs/348: test fstat with malformed inode mode xfs/348: test readlink/readdir with malformed inode modetests/xfs/348 | 154 +++++++++++++++++++++++++++ tests/xfs/348.out | 312 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/group | 1 + 3 files changed, 467 insertions(+) create mode 100755 tests/xfs/348 create mode 100644 tests/xfs/348.outSignature · 1 line
2.7.4
Quoted 13 lines · Eryu Guan
Quoted 11 lines · Amir Goldstein
Eryu,
I beefed up the initial test sent earlier today with more checks on mounted fs.
The original patch testing only
xfs_repairremains patch 1 in this series.Patch 2 adds fstat tests on mounted fs, which are safe on my test system.
Patch 3 is explosive. It exposes an XFS assert, but I left a "safety pin" that needs to be commented out to reproduce the assert.
Quoted 8 lines
My kenrel config doesn't turn DEBUG on, so I don't see a kernel crash :)
I can push this test out after the fix lands in upstream, then I think there's no need to leave a switch in the test.
Otherwise tests look good to me. But I'd like to have Darrick to review too, as he had written many fuzzer tests and suggested this test :)
Eryu,
Darrick has actually reviewed patch 1 v1 and gave only minor comments, which I addressed in v3.
So how about merging patch 1 (v3) (sanity of xfs_repair) and leave patches 2-3 for later?
Amir.
Quoted 23 lines · Amir Goldstein
Quoted 13 lines · Eryu Guan
Quoted 11 lines · Amir Goldstein
Eryu,
I beefed up the initial test sent earlier today with more checks on mounted fs.
The original patch testing only
xfs_repairremains patch 1 in this series.Patch 2 adds fstat tests on mounted fs, which are safe on my test system.
Patch 3 is explosive. It exposes an XFS assert, but I left a "safety pin" that needs to be commented out to reproduce the assert.
Quoted 8 lines
My kenrel config doesn't turn DEBUG on, so I don't see a kernel crash :)
I can push this test out after the fix lands in upstream, then I think there's no need to leave a switch in the test.
Otherwise tests look good to me. But I'd like to have Darrick to review too, as he had written many fuzzer tests and suggested this test :)
Quoted 7 lines
Eryu,
Darrick has actually reviewed patch 1 v1 and gave only minor comments, which I addressed in v3.
So how about merging patch 1 (v3) (sanity of
xfs_repair) and leave patches 2-3 for later?
Yeah, I was thinking about this too, will give it a quick test and queue it up if there's no issues found. Sorry I'm a bit late reviewing these patches, I was busy with other work these days.
Thanks,
Eryu