Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1221792

Re: [PATCH] mtd: blktrans: fix integer overflow

From Brian Norris <computersforpeace@gmail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] mtd: blktrans: fix integer overflow
Date 2015-09-10 01:40 +0200
Message-ID <q6X85-12V-1@gated-at.bofh.it> (permalink)
References <pZVXs-6N0-23@gated-at.bofh.it> <q4jHQ-2S4-25@gated-at.bofh.it> <q5m0W-25G-35@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH] mtd: blktrans: fix integer overflow Brian Norris <computersforpeace@gmail.com> - 2015-09-10 01:40 +0200

csiph-web