From fb792cad31f843c5924869cb99bc3cef05edd6ca Mon Sep 17 00:00:00 2001 From: Ryan Everett Date: Wed, 31 Jan 2024 13:40:05 +0000 Subject: [PATCH] Make psa_get_and_lock_X_with_policy threadsafe Between the call to psa_get_and_lock_key_slot and psa_unregister_read we only read the contents of a slot which we are registered to read, so no extra mutex taking is needed. Signed-off-by: Ryan Everett --- library/psa_crypto.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index e6d3851ba8..e3b2be6fe4 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -936,7 +936,7 @@ static psa_status_t psa_get_and_lock_key_slot_with_policy( error: *p_slot = NULL; - psa_unregister_read(slot); + psa_unregister_read_under_mutex(slot); return status; } @@ -968,7 +968,7 @@ static psa_status_t psa_get_and_lock_transparent_key_slot_with_policy( } if (psa_key_lifetime_is_external((*p_slot)->attr.lifetime)) { - psa_unregister_read(*p_slot); + psa_unregister_read_under_mutex(*p_slot); *p_slot = NULL; return PSA_ERROR_NOT_SUPPORTED; }