From: Logan Gunthorpe <logang@deltatee.com>
To: Yogesh Gaur <yogeshgaur.83@gmail.com>, Song Liu <song@kernel.org>,
Yu Kuai <yukuai@fygo.io>
Cc: linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org,
Li Nan <magiclinan@didiglobal.com>, Xiao Ni <xiao@kernel.org>,
Christoph Hellwig <hch@lst.de>, Hannes Reinecke <hare@suse.de>,
syzbot+270624bb31d478afe62e@syzkaller.appspotmail.com,
stable@vger.kernel.org
Subject: Re: [PATCH] md/raid5: set conf->mddev before the first setup_conf() error path
Date: Mon, 5 Oct 2026 09:53:48 -0600 [thread overview]
Message-ID: <1005631a-5234-4a3a-9edd-a4ec299c168a@deltatee.com> (raw)
In-Reply-To: <20261004060203.1379-1-yogeshgaur.83@gmail.com>
On 2026-10-04 00:02, Yogesh Gaur wrote:
> free_conf() starts with log_exit(), which falls through to
> raid5_has_ppl() when conf->log is NULL:
>
> static inline void log_exit(struct r5conf *conf)
> {
> if (conf->log)
> r5l_exit_log(conf);
> else if (raid5_has_ppl(conf))
> ppl_exit_log(conf);
> }
>
> raid5_has_ppl() reads conf->mddev->flags. setup_conf() only assigns
> conf->mddev after bioset_init(), but five of its error paths -- the
> pending_data, alloc_thread_groups(), conf->disks, extra_page and
> bioset_init() failures -- jump to "abort:" before that, and abort: calls
> free_conf(). conf comes from kzalloc, so conf->mddev is still NULL and
> free_conf() dereferences it:
>
> BUG: KASAN: null-ptr-deref in raid5_has_ppl drivers/md/raid5-log.h:54 [inline]
> BUG: KASAN: null-ptr-deref in log_exit drivers/md/raid5-log.h:128 [inline]
> BUG: KASAN: null-ptr-deref in free_conf+0x81/0x5d0 drivers/md/raid5.c:7549
> Read of size 8 at addr 0000000000000028 by task syz.3.20/5681
> Call Trace:
> <TASK>
> free_conf+0x81/0x5d0 drivers/md/raid5.c:7549
> setup_conf+0x1720/0x2ad0 drivers/md/raid5.c:7885
> raid5_run+0x8cc/0x2560 drivers/md/raid5.c:8129
> md_run+0xc3d/0x1cd0 drivers/md/md.c:6779
> do_md_run+0x35/0x720 drivers/md/md.c:6880
> array_state_store+0x958/0xe90 drivers/md/md.c:-1
> </TASK>
>
> The faulting address is offsetof(struct mddev, flags).
>
> conf->mddev is a back pointer that is constant for the lifetime of the
> conf and does not depend on anything computed in between, so assign it
> as soon as the conf is allocated. Nothing between the allocation and the
> old assignment reads conf->mddev -- alloc_thread_groups() takes the conf
> but never looks at its mddev, and the rdev_for_each() loop walks the
> mddev argument directly.
>
> All five paths are allocation failures, so this needs memory pressure or
> fault injection to hit, which is how syzbot found it.
>
> Reported-by: syzbot+270624bb31d478afe62e@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=270624bb31d478afe62e
> Fixes: ff875738edd4 ("raid5: separate header for log functions")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Yogesh Gaur <yogeshgaur.83@gmail.com>
Looks good to me, thanks!
Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
Logan
next prev parent reply other threads:[~2026-10-05 15:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-04 6:02 Yogesh Gaur
2026-10-05 15:53 ` Logan Gunthorpe [this message]
2026-10-05 17:02 ` yu kuai
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=1005631a-5234-4a3a-9edd-a4ec299c168a@deltatee.com \
--to=logang@deltatee.com \
--cc=hare@suse.de \
--cc=hch@lst.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=magiclinan@didiglobal.com \
--cc=song@kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+270624bb31d478afe62e@syzkaller.appspotmail.com \
--cc=xiao@kernel.org \
--cc=yogeshgaur.83@gmail.com \
--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®