From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 2B92A43D679 for ; Thu, 31 Oct 2019 02:52:16 +0300 (MSK) From: Vladislav Shpilevoy Date: Thu, 31 Oct 2019 00:57:49 +0100 Message-Id: <8c4b56ae46535fd048cae9b0081ccd47eaf8ab4f.1572479749.git.v.shpilevoy@tarantool.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 1/1] access: fix use-after-free of struct credentials List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tarantool-patches@dev.tarantool.org Func_delete() called credentials_destroy() after func->vtab->destroy(). But appeared, that vtab->destroy() is actually delete, and it frees the func object. Now the func's owner credentials are destroyed before the function is freed. Closes #4597 Follow up #2763 --- Branch: https://github.com/tarantool/tarantool/tree/gerold103/gh-4597-credentials-follow-up Issue: https://github.com/tarantool/tarantool/issues/4597 src/box/func.c | 3 ++- src/box/lua/call.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/box/func.c b/src/box/func.c index c94ca4974..7ac92bc84 100644 --- a/src/box/func.c +++ b/src/box/func.c @@ -463,6 +463,7 @@ func_c_destroy(struct func *base) assert(base != NULL && base->def->language == FUNC_LANGUAGE_C); struct func_c *func = (struct func_c *) base; func_c_unload(func); + TRASH(base); free(func); } @@ -548,8 +549,8 @@ void func_delete(struct func *func) { struct func_def *def = func->def; - func->vtab->destroy(func); credentials_destroy(&func->owner_credentials); + func->vtab->destroy(func); free(def); } diff --git a/src/box/lua/call.c b/src/box/lua/call.c index 00322f6c8..f1bbde7f0 100644 --- a/src/box/lua/call.c +++ b/src/box/lua/call.c @@ -734,6 +734,7 @@ func_lua_destroy(struct func *func) { assert(func != NULL && func->def->language == FUNC_LANGUAGE_LUA); assert(func->vtab == &func_lua_vtab); + TRASH(func); free(func); } -- 2.21.0 (Apple Git-122)