From fb9857ff9eaa980411ac58831f42fd93b1471ecd Mon Sep 17 00:00:00 2001 From: Ryan Everett Date: Wed, 14 Feb 2024 12:16:41 +0000 Subject: [PATCH] Make multi-part MAC operations thread-safe Within setup we create a copy of the key and put it in the operation field. After setup, we only ever use the new copy - and do not interact with any key slots. Therefore we need only register as a reader of the key during setup, then unregister after we stop accessing the key. Simultaneous API calls on the same operation object are not thread-safe. Signed-off-by: Ryan Everett --- library/psa_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/psa_crypto.c b/library/psa_crypto.c index 6cd6557d9e..f9b2fff70a 100644 --- a/library/psa_crypto.c +++ b/library/psa_crypto.c @@ -2565,7 +2565,7 @@ exit: psa_mac_abort(operation); } - unlock_status = psa_unregister_read(slot); + unlock_status = psa_unregister_read_under_mutex(slot); return (status == PSA_SUCCESS) ? unlock_status : status; }