[pkg-opensc-commit] [libp11] 28/51: Attempted workaround for an engine code deadlock

Eric Dorland eric at moszumanska.debian.org
Wed Dec 7 17:51:32 UTC 2016


This is an automated email from the git hooks/post-receive script.

eric pushed a commit to branch master
in repository libp11.

commit 32daa599d3b83d29e2fa1be9531e3aee077aaf7c
Author: Michał Trojnara <Michal.Trojnara at stunnel.org>
Date:   Wed Oct 26 22:14:07 2016 +0200

    Attempted workaround for an engine code deadlock
    
    See #123 for details
---
 src/eng_back.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/eng_back.c b/src/eng_back.c
index 45d8b5f..3b2cd42 100644
--- a/src/eng_back.c
+++ b/src/eng_back.c
@@ -165,6 +165,13 @@ int pkcs11_destroy(ENGINE_CTX *ctx)
 {
 	if (ctx) {
 		pkcs11_finish(ctx);
+		if (ctx->pkcs11_ctx) {
+			/* Modules cannot be unloaded in pkcs11_finish()
+			 * because of a deadlock in PKCS#11 modules that
+			 * internally use the OpenSSL engine interface */
+			PKCS11_CTX_unload(ctx->pkcs11_ctx);
+			PKCS11_CTX_free(ctx->pkcs11_ctx);
+		}
 		destroy_pin(ctx);
 		OPENSSL_free(ctx->module);
 		OPENSSL_free(ctx->init_args);
@@ -269,11 +276,6 @@ int pkcs11_finish(ENGINE_CTX *ctx)
 			ctx->slot_list = NULL;
 			ctx->slot_count = 0;
 		}
-		if (ctx->pkcs11_ctx) {
-			PKCS11_CTX_unload(ctx->pkcs11_ctx);
-			PKCS11_CTX_free(ctx->pkcs11_ctx);
-			ctx->pkcs11_ctx = NULL;
-		}
 	}
 	return 1;
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opensc/libp11.git



More information about the pkg-opensc-commit mailing list