Skip to content

Unreleased pk->lock in evp_keymgmt_util_export_to_provider #16847

@ryancaicse

Description

@ryancaicse

Hi, developers, it seems the lock pk->lock (Line 171) is not released correctly when !evp_keymgmt_util_cache_keydata(pk, keymgmt, import_data.keydata). Should it be a bug, which potentially leads to recursively requiring the same lock?

if (!CRYPTO_THREAD_write_lock(pk->lock)) {
evp_keymgmt_freedata(keymgmt, import_data.keydata);
return NULL;
}
/* Check to make sure some other thread didn't get there first */
op = evp_keymgmt_util_find_operation_cache(pk, keymgmt);
if (op != NULL && op->keydata != NULL) {
void *ret = op->keydata;
CRYPTO_THREAD_unlock(pk->lock);
/*
* Another thread seemms to have already exported this so we abandon
* all the work we just did.
*/
evp_keymgmt_freedata(keymgmt, import_data.keydata);
return ret;
}
/*
* If the dirty counter changed since last time, then clear the
* operation cache. In that case, we know that |i| is zero.
*/
if (pk->dirty_cnt != pk->dirty_cnt_copy)
evp_keymgmt_util_clear_operation_cache(pk, 0);
/* Add the new export to the operation cache */
if (!evp_keymgmt_util_cache_keydata(pk, keymgmt, import_data.keydata)) {
evp_keymgmt_freedata(keymgmt, import_data.keydata);
return NULL;
}
/* Synchronize the dirty count */
pk->dirty_cnt_copy = pk->dirty_cnt;
CRYPTO_THREAD_unlock(pk->lock);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions