From: Amir Goldstein Date: Wed, 11 Jan 2017 06:41:12 +0000 (+0200) Subject: xfs: test readlink/readdir with malformed inode mode X-Git-Tag: v2022.05.01~2215 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9b80c46ed0d3c892591ee3004ba9d8283f7e400b;p=users%2Fhch%2Fxfstests-dev.git xfs: test readlink/readdir with malformed inode mode In 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 kernel 4.9 with XFS_DEBUG=y XFS: Assertion failed: rval == 0 || args->dp->i_d.di_size == args->geo->blksize, file: /home/amir/build/src/linux/fs/xfs/libxfs/xfs_dir2.c, line: 634 A fix patch, as suggested by Darrick, changes this ASSERT() to return -EFSCORRUPTED ("xfs: sanity check directory inode di_size"). Merging this test should be deferred to after fix patch is merged. Signed-off-by: Amir Goldstein Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- diff --git a/tests/xfs/348 b/tests/xfs/348 index b195fffbc..9d3bcb222 100755 --- a/tests/xfs/348 +++ b/tests/xfs/348 @@ -133,6 +133,15 @@ 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. + # NOTE that ls DOES ASSERT with kernel 4.9 and XFS_DEBUG=y + # on malformed directory + if [ -d $testdir/$file ]; then + ls $testdir/$file &> /dev/null + elif [ -h $testdir/$file ]; then + readlink $testdir/$file &> /dev/null + fi fi | _filter_scratch done _scratch_unmount