Bug 717738
| Summary: | memleak in tlsm_auth_cert_handler | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | Jan Vcelak <jvcelak> | ||||
| Component: | openldap | Assignee: | Jan Vcelak <jvcelak> | ||||
| Status: | CLOSED ERRATA | QA Contact: | BaseOS QE Security Team <qe-baseos-security> | ||||
| Severity: | high | Docs Contact: | |||||
| Priority: | urgent | ||||||
| Version: | 6.1 | CC: | cww, jplans, jvcelak, jwest, omoris, rmeggins, rrelyea, rvokal, shaines, tsmetana | ||||
| Target Milestone: | rc | Keywords: | ZStream | ||||
| Target Release: | --- | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | openldap-2.4.23-16.el6 | Doc Type: | Bug Fix | ||||
| Doc Text: |
- Any tool which uses both OpenLDAP and Mozilla NSS libraries. OpenLDAP validates TLS peer and the certificate is cached by Mozilla NSS library.
- The tool can fail on NSS_Shutdown function call, because the client certificate is not freed and the caches cannot be destroyed.
- Peer certificate is freed in OpenLDAP library after certificate validation is finished.
- All caches can be freed and NSS_Shutdown succeeds.
|
Story Points: | --- | ||||
| Clone Of: | 717730 | Environment: | |||||
| Last Closed: | 2011-12-06 12:12:51 UTC | Type: | --- | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Embargoed: | |||||||
| Bug Depends On: | 717730 | ||||||
| Bug Blocks: | 710372, 723134, 790916 | ||||||
| Attachments: |
|
||||||
|
Description
Jan Vcelak
2011-06-29 18:05:07 UTC
Fix included in openldap-2.4.23-16.el6
Technical note added. If any revisions are required, please edit the "Technical Notes" field
accordingly. All revisions will be proofread by the Engineering Content Services team.
New Contents:
- Any tool which uses both OpenLDAP and Mozilla NSS libraries. OpenLDAP validates TLS peer and the certificate is cached by Mozilla NSS library.
- The tool can fail on NSS_Shutdown function call, because the client certificate is not freed and the caches cannot be destroyed.
- Peer certificate is freed in OpenLDAP library after certificate validation is finished.
- All caches can be freed and NSS_Shutdown succeeds.
What exactly I need to reproduce this bug? I set-up slapd on SSL/TLS and there are leaks reported while running valgrind on ldapsearch -ZZ in both new and old version of openldap: New (15.el6_1.1) ==6603== Warning: invalid file descriptor -1 in syscall close() ==6603== ==6603== HEAP SUMMARY: ==6603== in use at exit: 16,829 bytes in 101 blocks ==6603== total heap usage: 5,909 allocs, 5,808 frees, 1,934,615 bytes allocated ==6603== ==6603== LEAK SUMMARY: ==6603== definitely lost: 59 bytes in 2 blocks ==6603== indirectly lost: 0 bytes in 0 blocks ==6603== possibly lost: 52 bytes in 2 blocks ==6603== still reachable: 16,718 bytes in 97 blocks ==6603== suppressed: 0 bytes in 0 blocks ==6603== Rerun with --leak-check=full to see details of leaked memory ==6603== ==6603== For counts of detected and suppressed errors, rerun with: -v ==6603== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 44 from 13) Old (15.el6) ==7718== Warning: invalid file descriptor -1 in syscall close() ==7718== ==7718== HEAP SUMMARY: ==7718== in use at exit: 24,374 bytes in 125 blocks ==7718== total heap usage: 5,910 allocs, 5,785 frees, 1,934,687 bytes allocated ==7718== ==7718== LEAK SUMMARY: ==7718== definitely lost: 131 bytes in 3 blocks ==7718== indirectly lost: 0 bytes in 0 blocks ==7718== possibly lost: 11,667 bytes in 27 blocks ==7718== still reachable: 12,576 bytes in 95 blocks ==7718== suppressed: 0 bytes in 0 blocks ==7718== Rerun with --leak-check=full to see details of leaked memory ==7718== ==7718== For counts of detected and suppressed errors, rerun with: -v ==7718== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 44 from 13) I can attach valgrind --leak-check=yes outputs if needed, anyway: # grep tlsm old.valgrind ==9994== by 0x4051775: tlsm_init (tls_m.c:2906) ==9994== by 0x4052D9E: tlsm_deferred_ctx_init (tls_m.c:1598) ==9994== by 0x404FD7C: tlsm_session_new (tls_m.c:2306) ==9994== by 0x4052D9E: tlsm_deferred_ctx_init (tls_m.c:1598) ==9994== by 0x40516CE: tlsm_ctx_free (tls_m.c:1927) ==9994== by 0x4052D9E: tlsm_deferred_ctx_init (tls_m.c:1598) ==9994== by 0x4052D9E: tlsm_deferred_ctx_init (tls_m.c:1598) ==9994== by 0x4052D9E: tlsm_deferred_ctx_init (tls_m.c:1598) # grep tlsm new.valgrind ==8855== by 0x40516A5: tlsm_init (tls_m.c:2908) ==8855== by 0x4052CCE: tlsm_deferred_ctx_init (tls_m.c:1600) ==8855== by 0x404FCAC: tlsm_session_new (tls_m.c:2308) Ondrej, I know there are some leaks. And will investigate what can be done with it. I'm sure that all cannot be removed at the moment - one is definitely intended. Anyway, for the purpose of this bug, I was grepping for NSSCryptoContext_FindOrImportCertificate Thanks for you reply Jan. However, it seems to be hard to reproduce the leak mentioned in the description. Rich, could you provide more specific reproducer? Is anything specific needed to hit it? For instance, client certificates, certificate / key pairs in NSS DB or in pem files, certificate parameters, anything else... I have set-up openldap server to listen on both 636 and 389, added some sample data into it, told it to use cacert, server certificate and key from pem files, told openldap clients not to use client certificates and to demand server certificate verification and then used ldapsearch -ZZ to require TLS. As I have mentioned before, it is leaking, but I do not see the leak you reported. I am attaching valgrind --leak-check=full output. Created attachment 514017 [details]
Valgrind --leak-check=full output (old version)
(In reply to comment #10) > Created attachment 514017 [details] > Valgrind --leak-check=full output (old version) What platform is this? This openldap is using openssl, not moznss. Hi Rich, it is i686 and it is openldap-2.4.23-15.el6 which uses nss instead of openssl. It should use nss, shouldn't it? (In reply to comment #12) > Hi Rich, it is i686 and it is openldap-2.4.23-15.el6 which uses nss instead of > openssl. It should use nss, shouldn't it? Yes. How is this possible? How was this built? Ah, sorry, my fault. I was playing with it probably too much, I am attaching valgrind output of ldapsearch -ZZ for openldap-2.4.23-15.el6 build _with_ NSS (and deprecating previous valgrind output). See http://nest.test.redhat.com/mnt/qa/scratch/omoris/old-leaks.txt (In reply to comment #14) > Ah, sorry, my fault. I was playing with it probably too much, I am attaching > valgrind output of ldapsearch -ZZ for openldap-2.4.23-15.el6 build _with_ NSS > (and deprecating previous valgrind output). > > See http://nest.test.redhat.com/mnt/qa/scratch/omoris/old-leaks.txt Yes, this is the leak. Note that you should use the valgrind argument --num-callers=50 to get the full stack. Is this an example of a leak we are hunting for? ==3112== 24 bytes in 1 blocks are possibly lost in loss record 39 of 111 ==3112== at 0x40053B3: calloc (vg_replace_malloc.c:467) ==3112== by 0xC1324B: PR_Calloc (prmem.c:475) ==3112== by 0x5B50D7: nss_ZAlloc (arena.c:892) ==3112== by 0x5B5806: nss_arena_hash_alloc_entry (hashops.c:98) ==3112== by 0xC48785: PL_HashTableRawAdd (plhash.c:265) ==3112== by 0xC4886D: PL_HashTableAdd (plhash.c:296) ==3112== by 0x5B6D71: nssHash_Add (hash.c:259) ==3112== by 0x5ABBB5: nssCertificateStore_FindOrAdd (pkistore.c:192) ==3112== by 0x5A7C73: NSSCryptoContext_FindOrImportCertificate (cryptocontext.c:146) ==3112== by 0x5A26EF: CERT_NewTempCertificate (stanpcertdb.c:471) ==3112== by 0xC89610: ssl3_HandleHandshakeMessage (ssl3con.c:7848) ==3112== by 0xC8A904: ssl3_HandleRecord (ssl3con.c:8725) ==3112== by 0xC8B471: ssl3_GatherCompleteHandshake (ssl3gthr.c:209) ==3112== by 0xC8E0EB: ssl_GatherRecord1stHandshake (sslcon.c:1258) ==3112== by 0xC94C54: ssl_Do1stHandshake (sslsecur.c:151) ==3112== by 0xC96576: SSL_ForceHandshake (sslsecur.c:407) ==3112== by 0x404F79D: tlsm_session_accept_or_connect (tls_m.c:2350) ==3112== by 0x404DEDF: ldap_int_tls_connect (tls2.c:366) ==3112== by 0x404E1E1: ldap_int_tls_start (tls2.c:833) ==3112== by 0x404E36B: ldap_start_tls_s (tls2.c:939) ==3112== by 0x8052F62: tool_conn_setup (common.c:1290) ==3112== by 0x804DB80: main (ldapsearch.c:900) Is this bug about leaks in NSSCryptoContext*? (In reply to comment #16) > Is this an example of a leak we are hunting for? Yes. > Is this bug about leaks in NSSCryptoContext*? Not necessarily. (In reply to comment #17) > (In reply to comment #16) > > Is this an example of a leak we are hunting for? > > Yes. > > > Is this bug about leaks in NSSCryptoContext*? > > Not necessarily. Ok, let's reformulate it a bit - is this bug about leaks in *NSS*? Since there is still the following leak in the new version: ==5127== 32 bytes in 1 blocks are definitely lost in loss record 46 of 87 ==5127== at 0x400682F: malloc (vg_replace_malloc.c:236) ==5127== by 0xC13008: PR_Malloc (prmem.c:467) ==5127== by 0xC0FBC1: GrowStuff (prprf.c:1076) ==5127== by 0xC0F5E6: dosprintf (prprf.c:137) ==5127== by 0xC0FA81: PR_vsmprintf (prprf.c:1127) ==5127== by 0xC0FC74: PR_smprintf (prprf.c:1105) ==5127== by 0x551C85: nss_MkConfigString (nssinit.c:205) ==5127== by 0x551D7B: nss_Init (nssinit.c:597) ==5127== by 0x552AD7: NSS_InitContext (nssinit.c:800) ==5127== by 0x4052CCE: tlsm_deferred_ctx_init (tls_m.c:1600) ==5127== by 0xC18FD0: PR_CallOnceWithArg (prinit.c:832) ==5127== by 0x404FCAC: tlsm_session_new (tls_m.c:2308) ==5127== by 0x404DCFB: alloc_handle (tls2.c:296) ==5127== by 0x404DE8B: ldap_int_tls_connect (tls2.c:341) ==5127== by 0x404E111: ldap_int_tls_start (tls2.c:833) ==5127== by 0x404E29B: ldap_start_tls_s (tls2.c:939) ==5127== by 0x8052F52: tool_conn_setup (common.c:1290) ==5127== by 0x804DB80: main (ldapsearch.c:900) (In reply to comment #18) > (In reply to comment #17) > > (In reply to comment #16) > > > Is this an example of a leak we are hunting for? > > > > Yes. > > > > > Is this bug about leaks in NSSCryptoContext*? > > > > Not necessarily. > > Ok, let's reformulate it a bit - is this bug about leaks in *NSS*? no. It is only about this specific leak, about freeing the cert returned by SSL_PeerCertificate. > Since there > is still the following leak in the new version: This is a leak in NSS - please file a bug against nss for this. > ==5127== 32 bytes in 1 blocks are definitely lost in loss record 46 of 87 > ==5127== at 0x400682F: malloc (vg_replace_malloc.c:236) > ==5127== by 0xC13008: PR_Malloc (prmem.c:467) > ==5127== by 0xC0FBC1: GrowStuff (prprf.c:1076) > ==5127== by 0xC0F5E6: dosprintf (prprf.c:137) > ==5127== by 0xC0FA81: PR_vsmprintf (prprf.c:1127) > ==5127== by 0xC0FC74: PR_smprintf (prprf.c:1105) > ==5127== by 0x551C85: nss_MkConfigString (nssinit.c:205) > ==5127== by 0x551D7B: nss_Init (nssinit.c:597) > ==5127== by 0x552AD7: NSS_InitContext (nssinit.c:800) > ==5127== by 0x4052CCE: tlsm_deferred_ctx_init (tls_m.c:1600) > ==5127== by 0xC18FD0: PR_CallOnceWithArg (prinit.c:832) > ==5127== by 0x404FCAC: tlsm_session_new (tls_m.c:2308) > ==5127== by 0x404DCFB: alloc_handle (tls2.c:296) > ==5127== by 0x404DE8B: ldap_int_tls_connect (tls2.c:341) > ==5127== by 0x404E111: ldap_int_tls_start (tls2.c:833) > ==5127== by 0x404E29B: ldap_start_tls_s (tls2.c:939) > ==5127== by 0x8052F52: tool_conn_setup (common.c:1290) > ==5127== by 0x804DB80: main (ldapsearch.c:900) > This is a leak in NSS - please file a bug against nss for this.
Looks like Openldap is not calling the clear session cache function.
bob
(In reply to comment #20) > > This is a leak in NSS - please file a bug against nss for this. > > Looks like Openldap is not calling the clear session cache function. > > bob Then please open a different bug against openldap. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2011-1514.html |