Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH] btrfs: don't clobber ret in btrfs_validate_super()
@ 2025-03-11 16:39 Mark Harmstone
  2025-03-11 16:54 ` Filipe Manana
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Mark Harmstone @ 2025-03-11 16:39 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Mark Harmstone, Qu Wenruo

Commit 2a9bb78cfd36 introduces a call to validate_sys_chunk_array() in
btrfs_validate_super(), which clobbers the value of ret set earlier.
This has the effect of negating the validity checks done earlier, making
it so btrfs could potentially try to mount invalid filesystems.

Signed-off-by: Mark Harmstone <maharmstone@fb.com>
Cc: Qu Wenruo <wqu@suse.com>
Fixes: 2a9bb78cfd36 ("btrfs: validate system chunk array at btrfs_validate_super()")
---
 fs/btrfs/disk-io.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 0afd3c0f2fab..4421c946a53c 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2562,6 +2562,9 @@ int btrfs_validate_super(const struct btrfs_fs_info *fs_info,
 		ret = -EINVAL;
 	}
 
+	if (ret)
+		return ret;
+
 	ret = validate_sys_chunk_array(fs_info, sb);
 
 	/*
-- 
2.45.3


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

end of thread, other threads:[~2025-03-12 14:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-11 16:39 [PATCH] btrfs: don't clobber ret in btrfs_validate_super() Mark Harmstone
2025-03-11 16:54 ` Filipe Manana
2025-03-11 18:27   ` Mark Harmstone
2025-03-11 21:10 ` Qu Wenruo
2025-03-12 14:18   ` David Sterba
2025-03-12 14:26 ` David Sterba

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