linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Theodore Y. Ts'o" <tytso@mit.edu>
To: Andreas Dilger <adilger@dilger.ca>
Cc: Ext4 Developers List <linux-ext4@vger.kernel.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH] ext4: avoid arithemetic overflow that can trigger a BUG
Date: Fri, 31 Aug 2018 22:49:36 -0400	[thread overview]
Message-ID: <20180901024936.GA27277@thunk.org> (raw)
In-Reply-To: <A4D64426-1092-4652-9A8C-EBFD5B7655A7@dilger.ca>

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

  reply	other threads:[~2018-09-01  2:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-31 17:41 [PATCH] ext4: avoid arithemetic overflow that can trigger a BUG Theodore Ts'o
2018-08-31 19:31 ` Andreas Dilger
2018-09-01  2:49   ` Theodore Y. Ts'o [this message]
2018-08-31 19:31 ` Jiri Slaby
2018-09-01  2:50   ` Theodore Y. Ts'o
2018-09-01 16:49     ` [PATCH -v2] " Theodore Ts'o

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=20180901024936.GA27277@thunk.org \
    --to=tytso@mit.edu \
    --cc=adilger@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=stable@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).