Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: tarantool-patches@freelists.org
Subject: Re: [PATCH] box: fix use-after-free in space_truncate
Date: Sun, 7 Apr 2019 14:38:14 +0300	[thread overview]
Message-ID: <20190407113814.t53poaevxqilwvve@esperanza> (raw)
In-Reply-To: <b76542c42b82c08f651f24b41e15803f29556a2d.1554635717.git.vdavydov.dev@gmail.com>

On Sun, Apr 07, 2019 at 02:24:30PM +0300, Vladimir Davydov wrote:
> space_truncate allocates a statement on the stack which is grossly
> incorrect as the stack may be purged once the function returns while
> box_process_rw expects the statement to be valid until the end of
> the transaction. By happy accident, it worked fine until commit
> 1f7b0d6577f4 ("Require for single statement not autocommit in case of
> ddl"), which made it possible to run this function from a transaction
> and hence increased the probability of hitting the use-after-free bug.
> The fix is trivial: allocate a truncation statement on the region.
> 
> Fixes commit 353bcdc5d010 ("Rework space truncation").
> 
> Closes #4093
> ---
> https://github.com/tarantool/tarantool/issues/4093
> https://github.com/tarantool/tarantool/commits/dv/fix-use-after-free-in-space-truncate
> 
>  src/box/box.cc | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)

This one is pretty obvious. Pushed to master and resurrected the
box/transaction test case that triggered the use-after-free bug.

Since the bus was there for two years and we were just lucky not to step
on it, I also cherry-picked this commit to 2.1 and 1.10.

      reply	other threads:[~2019-04-07 11:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-07 11:24 Vladimir Davydov
2019-04-07 11:38 ` Vladimir Davydov [this message]

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=20190407113814.t53poaevxqilwvve@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH] box: fix use-after-free in space_truncate' \
    /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