mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] btrfs: verity: return error from btrfs_orphan_add in begin_enable_verity
@ 2026-10-15  7:11 guolingxing
  2026-10-15  9:02 ` Qu Wenruo
  0 siblings, 1 reply; 4+ messages in thread
From: guolingxing @ 2026-10-15  7:11 UTC (permalink / raw)
  To: David Sterba, Chris Mason, Boris Burkov
  Cc: linux-btrfs, linux-kernel, guolingxing, stable

btrfs_begin_enable_verity() ignores the return value of
btrfs_orphan_add() and unconditionally returns 0. When inserting the
orphan item fails (e.g. -ENOMEM), the error is swallowed and the
caller continues to build the Merkle tree even though the orphan item
was never written and BTRFS_INODE_VERITY_IN_PROGRESS was not set,
leaving the on-disk state inconsistent.

Propagate the error to the caller so that fsverity_ioctl_enable()
aborts before building the Merkle tree. The transaction is already
aborted inside btrfs_orphan_add() on failure and released by the
unconditional btrfs_end_transaction(), so only the return value needs
to change.

Fixes: 705242538ff3 ("btrfs: verity metadata orphan items")
Cc: stable@vger.kernel.org
Signed-off-by: guolingxing <guolingxing@tju.edu.cn>
---
 fs/btrfs/verity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/verity.c b/fs/btrfs/verity.c
index 600337a84fbe..d92c9dab0293 100644
--- a/fs/btrfs/verity.c
+++ b/fs/btrfs/verity.c
@@ -615,7 +615,7 @@ static int btrfs_begin_enable_verity(struct file *filp)
 		set_bit(BTRFS_INODE_VERITY_IN_PROGRESS, &inode->runtime_flags);
 	btrfs_end_transaction(trans);
 
-	return 0;
+	return ret;
 }
 
 /*
-- 
2.34.1


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

end of thread, other threads:[~2026-10-15 10:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-15  7:11 [PATCH] btrfs: verity: return error from btrfs_orphan_add in begin_enable_verity guolingxing
2026-10-15  9:02 ` Qu Wenruo
2026-10-15  9:59   ` [PATCH v2] btrfs: verity: propagate orphan insertion errors when enabling verity guolingxing
2026-10-15 10:34     ` Qu Wenruo

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

all inboxes | Powered by JetHome®