public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs-progs: check/lowmem: fix false alerts about verity items
@ 2026-03-24 23:47 Qu Wenruo
  2026-03-24 23:47 ` [PATCH 1/2] btrfs-progs: check/lowmem: recognize verity item keys Qu Wenruo
  2026-03-24 23:47 ` [PATCH 2/2] btrfs-progs: fsck-tests: add a test case for verity items Qu Wenruo
  0 siblings, 2 replies; 3+ messages in thread
From: Qu Wenruo @ 2026-03-24 23:47 UTC (permalink / raw)
  To: linux-btrfs

Leo reported and fixed a bug in original mode where false alerts were
triggered about verity items.

Unfortunately we have a similar problem in lowmem mode too.

Fix the lowmem mode false alert and add a test case to prevent similar
problems in the future.

Qu Wenruo (2):
  btrfs-progs: check/lowmem: recognize verity item keys
  btrfs-progs: fsck-tests: add a test case for verity items

 check/mode-lowmem.c                              |   3 +++
 .../fsck-tests/072-verity-items/fsverity.img.xz  | Bin 0 -> 2364 bytes
 tests/fsck-tests/072-verity-items/test.sh        |  15 +++++++++++++++
 3 files changed, 18 insertions(+)
 create mode 100644 tests/fsck-tests/072-verity-items/fsverity.img.xz
 create mode 100755 tests/fsck-tests/072-verity-items/test.sh

--
2.53.0


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

* [PATCH 1/2] btrfs-progs: check/lowmem: recognize verity item keys
  2026-03-24 23:47 [PATCH 0/2] btrfs-progs: check/lowmem: fix false alerts about verity items Qu Wenruo
@ 2026-03-24 23:47 ` Qu Wenruo
  2026-03-24 23:47 ` [PATCH 2/2] btrfs-progs: fsck-tests: add a test case for verity items Qu Wenruo
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2026-03-24 23:47 UTC (permalink / raw)
  To: linux-btrfs

Commit 4e88bb6e ("btrfs-progs: enhance detection on unknown inode keys")
added stricter validation for inode keys in the lowmem mode checker,
flagging unknown key types as errors. However, it did not add cases for
BTRFS_VERITY_DESC_ITEM_KEY (36) and BTRFS_VERITY_MERKLE_ITEM_KEY (37),
causing any filesystem with fs-verity enabled files to fail the lowmem
mode check with the following error:

 [5/8] checking fs roots
 ERROR: ITEM[257 36 0] UNKNOWN TYPE in leaf 30490624
 ERROR: ITEM[257 36 1] UNKNOWN TYPE in leaf 30490624
 ERROR: ITEM[257 37 0] UNKNOWN TYPE in leaf 30490624
 ERROR: ITEM[257 37 2048] UNKNOWN TYPE in leaf 30490624
 ERROR: errors found in fs roots

Add the missing switch cases so that verity metadata items are
recognized and silently skipped during the lowmem check.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 check/mode-lowmem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index 4375b92a5d12..5f41cda965a4 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -2817,7 +2817,10 @@ static int check_inode_item(struct btrfs_root *root, struct btrfs_path *path)
 			err |= ret;
 			break;
 		case BTRFS_XATTR_ITEM_KEY:
+		case BTRFS_VERITY_DESC_ITEM_KEY:
+		case BTRFS_VERITY_MERKLE_ITEM_KEY:
 			break;
+
 		default:
 			error("ITEM[%llu %u %llu] UNKNOWN TYPE in leaf %llu",
 			      key.objectid, key.type, key.offset, node->start);
-- 
2.53.0


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

* [PATCH 2/2] btrfs-progs: fsck-tests: add a test case for verity items
  2026-03-24 23:47 [PATCH 0/2] btrfs-progs: check/lowmem: fix false alerts about verity items Qu Wenruo
  2026-03-24 23:47 ` [PATCH 1/2] btrfs-progs: check/lowmem: recognize verity item keys Qu Wenruo
@ 2026-03-24 23:47 ` Qu Wenruo
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2026-03-24 23:47 UTC (permalink / raw)
  To: linux-btrfs

Leo recently fixed a false alerts in btrfs-check where verity items are
reported as unknown items.

Add a test case for such case, the image is generated by enabling
fsverity on a small file, which will have VERITY_DESC_ITEM and
VERITY_MERKLE_ITEM items to trigger the previous false alerts.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../fsck-tests/072-verity-items/fsverity.img.xz  | Bin 0 -> 2364 bytes
 tests/fsck-tests/072-verity-items/test.sh        |  15 +++++++++++++++
 2 files changed, 15 insertions(+)
 create mode 100644 tests/fsck-tests/072-verity-items/fsverity.img.xz
 create mode 100755 tests/fsck-tests/072-verity-items/test.sh

