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