From: Mikulas Patocka <mpatocka@redhat.com>
To: Li Youhong <dayou5941@163.com>
Cc: agk@redhat.com, snitzer@kernel.org, bmarzins@redhat.com,
yukuai@fygo.io, dm-devel@lists.linux.dev,
linux-kernel@vger.kernel.org, Li Youhong <liyouhong@kylinos.cn>,
stable@vger.kernel.org
Subject: Re: [PATCH] dm-raid: fix use-after-free in raid_dtr()
Date: Thu, 12 Nov 2026 21:35:50 +0100 (CET) [thread overview]
Message-ID: <2f7691db-0f26-bc0a-886e-2f97c2805bde@redhat.com> (raw)
In-Reply-To: <20261112091206.1656622-1-dayou5941@163.com>
OK. I applied the patch, thanks.
Mikulas
On Thu, 12 Nov 2026, Li Youhong wrote:
> From: Li Youhong <liyouhong@kylinos.cn>
>
> raid_dtr() currently flushes event_work only if work_pending() is true.
> This is insufficient because once a worker has dequeued the work, the
> PENDING bit is cleared while do_table_event() is still running. In that
> window raid_set_free() can free the raid_set, leading to a
> use-after-free when do_table_event() accesses rs->ti->table.
>
> Flush event_work whenever it has been initialized, so raid_set is not
> freed while the event handler is still running. The .func guard skips the
> flush for mddev instances where INIT_WORK has not run yet.
>
> Fixes: db29d79b34d9 ("dm-raid: delay flushing event_work() after reconfig_mutex is released")
> Cc: stable@vger.kernel.org
> Signed-off-by: Li Youhong <liyouhong@kylinos.cn>
> ---
> v2:
> - Fix incorrect Fixes tag; the work_pending() check in raid_dtr() was
> introduced by db29d79b34d9, not a17d1bca5aba.
> - v1: https://lore.kernel.org/all/20261112075741.1449168-1-dayou5941@163.com/
>
> drivers/md/dm-raid.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/md/dm-raid.c b/drivers/md/dm-raid.c
> index ac019a0f5a92..c1f546e8c65d 100644
> --- a/drivers/md/dm-raid.c
> +++ b/drivers/md/dm-raid.c
> @@ -3340,7 +3340,7 @@ static void raid_dtr(struct dm_target *ti)
> rs->md.dm_gendisk = NULL;
> mddev_unlock(&rs->md);
>
> - if (work_pending(&rs->md.event_work))
> + if (rs->md.event_work.func)
> flush_work(&rs->md.event_work);
> raid_set_free(rs);
> }
>
> --
> 2.25.1
>
next prev parent reply other threads:[~2026-11-12 20:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-12 9:12 Li Youhong
2026-11-12 20:35 ` Mikulas Patocka [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-11-12 7:57 Li Youhong
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=2f7691db-0f26-bc0a-886e-2f97c2805bde@redhat.com \
--to=mpatocka@redhat.com \
--cc=agk@redhat.com \
--cc=bmarzins@redhat.com \
--cc=dayou5941@163.com \
--cc=dm-devel@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=liyouhong@kylinos.cn \
--cc=snitzer@kernel.org \
--cc=stable@vger.kernel.org \
--cc=yukuai@fygo.io \
/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®