lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAPhsuW5HjcV1UM_XcRrgj8EHj2CJe9YvFga=YJoB3Q+2N=DO8w@mail.gmail.com>
Date:   Sun, 13 Aug 2023 20:13:59 +0400
From:   Song Liu <song@...nel.org>
To:     Yu Kuai <yukuai1@...weicloud.com>
Cc:     Zhang Shurong <zhang_shurong@...mail.com>,
        linux-raid@...r.kernel.org, linux-kernel@...r.kernel.org,
        "yukuai (C)" <yukuai3@...wei.com>
Subject: Re: [PATCH v2] md: raid1: fix potential OOB in raid1_remove_disk()

On Mon, Jul 31, 2023 at 5:08 AM Yu Kuai <yukuai1@...weicloud.com> wrote:
>
> Hi,
>
> 在 2023/07/29 18:49, Song Liu 写道:
> > On Mon, Jul 24, 2023 at 10:12 AM Yu Kuai <yukuai1@...weicloud.com> wrote:
> >>
> >> 在 2023/07/22 15:53, Zhang Shurong 写道:
> >>> 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.
> >>
> >> LGTM
> >>
> >> Reviewed-by: Yu Kuai <yukuai3@...wei.com>
> >>>
> >>> Signed-off-by: Zhang Shurong <zhang_shurong@...mail.com>
> >>> ---
> >>> Changes in v2:
> >>>    - Using conf->raid_disks instead of mddev->raid_disks.
> >>>
> >>>    drivers/md/raid1.c | 4 ++++
> >>>    1 file changed, 4 insertions(+)
> >>>
> >>> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> >>> index dd25832eb045..80aeee63dfb7 100644
> >>> --- a/drivers/md/raid1.c
> >>> +++ b/drivers/md/raid1.c
> >>> @@ -1829,6 +1829,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;
> >
> > We need err = -EINVAL here.
>
> I think return 0 is right here, so that caller can remove this rdev
> from array successfully, this only need to return error for the case
> -EBUSY.

Ah, that's right. Applied to md-next.

Thanks,
Song

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