fstests: btrfs/049: add regression test for compress-force=lzo mount option
PATCH 1/1 fstests: btrfs/049: add regression test for compress-force=lzo mount option
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.
--- tests/btrfs/049 | 41 +++++++++++++++++++++++++++++++++++++++++ tests/btrfs/049.out | 1 + 2 files changed, 42 insertions(+) create mode 100755 tests/btrfs/049
tests/btrfs/049 new file +41 -0
@@ -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 + +# 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
tests/btrfs/049.out +1 -0
@@ -1 +1,2 @@ QA output created by 049 +Silence is golden
Signature · 1 line
2.33.0
Quoted 45 lines · Qu Wenruo
Since kernel commit
d4088803f511("btrfs: subpage: makelzo_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 <[email protected]>--- tests/btrfs/049 | 41 +++++++++++++++++++++++++++++++++++++++++ tests/btrfs/049.out | 1 + 2 files changed, 42 insertions(+) create mode 100755 tests/btrfs/049tests/btrfs/049 new file +21
-0@@ -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 +
tests/btrfs/049 line 31
Quoted 10 lines
tests/btrfs/049 new file +10
-0+# 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.
Quoted 20 lines
tests/btrfs/049 new file +10
-0+ +# 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 +exittests/btrfs/049.out +1
-1@@ -1 +1,2 @@ QA output created by 049 +Silence is golden --2.33.0
Signature · 3 lines
Filipe David Manana, “Whether you think you can, or you think you can't — you're right.”
Quoted 63 lines · Filipe Manana
Quoted 45 lines · Qu Wenruo
Since kernel commit
d4088803f511("btrfs: subpage: makelzo_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 <[email protected]>--- tests/btrfs/049 | 41 +++++++++++++++++++++++++++++++++++++++++ tests/btrfs/049.out | 1 + 2 files changed, 42 insertions(+)create mode 100755 tests/btrfs/049
tests/btrfs/049 new file +21
-0@@ -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 +tests/btrfs/049 line 31
Quoted 10 lines
tests/btrfs/049 new file +10
-0+# 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/nullWhile 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;
Quoted 7 lines
2) Instead of redirecting to
/dev/nulland 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.
That would be a pretty good generic advice for all regression tests.
Would try to keep these advices in mind for all future tests.
Thanks,
Qu
Quoted 26 lines
Thanks.
Quoted 20 lines
tests/btrfs/049 new file +10
-0+ +# 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 +exittests/btrfs/049.out +1
-1@@ -1 +1,2 @@ QA output created by 049 +Silence is golden --2.33.0