From 24dd33929bbbc9a72360793048f17bf4e6cec8a3 Mon Sep 17 00:00:00 2001 From: Kaleb S KEITHLEY Date: Fri, 6 May 2016 13:04:38 -0400 Subject: libglusterfs (timer): race conditions, illegal mem access, mem leak While investigating gfapi memory consumption with valgrind, valgrind reported several memory access issues. Also see the timer 'registry' being recreated (shortly) after being freed during teardown due to the way it's currently written. Passing ctx as data to gf_timer_proc() is prone to memory access issues if ctx is freed before gf_timer_proc() terminates. (And in fact this does happen, at least in valgrind.) gf_timer_proc() doesn't need ctx for anything, it only needs ctx->timer, so just pass that. Nothing ever calls gf_timer_registry_init(). Nothing outside of timer.c that is. Making it and gf_timer_proc() static. Change-Id: Ia28454dda0cf0de2fec94d76441d98c3927a906a BUG: 1333925 Signed-off-by: Kaleb S KEITHLEY Reviewed-on: http://review.gluster.org/14247 NetBSD-regression: NetBSD Build System Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Poornima G Reviewed-by: Niels de Vos Reviewed-by: Jeff Darcy --- rpc/rpc-transport/rdma/src/rdma.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'rpc') diff --git a/rpc/rpc-transport/rdma/src/rdma.c b/rpc/rpc-transport/rdma/src/rdma.c index 1f397e42206..551ac072079 100644 --- a/rpc/rpc-transport/rdma/src/rdma.c +++ b/rpc/rpc-transport/rdma/src/rdma.c @@ -4641,7 +4641,7 @@ gf_rdma_init (rpc_transport_t *this) pthread_mutex_init (&priv->recv_mutex, NULL); pthread_cond_init (&priv->recv_cond, NULL); - pthread_mutex_lock (&ctx->lock); + LOCK (&ctx->lock); { if (ctx->ib == NULL) { ctx->ib = __gf_rdma_ctx_create (); @@ -4650,7 +4650,7 @@ gf_rdma_init (rpc_transport_t *this) } } } - pthread_mutex_unlock (&ctx->lock); + UNLOCK (&ctx->lock); return ret; } -- cgit