From f0762826193c08b2346f4aadc52c6524a5c45eee Mon Sep 17 00:00:00 2001 From: Coly Li Date: Apr 13 2024 06:51:51 +0000 Subject: bcache: Fix __bch_btree_node_alloc to make the failure behavior consistent (git-fixes). --- diff --git a/patches.suse/bcache-Fix-__bch_btree_node_alloc-to-make-the-failur-80fc.patch b/patches.suse/bcache-Fix-__bch_btree_node_alloc-to-make-the-failur-80fc.patch new file mode 100644 index 0000000..8b5dc1e --- /dev/null +++ b/patches.suse/bcache-Fix-__bch_btree_node_alloc-to-make-the-failur-80fc.patch @@ -0,0 +1,48 @@ +From 80fca8a10b604afad6c14213fdfd816c4eda3ee4 Mon Sep 17 00:00:00 2001 +From: Zheng Wang +Date: Thu, 15 Jun 2023 20:12:22 +0800 +Subject: [PATCH] bcache: Fix __bch_btree_node_alloc to make the failure + behavior consistent +Git-commit: 80fca8a10b604afad6c14213fdfd816c4eda3ee4 +Patch-mainline: v6.5-rc1 +References: git-fixes + +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 + +--- + 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 7c21e54468bf..0ddf91204782 100644 +--- a/drivers/md/bcache/btree.c ++++ b/drivers/md/bcache/btree.c +@@ -1090,10 +1090,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, wait)) + goto err; + +-- +2.35.3 + diff --git a/series.conf b/series.conf index 312465a..de38029 100644 --- a/series.conf +++ b/series.conf @@ -42381,6 +42381,7 @@ patches.suse/md-raid10-prevent-soft-lockup-while-flush-writes-0104.patch patches.suse/bcache-Remove-dead-references-to-cache_readaheads-ccb8.patch patches.suse/bcache-Remove-unnecessary-NULL-point-check-in-node-a-028d.patch + patches.suse/bcache-Fix-__bch_btree_node_alloc-to-make-the-failur-80fc.patch patches.suse/nvme-core-fix-memory-leak-in-dhchap_secret_store.patch patches.suse/nvme-core-fix-memory-leak-in-dhchap_ctrl_secret.patch patches.suse/nvme-core-fix-dev_pm_qos-memleak.patch