On Sat, 18 Jul 2026, Junzhe Yu wrote:
> Hello,
>
> I am reporting a KASAN slab use-after-free in dm-integrity involving the
> reboot notifier registration path.
>
> Summary
> =======
>
> A late do_resume() can register ic->reboot_notifier on a dm_integrity_c
> object that a concurrent DM_DEV_REMOVE path is destroying. The removal path
> unregisters the old notifier via dm_integrity_postsuspend() and later frees
> ic in dm_integrity_dtr(), but does not unregister the notifier that the
> racing resume just installed. The global reboot notifier chain is then left
> with a dangling node; a later notifier_chain_register() walk touches it and
> panics under KASAN.
Hi
Does this patch fix it?
Mikulas
dm: fix resume-vs-remove race
If the user issues the resume ioctl and the remove ioctl at the same
time, it may be possible that the device is resumed after it is suspended
in __dm_destroy. The result is that the table is destroyed without
calling the postsuspend method.
Dm targets expect that they may be removed only after the postsuspend
method method was called. If we break this expectation, it can cause
misbehavior in various targets. For example - in the dm-integrity target,
the reboot notifier is not unregistered, leading to use-after-free.
Fix this bug by refusing to resume if the device is being destroyed.
Signed-off-by: Mikulas Patocka <[email protected]>
Cc: [email protected]
---
drivers/md/dm.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6/drivers/md/dm.c
===================================================================
--- linux-2.6.orig/drivers/md/dm.c 2026-07-13 20:58:56.000000000 +0200
+++ linux-2.6/drivers/md/dm.c 2026-07-22 17:40:29.000000000 +0200
@@ -3140,7 +3140,7 @@ retry:
r = -EINVAL;
mutex_lock_nested(&md->suspend_lock, SINGLE_DEPTH_NESTING);
- if (!dm_suspended_md(md))
+ if (!dm_suspended_md(md) || test_bit(DMF_FREEING, &md->flags))
goto out;
if (dm_suspended_internally_md(md)) {