MTD: fix slab-use-after-free due to dangling pointer in notifier chain] MTD: fix slab-use-after-free due to dangling pointer in notifier chain
Subsystems (2)
PATCH 1/1 MTD: fix slab-use-after-free due to dangling pointer in notifier chain] 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. Thus, when the chain is iterated there is a possibility of finding the address of the reboot notifier which has already been freed, resulting in a slab-use-after-free error.
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.
--- drivers/mtd/ubi/wl.c | 1 + 1 file changed, 1 insertion(+)
drivers/mtd/ubi/wl.c +1 -0
@@ -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);
Signature · 1 line
2.47.0
Quoted 32 lines · Dennis Lam
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. Thus, when the chain is iterated there is a possibility of finding the address of the reboot notifier which has already been freed, resulting in a slab-use-after-free error.
To fix this, I added an unregister notifier function in the
ubi_wl_closefunction to ensure that the notifier is removed from the chain after the device has been detached.Reported-by [email protected]Signed-off-by Dennis Lam <[email protected]>--- drivers/mtd/ubi/wl.c | 1 + 1 file changed, 1 insertion(+)drivers/mtd/ubi/wl.c +1
-1@@ -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); --
Quoted 2 lines
2.47.0
My apologies everyone, please ignore this email. My mailing script seems to have changed my email header and commit message. I will send another better formatted email later.