From f36086db87aae24c10abde434f081d78b942735e Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Tue, 25 Jun 2019 18:00:06 +0200 Subject: glusterd: fix use-after-free of a dict_t A dict was passed to a function that calls dict_unref() without taking any additional reference. Given that the same dict is also used after the function returns, this was causing a use-after-free situation. To fix the issue, we simply take an additional reference before calling the function. Fixes: bz#1723890 Change-Id: I98c6b76b08fe3fa6224edf281a26e9ba1ffe3017 Signed-off-by: Xavi Hernandez --- xlators/mgmt/glusterd/src/glusterd-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index b004b2e42d6..80fb82938e5 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -3452,7 +3452,7 @@ glusterd_add_volumes_to_export_dict(dict_t *peer_data, char **buf, if (totthread) { gf_log(this->name, GF_LOG_INFO, "Finished merger of all dictionraies into single one"); - dict_arr[totthread++] = peer_data; + dict_arr[totthread++] = dict_ref(peer_data); ret = glusterd_dict_arr_serialize(dict_arr, totthread, buf, length); gf_log(this->name, GF_LOG_INFO, "Serialize dictionary data return is %d", ret); -- cgit