All of lore.kernel.org
 help / color / mirror / Atom feed
From: Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
To: Tejun Heo <tj@kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@osdl.org>, Jens Axboe <axboe@kernel.dk>,
	Kiyoshi Ueda <k-ueda@ct.jp.nec.com>,
	Lin Ming <ming.m.lin@intel.com>, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH] block:Remove extra condition in end of disk check
Date: Tue, 25 Jun 2013 10:40:14 +0530	[thread overview]
Message-ID: <51C92636.2060006@linux.vnet.ibm.com> (raw)
In-Reply-To: <20130624225126.GO1918@mtj.dyndns.org>

On 06/25/2013 04:21 AM, Tejun Heo wrote:
> On Mon, Jun 24, 2013 at 07:20:12PM +0530, Raghavendra K T wrote:
>>> @@ -1656,7 +1656,7 @@ static inline int bio_check_eod(struct bio *bio, unsigned int nr_sectors)
>>>   	if (maxsector) {
>>>   		sector_t sector = bio->bi_sector;
>>>
>>> -		if (maxsector < nr_sectors || maxsector - nr_sectors < sector) {
>>> +		if (maxsector - nr_sectors < sector) {
>
> If maxsector < nr_sectors, the subtraction will underflow making it a
> very large number and fail to detect the invalid condition, no?
>

Hi Tejun,
Thanks for the reply and explanation. You are right. underflow results
in invalid condition.

Considering maxsector and sectors are unsigned long, and nr_sector is
unsigned int, probably safer bet is
(max_sector < sector + nr_sector), but still it would leave scope for 
overflow.

Thanks again,
Raghu.


      reply	other threads:[~2013-06-25  5:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-23 17:17 [PATCH] block:Remove extra condition in end of disk check Raghavendra K T
2013-06-24 13:50 ` Raghavendra K T
2013-06-24 22:51   ` Tejun Heo
2013-06-25  5:10     ` Raghavendra K T [this message]

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=51C92636.2060006@linux.vnet.ibm.com \
    --to=raghavendra.kt@linux.vnet.ibm.com \
    --cc=akpm@osdl.org \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=k-ueda@ct.jp.nec.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ming.m.lin@intel.com \
    --cc=tj@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.