7c2869
From d005ede12e1da99dc077bf9e1c563a0f9f4066e3 Mon Sep 17 00:00:00 2001
7c2869
From: Pranith Kumar K <pkarampu@redhat.com>
7c2869
Date: Mon, 19 Mar 2018 12:09:18 +0530
7c2869
Subject: [PATCH 667/675] features/shard: Do list_del_init() while list memory
7c2869
 is valid
7c2869
7c2869
> Upstream: https://review.gluster.org/19737
7c2869
> BUG: 1557876
7c2869
> Change-Id: If429d3634219e1a435bd0da0ed985c646c59c2ca
7c2869
7c2869
Problem:
7c2869
shard_post_lookup_fsync_handler() goes over the list of inode-ctx that need to
7c2869
be fsynced and in cbk it removes each of the inode-ctx from the list. When the
7c2869
first member of list is removed it tries to modifies list head's memory with
7c2869
the latest next/prev and when this happens, there is no guarantee that the
7c2869
list-head which is from stack memory of shard_post_lookup_fsync_handler() is
7c2869
valid.
7c2869
7c2869
Fix:
7c2869
Do list_del_init() in the loop before winding fsync.
7c2869
7c2869
Change-Id: If429d3634219e1a435bd0da0ed985c646c59c2ca
7c2869
BUG: 1585046
7c2869
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
7c2869
Reviewed-on: https://code.engineering.redhat.com/gerrit/140483
7c2869
Tested-by: Krutika Dhananjay <kdhananj@redhat.com>
7c2869
Tested-by: RHGS Build Bot <nigelb@redhat.com>
7c2869
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
7c2869
---
7c2869
 xlators/features/shard/src/shard.c | 2 +-
7c2869
 1 file changed, 1 insertion(+), 1 deletion(-)
7c2869
7c2869
diff --git a/xlators/features/shard/src/shard.c b/xlators/features/shard/src/shard.c
7c2869
index 68d1a3a..651d08a 100644
7c2869
--- a/xlators/features/shard/src/shard.c
7c2869
+++ b/xlators/features/shard/src/shard.c
7c2869
@@ -4525,7 +4525,6 @@ out:
7c2869
                         if (op_ret == 0)
7c2869
                                 ctx->fsync_needed -= fsync_count;
7c2869
                         GF_ASSERT (ctx->fsync_needed >= 0);
7c2869
-                        list_del_init (&ctx->to_fsync_list);
7c2869
                         if (ctx->fsync_needed != 0) {
7c2869
                                 list_add_tail (&ctx->to_fsync_list,
7c2869
                                                &base_ictx->to_fsync_list);
7c2869
@@ -4600,6 +4599,7 @@ shard_post_lookup_fsync_handler (call_frame_t *frame, xlator_t *this)
7c2869
         anon_fd = NULL;
7c2869
 
7c2869
         list_for_each_entry_safe (iter, tmp, &copy, to_fsync_list) {
7c2869
+                list_del_init (&iter->to_fsync_list);
7c2869
                 fsync_count = 0;
7c2869
                 shard_inode_ctx_get_fsync_count (iter->inode, this,
7c2869
                                                  &fsync_count);
7c2869
-- 
7c2869
1.8.3.1
7c2869