From: Mikulas Patocka <mpatocka@redhat.com>
To: Junzhe Yu <junzheyu1@gmail.com>
Cc: snitzer@kernel.org, bmarzins@redhat.com, agk@redhat.com,
dm-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [BUG] dm-integrity: dangling reboot notifier after resume vs remove race
Date: Wed, 22 Jul 2026 18:14:03 +0200 (CEST) [thread overview]
Message-ID: <0ce40d40-1a42-7ee8-2fbd-6e1e8f9ce4b9@redhat.com> (raw)
In-Reply-To: <2582d759-1e99-4a31-9a1b-5eccf0af3891@gmail.com>
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 <mpatocka@redhat.com>
Cc: stable@vger.kernel.org
---
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)) {
next prev parent reply other threads:[~2026-07-22 16:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-18 13:32 Junzhe Yu
2026-07-22 16:14 ` Mikulas Patocka [this message]
2026-07-23 1:19 ` Junzhe Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0ce40d40-1a42-7ee8-2fbd-6e1e8f9ce4b9@redhat.com \
--to=mpatocka@redhat.com \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dm-devel@lists.linux.dev \
--cc=junzheyu1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=snitzer@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®