Re: [PATCH] fstests: btrfs/049: add regression test for compress-force=lzo mount option

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



On Fri, Nov 12, 2021 at 2:36 AM Qu Wenruo <wqu@xxxxxxxx> wrote:
>
> Since kernel commit d4088803f511 ("btrfs: subpage: make lzo_compress_pages()
> compatible"), lzo compression no longer respects the max compressed page
> limit, and can cause kernel crash.
>
> The fix is titled "btrfs: fix a out-of-boundary access for
> copy_compressed_data_to_page()".
>
> This patch will add such regression test for compress-force=lzo mount
> option against incompressible data.
>
> Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>
> ---
>  tests/btrfs/049     | 41 +++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/049.out |  1 +
>  2 files changed, 42 insertions(+)
>  create mode 100755 tests/btrfs/049
>
> diff --git a/tests/btrfs/049 b/tests/btrfs/049
> new file mode 100755
> index 00000000..5a73f738
> --- /dev/null
> +++ b/tests/btrfs/049
> @@ -0,0 +1,41 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2021 SUSE Linux Products GmbH. All Rights Reserved.
> +#
> +# FS QA Test 049
> +#
> +# Test if btrfs will crash when compress-force=lzo hits incompressible data
> +#
> +. ./common/preamble
> +_begin_fstest auto quick compress dangerous
> +
> +# Override the default cleanup function.
> +# _cleanup()
> +# {
> +#      cd /
> +#      rm -r -f $tmp.*
> +# }
> +
> +# Import common functions.
> +# . ./common/filter
> +
> +# real QA test starts here
> +
> +# Modify as appropriate.
> +_supported_fs btrfs
> +_require_scratch
> +
> +_scratch_mkfs >> $seqres.full
> +_scratch_mount -o compress-force=lzo
> +
> +$XFS_IO_PROG -f -c "pwrite -i /dev/urandom 0 4k" $SCRATCH_MNT/file > /dev/null

While at it, instead of just having the minimum to trigger that
specific bug, it would also be good to:

1) Try with zlib and zstd, instead of only lzo. This way it will help
more easily catch any future regression with those algorithms;

2) Instead of redirecting to /dev/null and ignoring if we are actually
writing what we are supposed to do, can we verify that we write all
the bytes - i.e. that there's no short write?

3) After unmount, we could also mount the fs again and check if we are
able to read exactly what we tried to write - that the write was
persisted and we're not reading from the page cache.

Thanks.


> +
> +# With kernel commit d4088803f511 ("btrfs: subpage: make lzo_compress_pages()
> +# compatible"), the kernel would crash when writing back above data.
> +_scratch_unmount
> +
> +echo "Silence is golden"
> +
> +# success, all done
> +status=0
> +exit
> diff --git a/tests/btrfs/049.out b/tests/btrfs/049.out
> index cb0061b3..c69568ad 100644
> --- a/tests/btrfs/049.out
> +++ b/tests/btrfs/049.out
> @@ -1 +1,2 @@
>  QA output created by 049
> +Silence is golden
> --
> 2.33.0
>


-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”




[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux