From: Coly Li <colyli@suse.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-bcache@vger.kernel.org, linux-block@vger.kernel.org,
Ken Raeburn <raeburn@redhat.com>,
stable@vger.kernel.org
Subject: Re: [PATCH 1/2] bcache: avoid nr_stripes overflow in bcache_device_init()
Date: Mon, 13 Jul 2020 11:34:56 +0800 [thread overview]
Message-ID: <789e0fff-5fc3-1d2a-3e7a-62a4eac4ae59@suse.de> (raw)
In-Reply-To: <010a5d09-5de8-8f1e-4ff5-3f194f899073@kernel.dk>
On 2020/7/13 04:37, Jens Axboe wrote:
> On 7/12/20 11:47 AM, Coly Li wrote:
>> For some block devices which large capacity (e.g. 8TB) but small io_opt
>> size (e.g. 8 sectors), in bcache_device_init() the stripes number calcu-
>> lated by,
>> DIV_ROUND_UP_ULL(sectors, d->stripe_size);
>> might be overflow to the unsigned int bcache_device->nr_stripes.
>>
>> This patch uses an unsigned long variable to store DIV_ROUND_UP_ULL()
>> and after the value is checked to be available in unsigned int range,
>> sets it to bache_device->nr_stripes. Then the overflow is avoided.
>
> Does that work on 32-bit, where sizeof(unsigned long) == 4?
>
I will post v2 to explicit use uint64_t. Thanks for the remind.
Coly Li
next prev parent reply other threads:[~2020-07-13 3:35 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-12 17:47 [PATCH 1/2] bcache: avoid nr_stripes overflow in bcache_device_init() Coly Li
2020-07-12 17:47 ` [PATCH 2/2] bcche: fix overflow in offset_to_stripe() Coly Li
2020-07-17 17:08 ` Sasha Levin
2020-07-12 17:49 ` [PATCH 1/2] bcache: avoid nr_stripes overflow in bcache_device_init() Coly Li
2020-07-12 20:38 ` Ken Raeburn
2020-07-13 3:35 ` Coly Li
2020-07-12 20:37 ` Jens Axboe
2020-07-13 3:34 ` Coly Li [this message]
2020-07-17 17:08 ` 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=789e0fff-5fc3-1d2a-3e7a-62a4eac4ae59@suse.de \
--to=colyli@suse.de \
--cc=axboe@kernel.dk \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=raeburn@redhat.com \
--cc=stable@vger.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;
as well as URLs for NNTP newsgroup(s).