mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Li Nan <linan666@huaweicloud.com>
To: Song Liu <song@kernel.org>, linan666@huaweicloud.com
Cc: neilb@suse.de, linux-raid@vger.kernel.org,
	linux-kernel@vger.kernel.org, yukuai3@huawei.com,
	yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com
Subject: Re: [PATCH v2 1/4] md/raid10: fix slab-out-of-bounds in md_bitmap_get_counter
Date: Sun, 14 May 2023 19:15:43 +0800	[thread overview]
Message-ID: <863a4b6e-ff85-2d82-cf8b-bec87e0f5468@huaweicloud.com> (raw)
In-Reply-To: <CAPhsuW7p=xw41EZ-f+UHMO+o5bLFGirORPE-gfnkYqfpjv-rzw@mail.gmail.com>



在 2023/5/13 9:05, Song Liu 写道:
> On Fri, May 5, 2023 at 6:24 PM <linan666@huaweicloud.com> wrote:
>>
>> From: Li Nan <linan122@huawei.com>
>>
>> If we write a large number to md/bitmap_set_bits, md_bitmap_checkpage()
>> will return -EINVAL because "page >= bitmap->pages", but the return value
>> was not checked immediately in md_bitmap_get_counter() in order to set
>> *blocks value and slab-out-of-bounds occurs.
>>
>> Return directly if err is -EINVAL.
>>
>> Fixes: ef4256733506 ("md/bitmap: optimise scanning of empty bitmaps.")
>> Signed-off-by: Li Nan <linan122@huawei.com>
>> Reviewed-by: Yu Kuai <yukuai3@huawei.com>
>> ---
>>   drivers/md/md-bitmap.c | 2 ++
>>   1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c
>> index 920bb68156d2..0b41ef422da7 100644
>> --- a/drivers/md/md-bitmap.c
>> +++ b/drivers/md/md-bitmap.c
>> @@ -1388,6 +1388,8 @@ __acquires(bitmap->lock)
>>          int err;
>>
>>          err = md_bitmap_checkpage(bitmap, page, create, 0);
>> +       if (err == -EINVAL)
>> +               return NULL;
> 
> This logic is error prone. Since we are on it, let's fix it better.
> Specifically, we can move "page >= bitmap->pages" check out

I will check out it in v3.

> of md_bitmap_checkpage(). (and fix the call site in md_bitmap_resize
> for clustered md).
> 

In md_bitmap_resize(), incoming parameters "page < bitmap->counts.page" 
and do not have this problem.


> Also, could you please add a mdadm test for this issue?
> 

It's my pleasure.

> Thanks,
> Song
> 
>>
>>          if (bitmap->bp[page].hijacked ||
>>              bitmap->bp[page].map == NULL)
>> --
>> 2.31.1
>>
> .

Thanks for your suggesion.

-- 
Thanks,
Nan


  reply	other threads:[~2023-05-14 11:15 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-06  1:23 [PATCH v2 0/4] md: bugfix of writing raid sysfs linan666
2023-05-06  1:23 ` [PATCH v2 1/4] md/raid10: fix slab-out-of-bounds in md_bitmap_get_counter linan666
2023-05-13  1:05   ` Song Liu
2023-05-14 11:15     ` Li Nan [this message]
2023-05-06  1:23 ` [PATCH v2 2/4] md/raid10: fix overflow in safe_delay_store linan666
2023-05-06  2:00   ` Yu Kuai
2023-05-14 11:18     ` Li Nan
2023-05-06  1:23 ` [PATCH v2 3/4] md/raid10: fix wrong setting of max_corr_read_errors linan666
2023-05-06  2:02   ` Yu Kuai
2023-05-13  1:08     ` Song Liu
2023-05-13  2:21       ` Yu Kuai
2023-05-14 11:08         ` Li Nan
2023-05-06  1:23 ` [PATCH v2 4/4] md/raid10: optimize check_decay_read_errors() linan666
2023-05-06  2:14   ` 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=863a4b6e-ff85-2d82-cf8b-bec87e0f5468@huaweicloud.com \
    --to=linan666@huaweicloud.com \
    --cc=houtao1@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=song@kernel.org \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.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®