Discussion:
[openssl.org #3572] [BUG] Memory leak in DTLS re-negotiation
Dmitry Sobinov via RT
2014-10-18 18:45:53 UTC
Permalink
Hi,

There's a memory leak in DTLS code when re-negotiating already established
session. valgrind output:

==5475== HEAP SUMMARY:
==5475== in use at exit: 2,285 bytes in 17 blocks
==5475== total heap usage: 7,973 allocs, 7,956 frees, 789,213 bytes
allocated
==5475==
==5475== 432 (168 direct, 264 indirect) bytes in 1 blocks are definitely
lost in loss record 15 of 17
==5475== at 0x4C29F90: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5475== by 0x4518EC: default_malloc_ex (mem.c:79)
==5475== by 0x451F7B: CRYPTO_malloc (mem.c:308)
==5475== by 0x47C948: EVP_CIPHER_CTX_new (evp_enc.c:90)
==5475== by 0x446C80: tls1_change_cipher_state (t1_enc.c:419)
==5475== by 0x403E6D: dtls1_accept (d1_srvr.c:738)
==5475== by 0x415315: SSL_do_handshake (ssl_lib.c:2605)
==5475== by 0x402226: handshakeIteration (dtlstest2.c:146)
==5475== by 0x402816: main (dtlstest2.c:278)
==5475==
==5475== 861 (48 direct, 813 indirect) bytes in 1 blocks are definitely
lost in loss record 17 of 17
==5475== at 0x4C29F90: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5475== by 0x4518EC: default_malloc_ex (mem.c:79)
==5475== by 0x451F7B: CRYPTO_malloc (mem.c:308)
==5475== by 0x47BEA9: EVP_MD_CTX_create (digest.c:131)
==5475== by 0x446CD4: tls1_change_cipher_state (t1_enc.c:424)
==5475== by 0x403E6D: dtls1_accept (d1_srvr.c:738)
==5475== by 0x415315: SSL_do_handshake (ssl_lib.c:2605)
==5475== by 0x402226: handshakeIteration (dtlstest2.c:146)
==5475== by 0x402816: main (dtlstest2.c:278)
==5475==
==5475== LEAK SUMMARY:
==5475== definitely lost: 216 bytes in 2 blocks
==5475== indirectly lost: 1,077 bytes in 9 blocks
==5475== possibly lost: 0 bytes in 0 blocks
==5475== still reachable: 992 bytes in 6 blocks
==5475== suppressed: 0 bytes in 0 blocks


Test application is in the attachment. Just run it under valgrind
--leak-check-full

OpenSSL version is 1.0.1 latest revision from the official repo. Tested
under Linux x86_64.

---
Thanks,
Dmitry Sobinov

Loading...