From 52f2b0dbee75a956035274a2721dfc04bf7768bb Mon Sep 17 00:00:00 2001 From: Thierry Bordaz Date: Oct 07 2019 13:10:42 +0000 Subject: Ticket 50636 - Crash during sasl bind Bug Description: Sasl bind registers IO layers (sasl_IoMethods) that will be pushed (and called) by the next incoming operation. So the next incoming operation should synchronize itself with the sasl bind. Fix Description: The call to connection_call_io_layer_callbacks, that pushes registered methods, must hold c_mutex so that it let a pending sasl bind to fully register the methods. https://pagure.io/389-ds-base/issue/50636 Reviewed by: Ludwig Krispenz, Mark Reynolds Platforms tested: F28 Flag Day: no Doc impact: no --- diff --git a/ldap/servers/slapd/connection.c b/ldap/servers/slapd/connection.c index 3600d3d..300e0b7 100644 --- a/ldap/servers/slapd/connection.c +++ b/ldap/servers/slapd/connection.c @@ -1576,12 +1576,15 @@ connection_threadmain() */ pb_conn->c_anonlimits_set = 1; } - pthread_mutex_unlock(&(pb_conn->c_mutex)); + /* must hold c_mutex so that it synchronizes the IO layer push + * with a potential pending sasl bind that is registering the IO layer + */ if (connection_call_io_layer_callbacks(pb_conn)) { slapi_log_err(SLAPI_LOG_ERR, "connection_threadmain", "Could not add/remove IO layers from connection\n"); } + pthread_mutex_unlock(&(pb_conn->c_mutex)); break; default: break;