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