mbedtls: CVE-2025-52496 fix

Backported from 3.6.x

Fixes a race condition
This commit is contained in:
Jeremy Newton 2025-10-31 22:09:52 -04:00
parent 59faf2506f
commit 07f4c1b44e

View File

@ -42,8 +42,12 @@
*/
int mbedtls_aesni_has_support(unsigned int what)
{
static int done = 0;
static unsigned int c = 0;
/* To avoid a race condition, tell the compiler that the assignment
* `done = 1` and the assignment to `c` may not be reordered.
* https://github.com/Mbed-TLS/mbedtls/issues/9840
*/
static volatile int done = 0;
static volatile unsigned int c = 0;
if (!done) {
#if MBEDTLS_AESNI_HAVE_CODE == 2