From: Pavel Machek <pavel@denx.de>
To: Sasha Levin <sashal@kernel.org>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Zhang Shurong <zhang_shurong@foxmail.com>,
Yu Kuai <yukuai3@huawei.com>, Song Liu <song@kernel.org>,
linux-raid@vger.kernel.org
Subject: Re: [PATCH AUTOSEL 4.14 2/3] md: raid1: fix potential OOB in raid1_remove_disk()
Date: Mon, 11 Sep 2023 11:49:49 +0200 [thread overview]
Message-ID: <ZP7ivTQR0bjM6WU/@duo.ucw.cz> (raw)
In-Reply-To: <20230908193656.3464052-2-sashal@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 1257 bytes --]
Hi!
> From: Zhang Shurong <zhang_shurong@foxmail.com>
>
> [ Upstream commit 8b0472b50bcf0f19a5119b00a53b63579c8e1e4d ]
>
> If rddev->raid_disk is greater than mddev->raid_disks, there will be
> an out-of-bounds in raid1_remove_disk(). We have already found
> similar reports as follows:
>
> 1) commit d17f744e883b ("md-raid10: fix KASAN warning")
> 2) commit 1ebc2cec0b7d ("dm raid: fix KASAN warning in raid5_remove_disk")
>
> Fix this bug by checking whether the "number" variable is
> valid.
> +++ b/drivers/md/raid1.c
> @@ -1775,6 +1775,10 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
> struct r1conf *conf = mddev->private;
> int err = 0;
> int number = rdev->raid_disk;
> +
> + if (unlikely(number >= conf->raid_disks))
> + goto abort;
> +
> struct raid1_info *p = conf->mirrors + number;
>
> if (rdev != p->rdev)
Wow. Mixing declarations and code. I'm pretty sure that's not ok
according to our coding style, and I'd be actually surprised if all
our compiler configurations allowed this.
Best regards,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Erika Unter
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2023-09-11 22:11 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-08 19:36 [PATCH AUTOSEL 4.14 1/3] drm/exynos: fix a possible null-pointer dereference due to data race in exynos_drm_crtc_atomic_disable() Sasha Levin
2023-09-08 19:36 ` [PATCH AUTOSEL 4.14 2/3] md: raid1: fix potential OOB in raid1_remove_disk() Sasha Levin
2023-09-11 9:49 ` Pavel Machek [this message]
2023-09-11 21:43 ` Song Liu
2023-09-08 19:36 ` [PATCH AUTOSEL 4.14 3/3] ext2: fix datatype of block number in ext2_xattr_set2() Sasha Levin
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=ZP7ivTQR0bjM6WU/@duo.ucw.cz \
--to=pavel@denx.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-raid@vger.kernel.org \
--cc=sashal@kernel.org \
--cc=song@kernel.org \
--cc=stable@vger.kernel.org \
--cc=yukuai3@huawei.com \
--cc=zhang_shurong@foxmail.com \
/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®