Re: [PATCH] ext4: avoid arithemetic overflow that can trigger a BUG

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 31, 2018 at 01:31:05PM -0600, Andreas Dilger wrote:
> > 	map.m_lblk = first_block;
> > -	map.m_len = last_block - first_block + 1;
> > +	len = last_block - first_block + 1;
> > +	map.m_len = (len < UINT_MAX) ? len : UINT_MAX;
> 
> Wouldn't "(len < UINT_MAX)" always be true on a 32-bit system, or is there some
> other limitation in that case (e.g. filesystem < 16TB) that prevents it from
> being an issue?  Otherwise, this should use "unsigned long long len".

first_block and last_block are both 32-bit values and defined as
unsigned long.  That's because they are logical block numbers and
should never be more than 2**32.  The fact that last_block had
overflowed was due to i_size being corrupted to being an insanely
large number.

So it's fine that len is an unsigned long, since first_block and
last_block are both unsigned long.

					- Ted



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux