From: Andreas Dilger <adilger@dilger.ca>
To: Theodore Ts'o <tytso@mit.edu>
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 13:31:05 -0600 [thread overview]
Message-ID: <A4D64426-1092-4652-9A8C-EBFD5B7655A7@dilger.ca> (raw)
In-Reply-To: <20180831174126.13071-1-tytso@mit.edu>
[-- Attachment #1: Type: text/plain, Size: 1481 bytes --]
On Aug 31, 2018, at 11:41 AM, Theodore Ts'o <tytso@mit.edu> wrote:
>
> A maliciously crafted file system can cause an overflow when the
> results of a 64-bit calculation is stored into a 32-bit length
> parameter.
>
> https://bugzilla.kernel.org/show_bug.cgi?id=200623
>
> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
> Reported-by: Wen Xu <wen.xu@gatech.edu>
> Cc: stable@vger.kernel.org
> ---
> fs/ext4/inode.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 8f6ad7667974..1134c3473673 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -3414,6 +3414,7 @@ static int ext4_iomap_begin(struct inode *inode,
> unsigned int blkbits = inode->i_blkbits;
> unsigned long first_block = offset >> blkbits;
> unsigned long last_block = (offset + length - 1) >> blkbits;
> + unsigned long len;
> struct ext4_map_blocks map;
> bool delalloc = false;
> int ret;
> @@ -3434,7 +3435,8 @@ static int ext4_iomap_begin(struct inode *inode,
> }
>
> 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".
Cheers, Andreas
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]
next prev parent reply other threads:[~2018-08-31 19:31 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 [this message]
2018-09-01 2:49 ` Theodore Y. Ts'o
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=A4D64426-1092-4652-9A8C-EBFD5B7655A7@dilger.ca \
--to=adilger@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tytso@mit.edu \
/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).