21ab4e
From 1e8465620f006628e68c9cd96b03eb5317542171 Mon Sep 17 00:00:00 2001
21ab4e
From: N Balachandran <nbalacha@redhat.com>
21ab4e
Date: Mon, 22 May 2017 11:26:22 +0530
21ab4e
Subject: [PATCH 462/473] cluster/dht: Fix crash in dht_selfheal_dir_setattr
21ab4e
21ab4e
Use a local variable to store the call cnt used in the
21ab4e
for loop for the STACK_WIND so as not to access local
21ab4e
which may be freed by STACK_UNWIND after all fops return.
21ab4e
21ab4e
> BUG: 1452102
21ab4e
> Signed-off-by: N Balachandran <nbalacha@redhat.com>
21ab4e
> Reviewed-on: https://review.gluster.org/17343
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
Change-Id: I24f49b6dbd29a2b706e388e2f6d5196c0f80afc5
21ab4e
BUG: 1453049
21ab4e
Signed-off-by: N Balachandran <nbalacha@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/106793
21ab4e
Reviewed-by: Mohit Agrawal <moagrawa@redhat.com>
21ab4e
---
21ab4e
 xlators/cluster/dht/src/dht-selfheal.c | 8 ++++++--
21ab4e
 1 file changed, 6 insertions(+), 2 deletions(-)
21ab4e
21ab4e
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
21ab4e
index c2d1c14..4180380 100644
21ab4e
--- a/xlators/cluster/dht/src/dht-selfheal.c
21ab4e
+++ b/xlators/cluster/dht/src/dht-selfheal.c
21ab4e
@@ -1092,6 +1092,7 @@ dht_selfheal_dir_setattr (call_frame_t *frame, loc_t *loc, struct iatt *stbuf,
21ab4e
         int           i     = 0, ret = -1;
21ab4e
         dht_local_t  *local = NULL;
21ab4e
         xlator_t     *this = NULL;
21ab4e
+        int           cnt  = 0;
21ab4e
 
21ab4e
         local = frame->local;
21ab4e
         this = frame->this;
21ab4e
@@ -1117,7 +1118,8 @@ dht_selfheal_dir_setattr (call_frame_t *frame, loc_t *loc, struct iatt *stbuf,
21ab4e
                 gf_uuid_copy (loc->gfid, local->gfid);
21ab4e
 
21ab4e
         local->call_cnt = missing_attr;
21ab4e
-        for (i = 0; i < layout->cnt; i++) {
21ab4e
+        cnt = layout->cnt;
21ab4e
+        for (i = 0; i < cnt; i++) {
21ab4e
                 if (layout->list[i].err == -1) {
21ab4e
                         gf_msg_trace (this->name, 0,
21ab4e
                                       "%s: setattr on subvol %s, gfid = %s",
21ab4e
@@ -1241,6 +1243,7 @@ dht_selfheal_dir_mkdir_lookup_done (call_frame_t *frame, xlator_t *this)
21ab4e
         dict_t       *dict = NULL;
21ab4e
         dht_layout_t  *layout = NULL;
21ab4e
         loc_t        *loc   = NULL;
21ab4e
+        int           cnt   = 0;
21ab4e
 
21ab4e
         VALIDATE_OR_GOTO (this->private, err);
21ab4e
 
21ab4e
@@ -1273,7 +1276,8 @@ dht_selfheal_dir_mkdir_lookup_done (call_frame_t *frame, xlator_t *this)
21ab4e
                         DHT_MSG_DICT_SET_FAILED,
21ab4e
                         "dict is NULL, need to make sure gfids are same");
21ab4e
 
21ab4e
-        for (i = 0; i < layout->cnt; i++) {
21ab4e
+        cnt = layout->cnt;
21ab4e
+        for (i = 0; i < cnt; i++) {
21ab4e
                 if (layout->list[i].err == ESTALE ||
21ab4e
                     layout->list[i].err == ENOENT ||
21ab4e
                     local->selfheal.force_mkdir) {
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e