From 4eb49de567c5e9f4559bfb05a6174ac8020b03ad Mon Sep 17 00:00:00 2001 From: Zhang Huan <zhanghuan@open-fs.com> Date: Tue, 5 Dec 2017 12:54:04 +0800 Subject: [PATCH] gfapi: fix issue when glfs_set_logging is called concurrently glfs_set_logging changes THIS->ctx without lock, during initialization THIS refers to global_xlator. Concurrently changing it could result in global_xlator.ctx being some fs->ctx. After that fs->ctx is destroyed, global_xlator.ctx refers to an invalid pointer and that causes crash in sbusequent access. Change-Id: I6682173811799bafd525d9ab371874f3803baa0e BUG: 1521213 Signed-off-by: Zhang Huan <zhanghuan@open-fs.com> --- api/src/glfs.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/api/src/glfs.c b/api/src/glfs.c index d6c05b763..9aa817b3f 100644 --- a/api/src/glfs.c +++ b/api/src/glfs.c @@ -929,14 +929,10 @@ pub_glfs_set_logging (struct glfs *fs, const char *logfile, int loglevel) { int ret = -1; char *tmplog = NULL; - glusterfs_ctx_t *old_ctx = NULL; DECLARE_OLD_THIS; __GLFS_ENTRY_VALIDATE_FS (fs, invalid_fs); - old_ctx = THIS->ctx; - THIS->ctx = fs->ctx; - if (!logfile) { ret = gf_set_log_file_path (&fs->ctx->cmd_args, fs->ctx); if (ret) @@ -959,7 +955,6 @@ pub_glfs_set_logging (struct glfs *fs, const char *logfile, int loglevel) goto out; out: - THIS->ctx = old_ctx; __GLFS_EXIT_FS; invalid_fs: