7f4c2a
From 63bd03660e88fe2aab59b0c3d86e079855cf87c1 Mon Sep 17 00:00:00 2001
7f4c2a
From: vmallika <vmallika@redhat.com>
7f4c2a
Date: Thu, 13 Aug 2015 14:11:59 +0530
7f4c2a
Subject: [PATCH 257/279] quota/marker: contribution with list_del can cause mem corruption
7f4c2a
7f4c2a
This is a backport of http://review.gluster.org/11706
7f4c2a
7f4c2a
There is a possibility that contribution is removed twice from list
7f4c2a
during unlink operation (with hard links) or during rename operation
7f4c2a
7f4c2a
Use list_del_init for a thread safe deltion of member from list
7f4c2a
7f4c2a
> Change-Id: Iff5e0c03cc8f0ed85da0db1739b84b695abf9ea6
7f4c2a
> BUG: 1244109
7f4c2a
> Signed-off-by: vmallika <vmallika@redhat.com>
7f4c2a
> Reviewed-on: http://review.gluster.org/11706
7f4c2a
> Tested-by: Gluster Build System <jenkins@build.gluster.com>
7f4c2a
> Tested-by: NetBSD Build System <jenkins@build.gluster.org>
7f4c2a
> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
7f4c2a
> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
7f4c2a
7f4c2a
BUG: 1236672
7f4c2a
Change-Id: Ic40d7342039a0512345418ab146d67682b87be21
7f4c2a
Signed-off-by: vmallika <vmallika@redhat.com>
7f4c2a
Reviewed-on: https://code.engineering.redhat.com/gerrit/55061
7f4c2a
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
7f4c2a
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
7f4c2a
---
7f4c2a
 xlators/features/marker/src/marker-quota-helper.h |   16 ++++++++--------
7f4c2a
 xlators/features/marker/src/marker-quota.c        |    2 +-
7f4c2a
 2 files changed, 9 insertions(+), 9 deletions(-)
7f4c2a
7f4c2a
diff --git a/xlators/features/marker/src/marker-quota-helper.h b/xlators/features/marker/src/marker-quota-helper.h
7f4c2a
index f69447b..1f9faf5 100644
7f4c2a
--- a/xlators/features/marker/src/marker-quota-helper.h
7f4c2a
+++ b/xlators/features/marker/src/marker-quota-helper.h
7f4c2a
@@ -18,14 +18,14 @@
7f4c2a
 
7f4c2a
 #include "marker.h"
7f4c2a
 
7f4c2a
-#define QUOTA_FREE_CONTRIBUTION_NODE(ctx, _contribution)          \
7f4c2a
-        do {                                                      \
7f4c2a
-                LOCK (&ctx->lock);                                \
7f4c2a
-                {                                                 \
7f4c2a
-                        list_del (&_contribution->contri_list);   \
7f4c2a
-                        GF_REF_PUT (_contribution);               \
7f4c2a
-                }                                                 \
7f4c2a
-                UNLOCK (&ctx->lock);                              \
7f4c2a
+#define QUOTA_FREE_CONTRIBUTION_NODE(ctx, _contribution)             \
7f4c2a
+        do {                                                         \
7f4c2a
+                LOCK (&ctx->lock);                                   \
7f4c2a
+                {                                                    \
7f4c2a
+                        list_del_init (&_contribution->contri_list); \
7f4c2a
+                        GF_REF_PUT (_contribution);                  \
7f4c2a
+                }                                                    \
7f4c2a
+                UNLOCK (&ctx->lock);                                 \
7f4c2a
         } while (0)
7f4c2a
 
7f4c2a
 #define QUOTA_SAFE_INCREMENT(lock, var)                 \
7f4c2a
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c
7f4c2a
index ca59c1b..f65ed77 100644
7f4c2a
--- a/xlators/features/marker/src/marker-quota.c
7f4c2a
+++ b/xlators/features/marker/src/marker-quota.c
7f4c2a
@@ -4178,7 +4178,7 @@ mq_forget (xlator_t *this, quota_inode_ctx_t *ctx)
7f4c2a
 
7f4c2a
         list_for_each_entry_safe (contri, next, &ctx->contribution_head,
7f4c2a
                                   contri_list) {
7f4c2a
-                list_del (&contri->contri_list);
7f4c2a
+                list_del_init (&contri->contri_list);
7f4c2a
                 GF_REF_PUT (contri);
7f4c2a
         }
7f4c2a
 
7f4c2a
-- 
7f4c2a
1.7.1
7f4c2a