Thread (3 messages) 3 messages, 3 authors, 2021-11-12

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

From: Qu Wenruo <hidden>
Date: 2021-11-12 02:35:57
Also in: linux-btrfs
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 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
+
+# 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help