[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250615164547.11900-1-bharadwaj.raju777@gmail.com>
Date: Sun, 15 Jun 2025 22:15:38 +0530
From: Bharadwaj Raju <bharadwaj.raju777@...il.com>
To: kent.overstreet@...ux.dev
Cc: Bharadwaj Raju <bharadwaj.raju777@...il.com>,
linux-bcachefs@...r.kernel.org,
shuah@...nel.org,
linux-kernel@...r.kernel.org,
linux-kernel-mentees@...ts.linux.dev,
syzbot+cfd994b9cdf00446fd54@...kaller.appspotmail.com
Subject: [PATCH v2] bcachefs: don't return fsck_fix for unfixable node errors in __btree_err
After cd3cdb1ef706 ("Single err message for btree node reads"),
all errors caused __btree_err to return -BCH_ERR_fsck_fix no matter what
the actual error type was if the recovery pass was scanning for btree
nodes. This lead to the code continuing despite things like bad node
formats when they earlier would have caused a jump to fsck_err, because
btree_err only jumps when the return from __btree_err does not match
fsck_fix. Ultimately this lead to undefined behavior by attempting to
unpack a key based on an invalid format.
Make only errors of type -BCH_ERR_btree_node_read_err_fixable cause
__btree_err to return -BCH_ERR_fsck_fix when scanning for btree nodes.
Reported-by: syzbot+cfd994b9cdf00446fd54@...kaller.appspotmail.com
Fixes: cd3cdb1ef706 ("bcachefs: Single err message for btree node reads")
Signed-off-by: Bharadwaj Raju <bharadwaj.raju777@...il.com>
---
v2: Return the given ret for all errors which are not btree_node_read_err_fixable when in scan_for_btree_nodes
fs/bcachefs/btree_io.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/bcachefs/btree_io.c b/fs/bcachefs/btree_io.c
index d8f3c4c65e90..940f7ce2e33e 100644
--- a/fs/bcachefs/btree_io.c
+++ b/fs/bcachefs/btree_io.c
@@ -557,7 +557,9 @@ static int __btree_err(int ret,
const char *fmt, ...)
{
if (c->recovery.curr_pass == BCH_RECOVERY_PASS_scan_for_btree_nodes)
- return bch_err_throw(c, fsck_fix);
+ return ret == -BCH_ERR_btree_node_read_err_fixable
+ ? bch_err_throw(c, fsck_fix)
+ : ret;
bool have_retry = false;
int ret2;
--
2.49.0
Powered by blists - more mailing lists