[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180901024936.GA27277@thunk.org>
Date: Fri, 31 Aug 2018 22:49:36 -0400
From: "Theodore Y. Ts'o" <tytso@....edu>
To: Andreas Dilger <adilger@...ger.ca>
Cc: Ext4 Developers List <linux-ext4@...r.kernel.org>,
stable@...r.kernel.org
Subject: Re: [PATCH] ext4: avoid arithemetic overflow that can trigger a BUG
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
Powered by blists - more mailing lists