-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problem with mutex used in CTR_DRBG and HMAC_DRBG #4017
Comments
Indeed #3393 is a regression on platforms where Please note that Mbed TLS 2.7 is approaching the end of its support period. Given that this bug is a regression on long-time support branches, I think we'll make one more 2.7 release to fix it, but that will be the last release in the 2.7 series. Everyone who is still using Mbed TLS 2.7 should upgrade to the 2.16 long-time support branch or to the latest release. |
There's a proposed fix in #4090. Please note that it has not been reviewed yet, and we may yet revise how we resolve this issue (it's not fully clear to me how to fix this issue without breaking “unusual” usage of the API). If you want to try it out, you can apply the patches locally: use the branch https://github.com/gilles-peskine-arm/mbedtls/tree/test-mutex-usage-count-2.7, or the individual patches a989b1f for CTR_DRBG and dc3e470 for HMAC_DRBG. The 2.7 patches should work for 2.16 as well. |
I did some tests and when calling mbedtls_ssl_handshake My server does:
I attached a log of the handshake process, with extra log when mutex are created or deleted |
(continued from #4071 (comment)) @giso-c There are two implementations of
|
I used this version https://github.com/gilles-peskine-arm/mbedtls/tree/test-mutex-usage-count-development and it seems that the bug is fixed, I was also investigating another memory issue I was having with version 2.14 and this code seems to have fixed it. |
The fix is now merged into the supported branches (https://github.com/ARMmbed/mbedtls/tree/mbedtls-2.7, https://github.com/ARMmbed/mbedtls/tree/mbedtls-2.16 and https://github.com/ARMmbed/mbedtls/tree/development). The critical parts (mutex resource leak through a DRBG context) is identical to the patches I shared earlier. |
Bug
OS
embedded system
mbed TLS build:
Version: 2.7.17
Hello everyone.
I am trying to upgrade the library from version 2.7.17 to 2.7.18.
In my application I use the mbedtls library together with curl.
After updating, my device stops connecting to servers properly after some time.
My application control the number of mutexes used by mbedtls. Logs show that there are no free mutexes to use and a new one could not be initialized.
This has to do with 'In CTR_DRBG and HMAC_DRBG, don't reset the reseed interval in seed (). Fixes # 2927. '
In the mbedtls_crt_drbg_free and mbedtls_hmac_drbg_free functions, a new mutex is initialized at the end of these functions. What if we don't want to use mbedtls_crt_drbg_context or mbedtls_hmac_drbg_context anymore?
In the library I found this function:
https://github.com/ARMmbed/mbedtls/blob/d0c7b79170dbfa42932523c8b4dd326559cf698e/library/ecp.c#L2241
which uses the local ecp_drbg_context. After executing the function, ecp_drbg_context is released but the mutex is initialized and its address is dropped.
Perhaps this is the real problem. I cannot define it.
The text was updated successfully, but these errors were encountered: