Deadlock in lib/krb5/mcache.c #432

This commit is contained in:
YASUOKA Masahiko
2018-12-26 11:32:58 -06:00
committed by Nico Williams
parent 63914b95b8
commit becb0b03ae

View File

@@ -248,27 +248,28 @@ mcc_destroy(krb5_context context,
{ {
krb5_mcache **n, *m = MCACHE(id); krb5_mcache **n, *m = MCACHE(id);
HEIMDAL_MUTEX_lock(&mcc_mutex);
HEIMDAL_MUTEX_lock(&(m->mutex)); HEIMDAL_MUTEX_lock(&(m->mutex));
if (m->refcnt == 0) if (m->refcnt == 0)
{ {
HEIMDAL_MUTEX_unlock(&(m->mutex)); HEIMDAL_MUTEX_unlock(&(m->mutex));
HEIMDAL_MUTEX_unlock(&mcc_mutex);
krb5_abortx(context, "mcc_destroy: refcnt already 0"); krb5_abortx(context, "mcc_destroy: refcnt already 0");
} }
if (!MISDEAD(m)) { if (!MISDEAD(m)) {
/* if this is an active mcache, remove it from the linked /* if this is an active mcache, remove it from the linked
list, and free all data */ list, and free all data */
HEIMDAL_MUTEX_lock(&mcc_mutex);
for(n = &mcc_head; n && *n; n = &(*n)->next) { for(n = &mcc_head; n && *n; n = &(*n)->next) {
if(m == *n) { if(m == *n) {
*n = m->next; *n = m->next;
break; break;
} }
} }
HEIMDAL_MUTEX_unlock(&mcc_mutex);
mcc_destroy_internal(context, m); mcc_destroy_internal(context, m);
} }
HEIMDAL_MUTEX_unlock(&(m->mutex)); HEIMDAL_MUTEX_unlock(&(m->mutex));
HEIMDAL_MUTEX_unlock(&mcc_mutex);
return 0; return 0;
} }