From 7f21238bb918a9b6eefcff5d76516a92a9271ae2 Mon Sep 17 00:00:00 2001 From: Jiffin Tony Thottan Date: Sat, 11 Jul 2015 15:47:18 +0530 Subject: 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. Change-Id: Ib95d2e3d67b0fb20d201244a206379d6261aeb23 BUG: 1242041 Signed-off-by: Jiffin Tony Thottan Reviewed-on: http://review.gluster.org/11632 Tested-by: NetBSD Build System Reviewed-by: Niels de Vos Reviewed-by: soumya k Tested-by: Gluster Build System Reviewed-by: Kaleb KEITHLEY --- xlators/system/posix-acl/src/posix-acl.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'xlators/system') diff --git a/xlators/system/posix-acl/src/posix-acl.c b/xlators/system/posix-acl/src/posix-acl.c index da2ccbd1c54..b1d3df396fb 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); } -- cgit