From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [PATCH 1/1] iproto: protect from false-correct size in msg header
Date: Tue, 19 Jun 2018 14:57:40 +0300 [thread overview]
Message-ID: <20180619115740.ezt2aue5gccoppdv@esperanza> (raw)
In-Reply-To: <c3d064b141e17e8c5fbc4d852e61615c8b4edd4a.1529351502.git.v.shpilevoy@tarantool.org>
Looks OK to me.
On Mon, Jun 18, 2018 at 10:53:01PM +0300, Vladislav Shpilevoy wrote:
> Consider this packet:
>
> msgpack = require('msgpack')
> data = msgpack.encode(18400000000000000000)..'aaaaaaa'
>
> Tarantool interprets 18400000000000000000 as size of a coming
> iproto request, and tries with no any checks to allocate buffer
> of such size. It calculates needed capacity like this:
>
> capacity = start_value;
> while (capacity < size)
> capacity *= 2;
>
> Here it is possible that on i-th iteration 'capacity' < 'size',
> but 'capacity * 2' overflows 64 bits and becomes < 'size' again,
> so this loop never ends and occupies 100% CPU.
>
> Strictly speaking overflow has undefined behavior. On the
> original system it led to nullifying 'capacity'.
>
> Such size is improbable as a real packet gabarits, but can appear
> as a result of parsing of some invalid packet, first bytes of
> which accidentally appears to be valid MessagePack uint. This is
> how the bug emerged on the real system.
>
> Lets restrict the maximal packet size to 2GB.
>
> Closes #3464
> ---
> Branch: https://github.com/tarantool/tarantool/tree/gerold103/gh-3464-iproto-100-cpu
> Issue: https://github.com/tarantool/tarantool/issues/3464
>
> src/box/iproto.cc | 15 +++++++++++++--
> test/box/net.box.result | 22 ++++++++++++++++++++++
> test/box/net.box.test.lua | 10 ++++++++++
> 3 files changed, 45 insertions(+), 2 deletions(-)
next prev parent reply other threads:[~2018-06-19 11:57 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-18 19:53 Vladislav Shpilevoy
2018-06-19 11:57 ` Vladimir Davydov [this message]
2018-06-25 13:55 ` [tarantool-patches] " Konstantin Osipov
2018-06-25 14:00 ` [tarantool-patches] [PATCH v2 " Vladislav Shpilevoy
2018-06-25 17:17 ` [tarantool-patches] " Konstantin Osipov
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=20180619115740.ezt2aue5gccoppdv@esperanza \
--to=vdavydov.dev@gmail.com \
--cc=tarantool-patches@freelists.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [PATCH 1/1] iproto: protect from false-correct size in msg header' \
/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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox