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