diff --git a/tests/fsck-tests/072-verity-items/fsverity.img.xz b/tests/fsck-tests/072-verity-items/fsverity.img.xz
new file mode 100644
index 0000000000000000000000000000000000000000..eba1bbb4192e28820d86f4bf2fe13ba1a2ee3edd
GIT binary patch
literal 2364
zcmexsUKJ6=z`*kC+7>sK13v{D6cic77$9KQ7q_1e`2TZ!jAd}0*|$7$-{ylSr7F{R
zJGN<<94w2|a7amxYX2E`_&}V*nYpLd%h|jCe|B?)bi3X!?v*Dj7usyyeQAT@gtSYp
z1vh^MTvF`suhn8`x)sxDvG{RGo|ioL<wZfviO&Ok7W?vVEVWUd_+X;3|LKUb6F&?j
zt`+MFxH<_7t()^V>vdMjHKUccJ)~{6Cy2f7R9zHu@8chn=zT}sCfr^0sY+>4bI7Y$
zzH{4Uw0cGEJrG+l?|sn8RKM`UR}1?CG&l21*`QUv-RF~Lj?1@vuRFWizu6pZuk4&>
zky6h!_o1S2i?h`h-Ts{gyUuO?)ls>hF_lxL=lVOH&(p&vsdQu=VNEHy+&4>}`$Qna
z(sf^UdiqzgKY1LGwm5Ea<ngKN1tO0~)aM^)SZuT4K)PJ^v8{5=5{&-#Cf#;>KF3ec
z{S<b%(VtCsO2~X8)9)$wWj8;r-{Pc^!t$ne(!Vcj(`OYmeRf#ASnBHut@nH(mPHZe
z3?~(qR_`iWCnB9C!SCf6l)m?lp?Okxp=RK!FIV4lbj5kH{@^=vc5%?n#V189eJ?Nf
z)cSsX{hSLz8&pmyEijXr_2AX6NiTM-Pd0OT7?irRuIpRu9nA+->({GIu+&my<!<6~
z5Ll|Xt?gL%!Dn~QcqW{Bny3>ht9kFdXZnTGC+7S+>`&~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Qt^Z)5@e(1OB#_bPMn|Pu|#g<LGMzAU9tz3ua
z?Y$zMvo1b&kpKQHq{GW5^vmyklgwCG&fUAZK`SLgJbSGazg+Rh`o+7NPTUeNkLtWT
zcg|sJvBLMO_q}0IY;gV{6|qM~x+3#h*vmDp+n<E-O*&=Bw&o#Ijc?IX<An96CoGk8
zn)UFUs!Q{OqxHcRUwYRuy<A)6YHj17!1Z(GVR4f*CN<sk;|weLTDM0(Wl6W5ziw)u
z-PvWy{wLSXy!Xknmv<+3QLA?M9ESMK0w1nTpLgtK<!ev9+3P0NOx^#*wxM`p#k56R
zJEO8!zdT-ZfcwfOr%wTWcX{S4OHd2(;$gmbSLGPryF;5w<}Y>8T)z5@y;+f$fmYPp
s_~myO@G^rNK>a^0=TyJx-^;)_Rj5IMfk7nwl;g%D>A#skvMiBN0DJd}YXATM

literal 0
HcmV?d00001

diff --git a/tests/fsck-tests/072-verity-items/test.sh b/tests/fsck-tests/072-verity-items/test.sh
new file mode 100755
index 000000000000..d5dc08a09afa
--- /dev/null
+++ b/tests/fsck-tests/072-verity-items/test.sh
@@ -0,0 +1,15 @@
+#!/bin/bash
+#
+# Verify that check can handle btrfs with fsverity features properly
+
+source "$TEST_TOP/common" || exit
+
+check_prereq btrfs
+
+check_image() {
+	# The image contains verity data in the fs tree.
+	# The check should not report verity items as errors.
+	run_check "$TOP/btrfs" check "$1"
+}
+
+check_all_images
-- 
2.53.0


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

end of thread, other threads:[~2026-03-24 23:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-24 23:47 [PATCH 0/2] btrfs-progs: check/lowmem: fix false alerts about verity items Qu Wenruo
2026-03-24 23:47 ` [PATCH 1/2] btrfs-progs: check/lowmem: recognize verity item keys Qu Wenruo
2026-03-24 23:47 ` [PATCH 2/2] btrfs-progs: fsck-tests: add a test case for verity items Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox