[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9e3302ac-7e1e-0925-3da1-7c9070c51a3c@huawei.com>
Date: Thu, 25 May 2023 21:20:07 +0800
From: zhongjinghua <zhongjinghua@...wei.com>
To: Christoph Hellwig <hch@...radead.org>,
Zhong Jinghua <zhongjinghua@...weicloud.com>
CC: <axboe@...nel.dk>, <linux-block@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <yi.zhang@...wei.com>,
<yukuai3@...wei.com>, <chengzhihao1@...wei.com>,
<yangerkun@...wei.com>
Subject: Re: [PATCH -next] block: Fix the partition start may overflow in
add_partition()
在 2023/5/25 16:55, Christoph Hellwig 写道:
> On Mon, May 22, 2023 at 03:06:15PM +0800, Zhong Jinghua wrote:
>> + if (p.start < 0 || p.length <= 0 || p.start + p.length < 0)
>> + return -EINVAL;
>> +
>> start = p.start >> SECTOR_SHIFT;
>> length = p.length >> SECTOR_SHIFT;
>>
>> + /* length may be equal to 0 after right shift */
>> + if (!length || start + length > get_capacity(bdev->bd_disk))
>> + return -EINVAL;
> While we're at it, shouldn't these be switched to use
> check_add_overflow?
p.start + p.length < 0 can use check_add_overflow instead.
Powered by blists - more mailing lists