mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Zhong Jinghua <zhongjinghua@huaweicloud.com>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org, zhongjinghua@huawei.com,
	yi.zhang@huawei.com, yukuai3@huawei.com, chengzhihao1@huawei.com,
	yangerkun@huawei.com
Subject: Re: [PATCH -next] block: Fix the partition start may overflow in add_partition()
Date: Thu, 25 May 2023 01:55:28 -0700	[thread overview]
Message-ID: <ZG8igEyXrFa4j/gf@infradead.org> (raw)
In-Reply-To: <20230522070615.1485014-1-zhongjinghua@huaweicloud.com>

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?


  parent reply	other threads:[~2023-05-25  8:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-22  7:06 Zhong Jinghua
2023-05-25  2:14 ` Yu Kuai
2023-05-25  2:27   ` Yu Kuai
2023-05-25  8:55 ` Christoph Hellwig [this message]
2023-05-25 13:20   ` zhongjinghua
2023-05-25 14:12   ` zhongjinghua

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=ZG8igEyXrFa4j/gf@infradead.org \
    --to=hch@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=chengzhihao1@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yangerkun@huawei.com \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.com \
    --cc=zhongjinghua@huawei.com \
    --cc=zhongjinghua@huaweicloud.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®