From a5463bb621e1c2b3dbd0d690558ab7705e16b2c8 Mon Sep 17 00:00:00 2001 From: Zheng Wang Date: Mon, 20 Oct 2025 03:41:59 +0000 Subject: [PATCH] bcache: Fix __bch_btree_node_alloc to make the failure behavior consistent stable inclusion from stable-v4.19.325 commit 587b4e8bb5dac682f09280ab35db4632b29d5ac4 category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/ID0VIM CVE: CVE-2023-53681 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=587b4e8bb5dac682f09280ab35db4632b29d5ac4 -------------------------------- [ Upstream commit 80fca8a10b604afad6c14213fdfd816c4eda3ee4 ] In some specific situations, the return value of __bch_btree_node_alloc may be NULL. This may lead to a potential NULL pointer dereference in caller function like a calling chain : btree_split->bch_btree_node_alloc->__bch_btree_node_alloc. Fix it by initializing the return value in __bch_btree_node_alloc. Fixes: cafe56359144 ("bcache: A block layer cache") Cc: stable@vger.kernel.org Signed-off-by: Zheng Wang Signed-off-by: Coly Li Link: https://lore.kernel.org/r/20230615121223.22502-6-colyli@suse.de Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Conflicts: drivers/md/bcache/btree.c [Context differences.] Signed-off-by: Xia Fukun --- drivers/md/bcache/btree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c index 24e70ee342f0..2b2621a6092c 100644 --- a/drivers/md/bcache/btree.c +++ b/drivers/md/bcache/btree.c @@ -1062,10 +1062,12 @@ struct btree *__bch_btree_node_alloc(struct cache_set *c, struct btree_op *op, struct btree *parent) { BKEY_PADDED(key) k; - struct btree *b = ERR_PTR(-EAGAIN); + struct btree *b; mutex_lock(&c->bucket_lock); retry: + /* return ERR_PTR(-EAGAIN) when it fails */ + b = ERR_PTR(-EAGAIN); if (__bch_bucket_alloc_set(c, RESERVE_BTREE, &k.key, 1, wait)) goto err; -- Gitee