From: "yu kuai" <yukuai@fygo.io>
To: "Edward Adam Davis" <eadavis@sina.com>,
<syzbot+08318698e045b4b85f51@syzkaller.appspotmail.com>,
"yu kuai" <yukuai@fygo.io>
Cc: <linux-kernel@vger.kernel.org>, <peterz@infradead.org>,
<syzkaller-bugs@googlegroups.com>, <tglx@kernel.org>,
<bigeasy@linutronix.de>, <song@kernel.org>,
<magiclinan@didiglobal.com>, <xiao@kernel.org>,
<linux-raid@vger.kernel.org>
Subject: Re: [PATCH] md/raid5: Cancel remove instance if adding it fails
Date: Tue, 3 Nov 2026 11:00:33 +0800 [thread overview]
Message-ID: <a8734f2f-dd23-4133-ae9e-fd95b90039a2@fygo.io> (raw)
In-Reply-To: <20261030105614.378971-1-eadavis@sina.com>
Hi,
在 2026/10/30 18:56, Edward Adam Davis 写道:
> The failure of raid456_cpu_up_prepare() to allocate memory causes
> cpuhp_state_add_instance() to fail; consequently, the corresponding
> instance is not initialized, potentially hitting [1].
>
> Additionally, there is another null-ptr-deref issue: conf->mddev is
> assigned too late, meaning that any error-handling exit occurring before
> this assignment, which jumps to the abort label, potentially hitting [2].
>
> [1]
> KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
> Call Trace:
> cpuhp_state_remove_instance include/linux/cpuhotplug.h:480 [inline]
> raid5_free_percpu drivers/md/raid5.c:7541 [inline]
> free_conf+0x238/0x710 drivers/md/raid5.c:7554
> setup_conf+0xd80/0x2a20 drivers/md/raid5.c:7885
> raid5_run+0x1260/0x1670 drivers/md/raid5.c:8129
>
> [2]
> BUG: KASAN: null-ptr-deref in free_conf+0xfd/0x7e0
> Read of size 8 at addr 0000000000000028 by task rp0/9459
> Call Trace:
> free_conf+0xfd/0x7e0
> setup_conf.cold+0x6e/0x4a1
> raid5_run+0x1260/0x1670
>
> Add a check before removing an instance, if the instance was not successfully
> added, skip the removal process. Move the assignment of conf->mddev after the
> memory allocation for conf.
>
> Fixes: 29c6d1bbd7a2 ("md/raid5: Convert to hotplug state machine")
> Reported-by: syzbot+08318698e045b4b85f51@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=08318698e045b4b85f51
> Signed-off-by: Edward Adam Davis <eadavis@sina.com>
> ---
> drivers/md/raid5.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Looks like this problem is already fixed
https://patch.msgid.link/20260827080341.112296-2-ghuicao@163.com
https://patch.msgid.link/20260915081731.122933-1-chengzhihao1@huawei.com
>
> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> index b91545ce090d..e1f9ec8f25be 100644
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c
> @@ -7538,7 +7538,8 @@ static void raid5_free_percpu(struct r5conf *conf)
> if (!conf->percpu)
> return;
>
> - cpuhp_state_remove_instance(CPUHP_MD_RAID5_PREPARE, &conf->node);
> + if (!hlist_unhashed(&conf->node))
> + cpuhp_state_remove_instance(CPUHP_MD_RAID5_PREPARE, &conf->node);
> free_percpu(conf->percpu);
> }
>
> @@ -7675,6 +7676,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
> if (conf == NULL)
> goto abort;
>
> + conf->mddev = mddev;
> #if PAGE_SIZE != DEFAULT_STRIPE_SIZE
> conf->stripe_size = DEFAULT_STRIPE_SIZE;
> conf->stripe_shift = ilog2(DEFAULT_STRIPE_SIZE) - 9;
> @@ -7743,7 +7745,6 @@ static struct r5conf *setup_conf(struct mddev *mddev)
> ret = bioset_init(&conf->bio_split, BIO_POOL_SIZE, 0, 0);
> if (ret)
> goto abort;
> - conf->mddev = mddev;
>
> ret = -ENOMEM;
> conf->stripe_hashtbl = kzalloc(PAGE_SIZE, GFP_KERNEL);
--
Thanks,
Kuai
prev parent reply other threads:[~2026-11-03 3:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-29 13:38 [syzbot] [kernel?] general protection fault in __cpuhp_state_remove_instance syzbot
2026-10-30 10:56 ` [PATCH] md/raid5: Cancel remove instance if adding it fails Edward Adam Davis
2026-11-03 3:00 ` yu kuai [this message]
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=a8734f2f-dd23-4133-ae9e-fd95b90039a2@fygo.io \
--to=yukuai@fygo.io \
--cc=bigeasy@linutronix.de \
--cc=eadavis@sina.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=magiclinan@didiglobal.com \
--cc=peterz@infradead.org \
--cc=song@kernel.org \
--cc=syzbot+08318698e045b4b85f51@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tglx@kernel.org \
--cc=xiao@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®