[sr-dev] git:4.4:c5657b73: tls: explicit libssl v1.1+ cleanup when module is destroyed

Daniel-Constantin Mierla miconda at gmail.com
Wed Aug 2 12:56:58 CEST 2017


Module: kamailio
Branch: 4.4
Commit: c5657b7386f8be722e3d87c70b9e049d2b843c0d
URL: https://github.com/kamailio/kamailio/commit/c5657b7386f8be722e3d87c70b9e049d2b843c0d

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-08-02T12:56:03+02:00

tls: explicit libssl v1.1+ cleanup when module is destroyed

- OPENSSL_cleanup() explicitely executed for libssl v1.1+ when tls
  module is destroyed, to avoid being executed again on final exit
  (due to atexit() callback), because at that moment shared memory
  is already destroyed and attempts to access the locals will result
  in cored dump
- retported by Victor Seva, GH #1189

(cherry picked from commit 00eb71da83347c9d2ea74feacec9c955f7b2a2e6)
(cherry picked from commit 071b85f66cabaa3a705a014b26b7c1eb31029b26)

---

Modified: modules/tls/tls_init.c

---

Diff:  https://github.com/kamailio/kamailio/commit/c5657b7386f8be722e3d87c70b9e049d2b843c0d.diff
Patch: https://github.com/kamailio/kamailio/commit/c5657b7386f8be722e3d87c70b9e049d2b843c0d.patch

---

diff --git a/modules/tls/tls_init.c b/modules/tls/tls_init.c
index 133bc7fc83..1ce9d716a5 100644
--- a/modules/tls/tls_init.c
+++ b/modules/tls/tls_init.c
@@ -778,4 +778,10 @@ void destroy_tls_h(void)
 	tls_destroy_cfg();
 	tls_destroy_locks();
 	tls_ct_wq_destroy();
+#if OPENSSL_VERSION_NUMBER >= 0x010100000L
+	/* explicit execution of libssl cleanup to avoid being executed again
+	 * by atexit(), when shm is gone */
+	DBG("executing openssl v1.1+ cleanup\n");
+	OPENSSL_cleanup();
+#endif
 }




More information about the sr-dev mailing list