Fix race condition & allow operation cache to grow.
authorPauli <ppzgs1@gmail.com>
Thu, 4 Feb 2021 04:40:19 +0000 (14:40 +1000)
committerPauli <ppzgs1@gmail.com>
Sun, 7 Feb 2021 10:01:50 +0000 (20:01 +1000)
commit64954e2f34b8839ca7ad1e9576a6efaf3e49e17c
tree5c75995a9212076a6ec6aa1873ba655eb571fc23
parent11ddbf84597d26c937ecb8f266424dea7f72cbdf
Fix race condition & allow operation cache to grow.

This fixes a race condition where the index to the cache location was found
under a read lock and a later write lock set the cache entry.  The issue being
that two threads could get the same location index and then fight each other
over writing the cache entry.  The most likely outcome is a memory leak,
however it would be possible to set up an invalid cache entry.

The operation cache was a fixed sized array, once full an assertion failed.
The other fix here is to convert this to a stack.  The code is simplified and
it avoids a cache overflow condition.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/14062)
crypto/evp/keymgmt_lib.c
crypto/evp/p_lib.c
doc/internal/man3/evp_keymgmt_util_export_to_provider.pod
include/crypto/evp.h