From: Maria <maria.khaydich@tarantool.org>
To: tarantool-patches@dev.tarantool.org, georgy@tarantool.org
Subject: [Tarantool-patches] [PATCH] Memtx_tuple_delete used heap after free
Date: Sat, 30 Nov 2019 00:39:05 +0300 [thread overview]
Message-ID: <20191129213905.36097-1-maria.khaydich@tarantool.org> (raw)
Struct of type tuple_format is being passed as
an argument to tuple_format_unref where it might
be freed. On such occasion any further references
to format fields should not take place.
Closes #4658
---
Issue:
https://github.com/tarantool/tarantool/issues/4658
Branch:
https://github.com/tarantool/tarantool/compare/eljashm/gh-4658-heap-use-after-free
src/box/memtx_engine.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/box/memtx_engine.c b/src/box/memtx_engine.c
index 23ccc4703..bdce4ac32 100644
--- a/src/box/memtx_engine.c
+++ b/src/box/memtx_engine.c
@@ -1177,13 +1177,13 @@ memtx_tuple_delete(struct tuple_format *format, struct tuple *tuple)
struct memtx_engine *memtx = (struct memtx_engine *)format->engine;
say_debug("%s(%p)", __func__, tuple);
assert(tuple->refs == 0);
+ bool is_temp = format->is_temporary;
tuple_format_unref(format);
struct memtx_tuple *memtx_tuple =
container_of(tuple, struct memtx_tuple, base);
size_t total = tuple_size(tuple) + offsetof(struct memtx_tuple, base);
if (memtx->alloc.free_mode != SMALL_DELAYED_FREE ||
- memtx_tuple->version == memtx->snapshot_version ||
- format->is_temporary)
+ memtx_tuple->version == memtx->snapshot_version || is_temp)
smfree(&memtx->alloc, memtx_tuple, total);
else
smfree_delayed(&memtx->alloc, memtx_tuple, total);
--
2.20.1 (Apple Git-117)
next reply other threads:[~2019-11-29 21:39 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-29 21:39 Maria [this message]
2019-12-06 11:29 ` Maria Khaydich
2020-01-14 17:30 ` Cyrill Gorcunov
2020-01-14 20:24 ` Nikita Pettik
2020-01-14 21:21 ` Cyrill Gorcunov
[not found] ` <20200113164548.GA2451@uranus>
2020-01-14 22:14 ` Alexander Turenko
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=20191129213905.36097-1-maria.khaydich@tarantool.org \
--to=maria.khaydich@tarantool.org \
--cc=georgy@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH] Memtx_tuple_delete used heap after free' \
/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