borisb / rpms / btrfs-progs

Forked from rpms/btrfs-progs 2 years ago
Clone
e4a3d3
From 11c4a7b38a6aeef51b075d70e5aca36c42398842 Mon Sep 17 00:00:00 2001
e4a3d3
From: Qu Wenruo <wqu@suse.com>
e4a3d3
Date: Mon, 20 Jul 2020 20:51:09 +0800
e4a3d3
Subject: [PATCH 2/2] btrfs-progs: tests: add convert test case for multiply
e4a3d3
 overflow
e4a3d3
e4a3d3
The new test case will test whether btrfs-convert can handle 64G ext*
e4a3d3
fs.
e4a3d3
e4a3d3
This exercise the cctx->total_bytes calculation where multiplying 4K
e4a3d3
(unsigned int) and 16777216 (u32) could lead to bit overflow for
e4a3d3
unsigned int and got 0, and screw up later free space calculation.
e4a3d3
e4a3d3
Signed-off-by: Qu Wenruo <wqu@suse.com>
e4a3d3
Signed-off-by: David Sterba <dsterba@suse.com>
e4a3d3
(cherry picked from commit 61f41474469b0b0fba9ec1978dfa91d9cbc6c914)
e4a3d3
---
e4a3d3
 .../018-fs-size-overflow/test.sh              | 19 +++++++++++++++++++
e4a3d3
 1 file changed, 19 insertions(+)
e4a3d3
 create mode 100755 tests/convert-tests/018-fs-size-overflow/test.sh
e4a3d3
e4a3d3
diff --git a/tests/convert-tests/018-fs-size-overflow/test.sh b/tests/convert-tests/018-fs-size-overflow/test.sh
e4a3d3
new file mode 100755
e4a3d3
index 00000000..d819f695
e4a3d3
--- /dev/null
e4a3d3
+++ b/tests/convert-tests/018-fs-size-overflow/test.sh
e4a3d3
@@ -0,0 +1,19 @@
e4a3d3
+#!/bin/bash
e4a3d3
+# Check if btrfs-convert can handle an ext4 fs whose size is 64G.
e4a3d3
+# That fs size could trigger a multiply overflow and screw up free space
e4a3d3
+# calculation
e4a3d3
+
e4a3d3
+source "$TEST_TOP/common"
e4a3d3
+source "$TEST_TOP/common.convert"
e4a3d3
+
e4a3d3
+setup_root_helper
e4a3d3
+prepare_test_dev 64g
e4a3d3
+check_prereq btrfs-convert
e4a3d3
+check_global_prereq mke2fs
e4a3d3
+
e4a3d3
+convert_test_prep_fs ext4 mke2fs -t ext4 -b 4096
e4a3d3
+run_check_umount_test_dev
e4a3d3
+
e4a3d3
+# Unpatched btrfs-convert would fail half way due to corrupted free space
e4a3d3
+# cache tree
e4a3d3
+convert_test_do_convert
e4a3d3
-- 
e4a3d3
2.26.2
e4a3d3