Blob Blame History Raw
From f0f811e8075703f007063937877ebdb77219765d Mon Sep 17 00:00:00 2001
From: Jiffin Tony Thottan <jthottan@redhat.com>
Date: Sat, 11 Jul 2015 15:47:18 +0530
Subject: [PATCH 233/234] access_control : avoid double unrefing of acl variable in its context.

In handling_other_acl_related_xattr(), acl variable is unrefered twice
after updating the context of access_control translator.So the acl variable
stored in the inmemory context will become invalid one. When the variable
accessed again , it will result in brick crash. This patch fixes the same.

Backport of http://review.gluster.org/#/c/11632/

Upstream reference
>Change-Id: Ib95d2e3d67b0fb20d201244a206379d6261aeb23
>BUG: 1242041
>Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>

Change-Id: Ib3bcf6f2f46adffb758ba24c680ce4ff879d6626
BUG: 1242046
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/52817
Reviewed-by: Kaleb Keithley <kkeithle@redhat.com>
Tested-by: Kaleb Keithley <kkeithle@redhat.com>
---
 xlators/system/posix-acl/src/posix-acl.c |   31 +++++++++++++++--------------
 1 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/xlators/system/posix-acl/src/posix-acl.c b/xlators/system/posix-acl/src/posix-acl.c
index da2ccbd..b1d3df3 100644
--- a/xlators/system/posix-acl/src/posix-acl.c
+++ b/xlators/system/posix-acl/src/posix-acl.c
@@ -1945,37 +1945,38 @@ handling_other_acl_related_xattr (xlator_t *this, inode_t *inode, dict_t *xattr)
         data_t                 *data     = NULL;
         int                     ret      = 0;
 
-        ctx = posix_acl_ctx_get (inode, this);
-        if (!ctx) {
-                ret = -1;
-                goto out;
-        }
-
         data = dict_get (xattr, POSIX_ACL_ACCESS_XATTR);
         if (data) {
-                ctx = posix_acl_ctx_get (inode, this);
-                if (!ctx) {
+
+
+                acl = posix_acl_from_xattr (this, data->data, data->len);
+                if (!acl) {
                         ret = -1;
                         goto out;
                 }
 
-                acl = posix_acl_from_xattr (this, data->data, data->len);
-
                 ret = posix_acl_set_specific (inode, this, acl, _gf_true);
                 if (ret)
                         goto out;
 
-                if (acl)
-                        posix_acl_access_set_mode (acl, ctx);
-
-        }
+                ctx = posix_acl_ctx_get (inode, this);
+                if (!ctx) {
+                        ret = -1;
+                        goto out;
+                }
 
-        if (acl)
+                posix_acl_access_set_mode (acl, ctx);
                 posix_acl_unref (this, acl);
+                acl = NULL;
+        }
 
         data = dict_get (xattr, POSIX_ACL_DEFAULT_XATTR);
         if (data) {
                 acl = posix_acl_from_xattr (this, data->data, data->len);
+                if (!acl) {
+                        ret = -1;
+                        goto out;
+                }
 
                 ret = posix_acl_set_specific (inode, this, acl, _gf_false);
         }
-- 
1.7.1