cb8e9e
From f0f811e8075703f007063937877ebdb77219765d Mon Sep 17 00:00:00 2001
cb8e9e
From: Jiffin Tony Thottan <jthottan@redhat.com>
cb8e9e
Date: Sat, 11 Jul 2015 15:47:18 +0530
cb8e9e
Subject: [PATCH 233/234] access_control : avoid double unrefing of acl variable in its context.
cb8e9e
cb8e9e
In handling_other_acl_related_xattr(), acl variable is unrefered twice
cb8e9e
after updating the context of access_control translator.So the acl variable
cb8e9e
stored in the inmemory context will become invalid one. When the variable
cb8e9e
accessed again , it will result in brick crash. This patch fixes the same.
cb8e9e
cb8e9e
Backport of http://review.gluster.org/#/c/11632/
cb8e9e
cb8e9e
Upstream reference
cb8e9e
>Change-Id: Ib95d2e3d67b0fb20d201244a206379d6261aeb23
cb8e9e
>BUG: 1242041
cb8e9e
>Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
cb8e9e
cb8e9e
Change-Id: Ib3bcf6f2f46adffb758ba24c680ce4ff879d6626
cb8e9e
BUG: 1242046
cb8e9e
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/52817
cb8e9e
Reviewed-by: Kaleb Keithley <kkeithle@redhat.com>
cb8e9e
Tested-by: Kaleb Keithley <kkeithle@redhat.com>
cb8e9e
---
cb8e9e
 xlators/system/posix-acl/src/posix-acl.c |   31 +++++++++++++++--------------
cb8e9e
 1 files changed, 16 insertions(+), 15 deletions(-)
cb8e9e
cb8e9e
diff --git a/xlators/system/posix-acl/src/posix-acl.c b/xlators/system/posix-acl/src/posix-acl.c
cb8e9e
index da2ccbd..b1d3df3 100644
cb8e9e
--- a/xlators/system/posix-acl/src/posix-acl.c
cb8e9e
+++ b/xlators/system/posix-acl/src/posix-acl.c
cb8e9e
@@ -1945,37 +1945,38 @@ handling_other_acl_related_xattr (xlator_t *this, inode_t *inode, dict_t *xattr)
cb8e9e
         data_t                 *data     = NULL;
cb8e9e
         int                     ret      = 0;
cb8e9e
 
cb8e9e
-        ctx = posix_acl_ctx_get (inode, this);
cb8e9e
-        if (!ctx) {
cb8e9e
-                ret = -1;
cb8e9e
-                goto out;
cb8e9e
-        }
cb8e9e
-
cb8e9e
         data = dict_get (xattr, POSIX_ACL_ACCESS_XATTR);
cb8e9e
         if (data) {
cb8e9e
-                ctx = posix_acl_ctx_get (inode, this);
cb8e9e
-                if (!ctx) {
cb8e9e
+
cb8e9e
+
cb8e9e
+                acl = posix_acl_from_xattr (this, data->data, data->len);
cb8e9e
+                if (!acl) {
cb8e9e
                         ret = -1;
cb8e9e
                         goto out;
cb8e9e
                 }
cb8e9e
 
cb8e9e
-                acl = posix_acl_from_xattr (this, data->data, data->len);
cb8e9e
-
cb8e9e
                 ret = posix_acl_set_specific (inode, this, acl, _gf_true);
cb8e9e
                 if (ret)
cb8e9e
                         goto out;
cb8e9e
 
cb8e9e
-                if (acl)
cb8e9e
-                        posix_acl_access_set_mode (acl, ctx);
cb8e9e
-
cb8e9e
-        }
cb8e9e
+                ctx = posix_acl_ctx_get (inode, this);
cb8e9e
+                if (!ctx) {
cb8e9e
+                        ret = -1;
cb8e9e
+                        goto out;
cb8e9e
+                }
cb8e9e
 
cb8e9e
-        if (acl)
cb8e9e
+                posix_acl_access_set_mode (acl, ctx);
cb8e9e
                 posix_acl_unref (this, acl);
cb8e9e
+                acl = NULL;
cb8e9e
+        }
cb8e9e
 
cb8e9e
         data = dict_get (xattr, POSIX_ACL_DEFAULT_XATTR);
cb8e9e
         if (data) {
cb8e9e
                 acl = posix_acl_from_xattr (this, data->data, data->len);
cb8e9e
+                if (!acl) {
cb8e9e
+                        ret = -1;
cb8e9e
+                        goto out;
cb8e9e
+                }
cb8e9e
 
cb8e9e
                 ret = posix_acl_set_specific (inode, this, acl, _gf_false);
cb8e9e
         }
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e