e3c68b
From a7a7d497af4230430f8a0cc54d8b49cfea260039 Mon Sep 17 00:00:00 2001
e3c68b
From: Xavi Hernandez <xhernandez@redhat.com>
e3c68b
Date: Tue, 25 Jun 2019 18:00:06 +0200
e3c68b
Subject: [PATCH 207/221] glusterd: fix use-after-free of a dict_t
e3c68b
e3c68b
A dict was passed to a function that calls dict_unref() without taking
e3c68b
any additional reference. Given that the same dict is also used after
e3c68b
the function returns, this was causing a use-after-free situation.
e3c68b
e3c68b
To fix the issue, we simply take an additional reference before calling
e3c68b
the function.
e3c68b
e3c68b
Upstream patch:
e3c68b
> BUG: 1723890
e3c68b
> Upstream patch link: https://review.gluster.org/c/glusterfs/+/22943
e3c68b
> Change-Id: I98c6b76b08fe3fa6224edf281a26e9ba1ffe3017
e3c68b
> Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
e3c68b
e3c68b
Change-Id: I98c6b76b08fe3fa6224edf281a26e9ba1ffe3017
e3c68b
Updates: bz#1722801
e3c68b
Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
e3c68b
Reviewed-on: https://code.engineering.redhat.com/gerrit/174656
e3c68b
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e3c68b
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
e3c68b
---
e3c68b
 xlators/mgmt/glusterd/src/glusterd-utils.c | 2 +-
e3c68b
 1 file changed, 1 insertion(+), 1 deletion(-)
e3c68b
e3c68b
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
e3c68b
index c6e9bb0..4c487d0 100644
e3c68b
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
e3c68b
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
e3c68b
@@ -3697,7 +3697,7 @@ glusterd_add_volumes_to_export_dict(dict_t *peer_data, char **buf,
e3c68b
     if (totthread) {
e3c68b
         gf_log(this->name, GF_LOG_INFO,
e3c68b
                "Finished merger of all dictionraies into single one");
e3c68b
-        dict_arr[totthread++] = peer_data;
e3c68b
+        dict_arr[totthread++] = dict_ref(peer_data);
e3c68b
         ret = glusterd_dict_arr_serialize(dict_arr, totthread, buf, length);
e3c68b
         gf_log(this->name, GF_LOG_INFO,
e3c68b
                "Serialize dictionary data return is %d", ret);
e3c68b
-- 
e3c68b
1.8.3.1
e3c68b