mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Brian Norris <computersforpeace@gmail.com>
To: Peng Fan <van.freenix@gmail.com>
Cc: dwmw2@infradead.org, linux-mtd@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtd: blktrans: fix integer overflow
Date: Wed, 9 Sep 2015 16:37:18 -0700	[thread overview]
Message-ID: <20150909233718.GA11487@google.com> (raw)
In-Reply-To: <20150905134224.GB17774@linux-4gyl.site>

On Sat, Sep 05, 2015 at 09:42:27PM +0800, Peng Fan wrote:
> On Wed, Sep 02, 2015 at 10:02:49AM -0700, Brian Norris wrote:
> > One possibility, since you only point to a single computation that
> > overflows, is to just fix the overflow locally. It's not like the 'size'
> > (which represents number of sectors) is actually ever overflowing a
> > 32-bit integer. It's just the multiplication that overflows. So you
> > could cast to 64-bit arithmetic just for the multiplication. e.g.:
> > 
> > 	set_capcity(gd, ((u64)new->size * tr->blksize) >> 9);
> 
> Yeah. It is the multiplication overflowing a 32-bit interger. My frist
> implementation is this way, using u64 to do type cast. But I guess one
> day the number of sectors can be larger than UINT_MAX, so I change it
> to 'unsigned long long' from 'unsigned long', which is
> not the right way, thanks for correcting me.
> > 
> > Or some other creative solution.
> 
> I think this should be a bug fix. If you need a quick fix, I can send
> out the simple patch that just do (u64) cast. If not, I can take some
> time to "fix all the blktrans users".

I think since you've identified (and tested) a fix, we might as well
include it. So I suppose the cast approach. The larger change would be
more invasive and may take a while.

> > 
> > Then, we don't have to address this problem till we start seeing 2TB
> > MTDs!

Brian

      reply	other threads:[~2015-09-09 23:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-21 14:57 Peng Fan
2015-09-02 17:02 ` Brian Norris
2015-09-05 13:42   ` Peng Fan
2015-09-09 23:37     ` Brian Norris [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=20150909233718.GA11487@google.com \
    --to=computersforpeace@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=van.freenix@gmail.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

Powered by JetHome