All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] btrfs-progs: Detect compressed extent without csum
@ 2018-05-14  6:54 Qu Wenruo
  2018-05-14  6:54 ` [PATCH 1/3] btrfs-progs: check/lowmem: Add checks for " Qu Wenruo
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Qu Wenruo @ 2018-05-14  6:54 UTC (permalink / raw)
  To: linux-btrfs

Patches can be fetch from github:
https://github.com/adam900710/btrfs-progs/tree/compress_nodatasum

It's based on v4.16 stable branch.

James Harvey from mail list reports a strange kernel panic, whichs show
obviously kernel memory corruption, while after btrfs decompression
failure.

It turns out that, some compressed extent get corrupted on-disk, while
the inode has NODATASUM set, there is no csum to prevent corrupted
mirror being used.

Although the root cause should be buggy lzo implementation, it still
shows that btrfs is not following the behavior defined in btrfs(5):

     Note
     If nodatacow or nodatasum are enabled, compression is disabled.

So at least make btrfs check to detect such problem.

Qu Wenruo (3):
  btrfs-progs: check/lowmem: Add checks for compressed extent without
    csum
  btrfs-progs: check/original: Add checks for compressed extent without
    csum
  btrfs-progs: fsck-tests: Add test case for detecting compressed extent
    without csum

 check/main.c                                  |  10 ++++++--
 check/mode-lowmem.c                           |  18 +++++++++++++
 .../compressed_extent_without_csum.raw.xz     | Bin 0 -> 21996 bytes
 .../032-compressed-nodatasum/test.sh          |  24 ++++++++++++++++++
 4 files changed, 50 insertions(+), 2 deletions(-)
 create mode 100644 tests/fsck-tests/032-compressed-nodatasum/compressed_extent_without_csum.raw.xz
 create mode 100755 tests/fsck-tests/032-compressed-nodatasum/test.sh

-- 
2.17.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] btrfs-progs: check/lowmem: Add checks for compressed extent without csum
  2018-05-14  6:54 [PATCH 0/3] btrfs-progs: Detect compressed extent without csum Qu Wenruo
@ 2018-05-14  6:54 ` Qu Wenruo
  2018-05-14  6:54 ` [PATCH 2/3] btrfs-progs: check/original: " Qu Wenruo
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Qu Wenruo @ 2018-05-14  6:54 UTC (permalink / raw)
  To: linux-btrfs

There is one report of compressed extent happens in btrfs, but has no
csum and then leads to possible decompress error screwing up kernel
memory.

Although it's a kernel bug, and won't cause problem until compressed
data get corrupted, let's catch such problem in advance.

This patch will catch any unexpected compressed extent with:

1) 0 or less than expected csum

2) nodatasum flag set in the inode item

This is for lowmem mode.

Reported-by: James Harvey <jamespharvey20@gmail.com>
Issue: #134
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 check/mode-lowmem.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index dac3201b7d99..8e6d5e8de12a 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -1543,6 +1543,24 @@ static int check_file_extent(struct btrfs_root *root, struct btrfs_key *fkey,
 			      csum_found);
 		}
 	}
+	/*
+	 * Extra check for compressed extents.
+	 * Btrfs doesn't allow NODATASUM and compressed extent co-exist, thus
+	 * all compressed extent should have csum.
+	 */
+	if (compressed && csum_found < search_len) {
+		error(
+"root %llu EXTENT_DATA[%llu %llu] compressed extent must have csum, but only %llu bytes has csum, expect %llu",
+		      root->objectid, fkey->objectid, fkey->offset, csum_found,
+		      search_len);
+		err |= CSUM_ITEM_MISSING;
+	}
+	if (compressed && nodatasum) {
+		error(
+"root %llu EXTENT_DATA[%llu %llu] is compressed, but inode flag doesn't allow it",
+		      root->objectid, fkey->objectid, fkey->offset);
+		err |= FILE_EXTENT_ERROR;
+	}
 
 	/* Check EXTENT_DATA hole */
 	if (!no_holes && *end != fkey->offset) {
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] btrfs-progs: check/original: Add checks for compressed extent without csum
  2018-05-14  6:54 [PATCH 0/3] btrfs-progs: Detect compressed extent without csum Qu Wenruo
  2018-05-14  6:54 ` [PATCH 1/3] btrfs-progs: check/lowmem: Add checks for " Qu Wenruo
@ 2018-05-14  6:54 ` Qu Wenruo
  2018-05-14  6:54 ` [PATCH 3/3] btrfs-progs: fsck-tests: Add test case for detecting " Qu Wenruo
  2018-09-11 15:58 ` [PATCH 0/3] btrfs-progs: Detect " David Sterba
  3 siblings, 0 replies; 7+ messages in thread
From: Qu Wenruo @ 2018-05-14  6:54 UTC (permalink / raw)
  To: linux-btrfs

There is one report of compressed extent happens in btrfs, but has no
csum and then leads to possible decompress error screwing up kernel
memory.

Although it's a kernel bug, and won't cause problem until compressed
data get corrupted, let's catch such problem in advance.

This patch will catch any unexpected compressed extent with:

1) 0 or less than expected csum

2) nodatasum flag set in the inode item

This is for original mode.

Reported-by: James Harvey <jamespharvey20@gmail.com>
Issue: #134
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 check/main.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/check/main.c b/check/main.c
index 891a6d797756..db064b27e84b 100644
--- a/check/main.c
+++ b/check/main.c
@@ -1437,6 +1437,7 @@ static int process_file_extent(struct btrfs_root *root,
 	u64 mask = root->fs_info->sectorsize - 1;
 	u32 max_inline_size = min_t(u32, mask,
 				BTRFS_MAX_INLINE_DATA_SIZE(root->fs_info));
+	u8 compression;
 	int extent_type;
 	int ret;
 
@@ -1460,9 +1461,9 @@ static int process_file_extent(struct btrfs_root *root,
 
 	fi = btrfs_item_ptr(eb, slot, struct btrfs_file_extent_item);
 	extent_type = btrfs_file_extent_type(eb, fi);
+	compression = btrfs_file_extent_compression(eb, fi);
 
 	if (extent_type == BTRFS_FILE_EXTENT_INLINE) {
-		u8 compression = btrfs_file_extent_compression(eb, fi);
 		struct btrfs_item *item = btrfs_item_nr(slot);
 
 		num_bytes = btrfs_file_extent_inline_len(eb, slot, fi);
@@ -1494,6 +1495,8 @@ static int process_file_extent(struct btrfs_root *root,
 		     btrfs_file_extent_encryption(eb, fi) ||
 		     btrfs_file_extent_other_encoding(eb, fi)))
 			rec->errors |= I_ERR_BAD_FILE_EXTENT;
+		if (compression && rec->nodatasum)
+			rec->errors |= I_ERR_BAD_FILE_EXTENT;
 		if (disk_bytenr > 0)
 			rec->found_size += num_bytes;
 	} else {
@@ -1512,7 +1515,8 @@ static int process_file_extent(struct btrfs_root *root,
 	if (disk_bytenr > 0 &&
 	    btrfs_header_owner(eb) != BTRFS_DATA_RELOC_TREE_OBJECTID) {
 		u64 found;
-		if (btrfs_file_extent_compression(eb, fi))
+
+		if (compression)
 			num_bytes = btrfs_file_extent_disk_num_bytes(eb, fi);
 		else
 			disk_bytenr += extent_offset;
@@ -1526,6 +1530,8 @@ static int process_file_extent(struct btrfs_root *root,
 				rec->found_csum_item = 1;
 			if (found < num_bytes)
 				rec->some_csum_missing = 1;
+			if (compression && found < num_bytes)
+				rec->errors |= I_ERR_SOME_CSUM_MISSING;
 		} else if (extent_type == BTRFS_FILE_EXTENT_PREALLOC) {
 			if (found > 0) {
 				ret = check_prealloc_extent_written(root->fs_info,
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] btrfs-progs: fsck-tests: Add test case for detecting compressed extent without csum
  2018-05-14  6:54 [PATCH 0/3] btrfs-progs: Detect compressed extent without csum Qu Wenruo
  2018-05-14  6:54 ` [PATCH 1/3] btrfs-progs: check/lowmem: Add checks for " Qu Wenruo
  2018-05-14  6:54 ` [PATCH 2/3] btrfs-progs: check/original: " Qu Wenruo
@ 2018-05-14  6:54 ` Qu Wenruo
  2018-09-11 15:58 ` [PATCH 0/3] btrfs-progs: Detect " David Sterba
  3 siblings, 0 replies; 7+ messages in thread
From: Qu Wenruo @ 2018-05-14  6:54 UTC (permalink / raw)
  To: linux-btrfs

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../compressed_extent_without_csum.raw.xz     | Bin 0 -> 21996 bytes
 .../032-compressed-nodatasum/test.sh          |  24 ++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100644 tests/fsck-tests/032-compressed-nodatasum/compressed_extent_without_csum.raw.xz
 create mode 100755 tests/fsck-tests/032-compressed-nodatasum/test.sh

diff --git a/tests/fsck-tests/032-compressed-nodatasum/compressed_extent_without_csum.raw.xz b/tests/fsck-tests/032-compressed-nodatasum/compressed_extent_without_csum.raw.xz
new file mode 100644
index 0000000000000000000000000000000000000000..72a3bfd8f8b0bf2d610ce84af0abf4003204a9a1
GIT binary patch
literal 21996
zcmeI4c{J4jzsG075Hj{%+4r4FX&MniW8cQskdS4vi)<lfvcw3HouX{xha%atQzN?w
zSu<oevdr&$?)RVXJ?GwgemcMI&%M9TfAi0rIp;O6=i~i+z22|)>)?EVxdjMBJ~vpQ
zaRS5#<_3X4^dHT;NhCpX6KfFY&H;&(`-Y@>`5KGo1zUr+38Hhkk(9eDGpEBo%Y3+a
z39N$)?!aIWGP$QlLSB4}7GN-%M6!SI!A$!Rs}e(Kof{^+wd}33Zf48xDWoJETEpI1
zJaKTil_;sFO{y5G4$!50I$USB9T)ZvTBJJ#(kP=uiH=7`xOc6GK=#_tkR<n8k@JF&
zjMBbZF`BDZ^~*KTxP@%{A@}XVf)T_)S6NW^1&5~=OtD;C*ZNmfERAswJ0-@Ohf+_>
z!d{gr!mh{ZL~)Oii%0PJQei`H+mC;Yxx{KdS%S%NR`Bvi*^?KY$%coNW6;V}UKynZ
z3=&A&39BUc+4ThIxAm!uXIYjteyW8|r>EMS(~?<y5t5$3JcvHvAn<W)6$uhJ1GdHt
zYToCpTc&#}8TxC8my_`k0v|G=A7_LOpInT_@RFB*Th`rTDY`b>^bM1~jLjZ!OX!as
zb(qrq4tu7>D)Dqz^QZ2-;dBDTlq2J6#&q9|#<ub5BOgiGu_k@vc>ZJv*^Lf&W#$I?
z^C|f(;QWQ$lj4L|Bn#mpPg>T5mvtB71gG3HUJBeGh;}`|KTW{|i^s2v`0Q{rKvEDX
zwPs0=Z5_M?GL!Ev)YPx{k7hQHNH53}sRkpOKSUSa773^byveV<DM=+na8u)VtnfAO
zeov#3M``lOW9<B5duVL{lNo1E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Cx5JE9lg6$gUz=xiNWq
z>6gz1(l66=*;EJ>MmzKHW?I@h>(&)TW9;J_RX?@k!?bhB3uq+MRk2IMqfr*hG^;`9
z6ce6nI6Yf@o7vk4?a#cfQ!~hYe$|H?GLUCF_&wzGT2}8GkIcosMX|}}(zV<D`rq_&
z*$Sd(23lnXs<J!B@NtI?Is0$(Gb?gd#p$R*Z`%=wXPiO=NT+TRp?zLv<|76<^X~@k
z&TfK(zNG)hUG87{ME{g~u-YUEJYX;Yg8>+fV|LjK6qiRVE`fjn0sCE}A3%}xOGOeO
zNkEc-B#+e$86ZhOl7J+Sl_Z~mFN2m`PUnr}l6}GsAzkGPO9k|CZZLM8&>+OqK<7#4
zf61KPU&d=UN~qwW)(3+^$8bJ2h>ubVXkZ+<fst}dui_4`sQNDd?Az<To=b2!R-@W>
z?t95Vq8&NW0K)+o4#036E5iXu5|AVyNkEeSm*2tx3<DSjFbrTAz_5R#2hj9jNf5!i
z>5=&+=dgr`^qbwQRjB0`?i0E;exj+=DaPob$DNPhH{|x(^%j_5Z@z`r2ow+@k4Lsb
z22XLpgZy5HGxMSG0|6VCnT_oJ-#rrl&vV7<1&A*|yW$tx6;j7)t}``@zo_(w>mOSd
zu82`zy&^t+oYowWX^US0a_kp!3|M^e5ANIm1}}iYi{HD|1;{WU!+;DshTD#S4iC`b
z0XjTDhX?5J{9AQ+fYRs)rBUelZV)Ai;2Dx#T>8fX*PiIc3tVG}P7t{HH8?ahROOF7
Vt|BkKz?s>UWy${d3?fHb{2eaBAT9s^

literal 0
HcmV?d00001

diff --git a/tests/fsck-tests/032-compressed-nodatasum/test.sh b/tests/fsck-tests/032-compressed-nodatasum/test.sh
new file mode 100755
index 000000000000..ebec74dffdbd
--- /dev/null
+++ b/tests/fsck-tests/032-compressed-nodatasum/test.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+#
+# Verify that btrfs check can detect compressed extent without csum as an error
+#
+# There is report about nodatasum inode which has compressed extent, and when
+# its compressed data is corrupted, decompress screw up the whole kernel.
+#
+# While btrfs(5) shows that nodatasum will disable data CoW and compression,
+# kernel obviously doesn't follow it well. And in above case, lzo problem
+# can leads to more serious kernel memory corruption since btrfs completely
+# depends its csum to prevent corruption.
+#
+# So btrfs check should report such compressed extent without csum as error.
+
+source "$TEST_TOP/common"
+
+check_prereq btrfs
+
+check_image() {
+	run_mustfail "btrfs fails to detect compressed extent with csum as an error" \
+		"$TOP/btrfs" check "$1"
+}
+
+check_all_images
-- 
2.17.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] btrfs-progs: Detect compressed extent without csum
  2018-05-14  6:54 [PATCH 0/3] btrfs-progs: Detect compressed extent without csum Qu Wenruo
                   ` (2 preceding siblings ...)
  2018-05-14  6:54 ` [PATCH 3/3] btrfs-progs: fsck-tests: Add test case for detecting " Qu Wenruo
@ 2018-09-11 15:58 ` David Sterba
  2018-09-12  0:08   ` Qu Wenruo
  3 siblings, 1 reply; 7+ messages in thread
From: David Sterba @ 2018-09-11 15:58 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs

On Mon, May 14, 2018 at 02:54:41PM +0800, Qu Wenruo wrote:
> Patches can be fetch from github:
> https://github.com/adam900710/btrfs-progs/tree/compress_nodatasum
> 
> It's based on v4.16 stable branch.
> 
> James Harvey from mail list reports a strange kernel panic, whichs show
> obviously kernel memory corruption, while after btrfs decompression
> failure.
> 
> It turns out that, some compressed extent get corrupted on-disk, while
> the inode has NODATASUM set, there is no csum to prevent corrupted
> mirror being used.
> 
> Although the root cause should be buggy lzo implementation, it still
> shows that btrfs is not following the behavior defined in btrfs(5):
> 
>      Note
>      If nodatacow or nodatasum are enabled, compression is disabled.
> 
> So at least make btrfs check to detect such problem.
> 
> Qu Wenruo (3):
>   btrfs-progs: check/lowmem: Add checks for compressed extent without
>     csum
>   btrfs-progs: check/original: Add checks for compressed extent without
>     csum
>   btrfs-progs: fsck-tests: Add test case for detecting compressed extent
>     without csum

Sorry for late reply, can you please refresh the patches on top of a
more recent progs? Thanks.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] btrfs-progs: Detect compressed extent without csum
  2018-09-11 15:58 ` [PATCH 0/3] btrfs-progs: Detect " David Sterba
@ 2018-09-12  0:08   ` Qu Wenruo
  0 siblings, 0 replies; 7+ messages in thread
From: Qu Wenruo @ 2018-09-12  0:08 UTC (permalink / raw)
  To: dsterba, Qu Wenruo, linux-btrfs


[-- Attachment #1.1: Type: text/plain, Size: 1603 bytes --]



On 2018/9/11 下午11:58, David Sterba wrote:
> On Mon, May 14, 2018 at 02:54:41PM +0800, Qu Wenruo wrote:
>> Patches can be fetch from github:
>> https://github.com/adam900710/btrfs-progs/tree/compress_nodatasum
>>
>> It's based on v4.16 stable branch.
>>
>> James Harvey from mail list reports a strange kernel panic, whichs show
>> obviously kernel memory corruption, while after btrfs decompression
>> failure.
>>
>> It turns out that, some compressed extent get corrupted on-disk, while
>> the inode has NODATASUM set, there is no csum to prevent corrupted
>> mirror being used.
>>
>> Although the root cause should be buggy lzo implementation, it still
>> shows that btrfs is not following the behavior defined in btrfs(5):
>>
>>      Note
>>      If nodatacow or nodatasum are enabled, compression is disabled.
>>
>> So at least make btrfs check to detect such problem.
>>
>> Qu Wenruo (3):
>>   btrfs-progs: check/lowmem: Add checks for compressed extent without
>>     csum
>>   btrfs-progs: check/original: Add checks for compressed extent without
>>     csum
>>   btrfs-progs: fsck-tests: Add test case for detecting compressed extent
>>     without csum
> 
> Sorry for late reply, can you please refresh the patches on top of a
> more recent progs? Thanks.

https://github.com/adam900710/btrfs-progs/tree/compress_nodatasum

Branch updated.

Rebased to v4.17.1 tag, with first patch commit message change:
"1) 0 or less than expected csum" -> "1) missing csum"

And re-numbering the test case of the last patch from 032 to 036.

Thanks,
Qu


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 0/3] btrfs-progs: Detect compressed extent without csum
@ 2018-05-14  7:03 Qu Wenruo
  0 siblings, 0 replies; 7+ messages in thread
From: Qu Wenruo @ 2018-05-14  7:03 UTC (permalink / raw)
  To: linux-btrfs

Patches can be fetch from github:
https://github.com/adam900710/btrfs-progs/tree/compress_nodatasum

It's based on v4.16 stable branch.

James Harvey from mail list reports a strange kernel panic, whichs show
obviously kernel memory corruption, while after btrfs decompression
failure.

It turns out that, some compressed extent get corrupted on-disk, while
the inode has NODATASUM set, there is no csum to prevent corrupted
mirror being used.

Although the root cause should be buggy lzo implementation, it still
shows that btrfs is not following the behavior defined in btrfs(5):

     Note
     If nodatacow or nodatasum are enabled, compression is disabled.

So at least make btrfs check to detect such problem.

Qu Wenruo (3):
  btrfs-progs: check/lowmem: Add checks for compressed extent without
    csum
  btrfs-progs: check/original: Add checks for compressed extent without
    csum
  btrfs-progs: fsck-tests: Add test case for detecting compressed extent
    without csum

 check/main.c                                  |  10 ++++++--
 check/mode-lowmem.c                           |  18 +++++++++++++
 .../compressed_extent_without_csum.raw.xz     | Bin 0 -> 21996 bytes
 .../032-compressed-nodatasum/test.sh          |  24 ++++++++++++++++++
 4 files changed, 50 insertions(+), 2 deletions(-)
 create mode 100644 tests/fsck-tests/032-compressed-nodatasum/compressed_extent_without_csum.raw.xz
 create mode 100755 tests/fsck-tests/032-compressed-nodatasum/test.sh

-- 
2.17.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-09-12  5:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-14  6:54 [PATCH 0/3] btrfs-progs: Detect compressed extent without csum Qu Wenruo
2018-05-14  6:54 ` [PATCH 1/3] btrfs-progs: check/lowmem: Add checks for " Qu Wenruo
2018-05-14  6:54 ` [PATCH 2/3] btrfs-progs: check/original: " Qu Wenruo
2018-05-14  6:54 ` [PATCH 3/3] btrfs-progs: fsck-tests: Add test case for detecting " Qu Wenruo
2018-09-11 15:58 ` [PATCH 0/3] btrfs-progs: Detect " David Sterba
2018-09-12  0:08   ` Qu Wenruo
2018-05-14  7:03 Qu Wenruo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.