libxfs: readahead of dir3 data blocks should use the read verifier
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 19 Aug 2015 00:33:58 +0000 (10:33 +1000)
committerDave Chinner <david@fromorbit.com>
Wed, 19 Aug 2015 00:33:58 +0000 (10:33 +1000)
In the dir3 data block readahead function, use the regular read
verifier to check the block's CRC and spot-check the block contents
instead of directly calling only the spot-checking routine.  This
prevents corrupted directory data blocks from being read into the
kernel, which can lead to garbage ls output and directory loops (if
say one of the entries contains slashes and other junk).

cc: <stable@vger.kernel.org> # 3.12 - 4.2
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/libxfs/xfs_dir2_data.c

index 6a57fdbc63ef4b67edb916afa2668c6a837425fc..824131e71bc53017082f518355c47f963e792cd8 100644 (file)
@@ -252,7 +252,8 @@ xfs_dir3_data_reada_verify(
                return;
        case cpu_to_be32(XFS_DIR2_DATA_MAGIC):
        case cpu_to_be32(XFS_DIR3_DATA_MAGIC):
-               xfs_dir3_data_verify(bp);
+               bp->b_ops = &xfs_dir3_data_buf_ops;
+               bp->b_ops->verify_read(bp);
                return;
        default:
                xfs_buf_ioerror(bp, -EFSCORRUPTED);