[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241208175211.9406-2-dennis.lamerice@gmail.com>
Date: Sun, 8 Dec 2024 12:52:12 -0500
From: Dennis Lam <dennis.lamerice@...il.com>
To: richard@....at,
chengzhihao1@...wei.com,
miquel.raynal@...tlin.com,
vigneshr@...com
Cc: linux-kernel@...r.kernel.org,
linux-mtd@...ts.infradead.org,
syzbot+0988a383ae7c57b99dd9@...kaller.appspotmail.com,
syzkaller-bugs@...glegroups.com,
Dennis Lam <dennis.lamerice@...il.com>
Subject: [PATCH] MTD: fix slab-use-after-free due to dangling pointer in notifier chain
When attaching MTDs, a reboot notifier is added to the blocking
notification chain. However, when detaching a MTD and freeing its
related objects, the notifier is never unregistered from the
notification chain and is freed during the detaching process. This
results in the slab-use-after-free.
To fix this, I added an unregister notifier function in the ubi_wl_close
function to ensure that the notifier is removed from the chain after the
device has been detached.
Signed-off-by: Dennis Lam <dennis.lamerice@...il.com>
Reported-by: syzbot+0988a383ae7c57b99dd9@...kaller.appspotmail.com
Closes: https://lore.kernel.org/all/67409091.050a0220.363a1b.013d.GAE@google.com/T/
---
drivers/mtd/ubi/wl.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 4f6f339d8fb8..31a1e5515d98 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1995,6 +1995,7 @@ static void protection_queue_destroy(struct ubi_device *ubi)
void ubi_wl_close(struct ubi_device *ubi)
{
dbg_wl("close the WL sub-system");
+ unregister_reboot_notifier(&ubi->wl_reboot_notifier);
ubi_fastmap_close(ubi);
shutdown_work(ubi);
protection_queue_destroy(ubi);
--
2.47.0
Powered by blists - more mailing lists