Skip to content

ossl.c: make legacy locking callbacks reentrant#155

Merged
rhenium merged 2 commits intoruby:maintfrom
rhenium:ky/fix-legacy-locking-callback-relock
Sep 24, 2017
Merged

ossl.c: make legacy locking callbacks reentrant#155
rhenium merged 2 commits intoruby:maintfrom
rhenium:ky/fix-legacy-locking-callback-relock

Conversation

@rhenium
Copy link
Member

@rhenium rhenium commented Sep 24, 2017

Although it's not documented explicitly that the locking callbacks must
provide reentrant mutexes, it seems to be required.

Specifically, the session_remove_cb callback function of an SSL_CTX is
called in a critical section for CRYPTO_LOCK_SSL_CTX, which is shared
across the library. This leads, if the callback function calls another
OpenSSL function that will attempt to lock CRYPTO_LOCK_SSL_CTX, to
deadlock. SSL_CTX_free() is one example of such a function.

http://ci.rvm.jp/results/trunk@P895/64001

In preparation for making the mutexes reentrant. It is common to the
non-dynamic and the dynamic locking callbacks.
Although it's not documented explicitly that the locking callbacks must
provide reentrant mutexes, it seems to be required.

Specifically, the session_remove_cb callback function of an SSL_CTX is
called in a critical section for CRYPTO_LOCK_SSL_CTX, which is shared
across the library. This leads, if the callback function calls another
OpenSSL function that will attempt to lock CRYPTO_LOCK_SSL_CTX, to
deadlock. SSL_CTX_free() is one example of such a function.

	http://ci.rvm.jp/results/trunk@P895/64001
@rhenium rhenium merged commit 4945d36 into ruby:maint Sep 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant