Skip to content

Conversation

@tiran
Copy link
Member

@tiran tiran commented Mar 21, 2021

OpenSSL copies the internal message callback from SSL_CTX->msg_callback to
SSL->msg_callback. SSL_set_SSL_CTX() does not update SSL->msg_callback
to use the callback value of the new context.

PySSL_set_context() now resets the callback and _PySSL_msg_callback()
resets thread state in error path.

Signed-off-by: Christian Heimes christian@python.org

https://bugs.python.org/issue43577

@tiran tiran changed the title Fix deadlock with SSLContext._msg_callback and sni_callback bpo-43577: Fix deadlock with SSLContext._msg_callback and sni_callback Mar 21, 2021
OpenSSL copies the internal message callback from SSL_CTX->msg_callback to
SSL->msg_callback. SSL_set_SSL_CTX() does not update SSL->msg_callback
to use the callback value of the new context.

PySSL_set_context() now resets the callback and _PySSL_msg_callback()
resets thread state in error path.

Signed-off-by: Christian Heimes <christian@python.org>
@tiran tiran force-pushed the bpo-43577-ssl-deadlock branch 2 times, most recently from d550afc to 11445c4 Compare March 21, 2021 13:22
@tiran tiran changed the title bpo-43577: Fix deadlock with SSLContext._msg_callback and sni_callback bpo-43577: Fix deadlock with SSLContext._msg_callback and sni_callback (GH-24957) Mar 21, 2021
@tiran tiran merged commit 77cde50 into python:master Mar 21, 2021
@miss-islington
Copy link
Contributor

Thanks @tiran for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9.
🐍🍒⛏🤖

@tiran tiran deleted the bpo-43577-ssl-deadlock branch March 21, 2021 15:13
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 21, 2021
pythonGH-24957)

OpenSSL copies the internal message callback from SSL_CTX->msg_callback to
SSL->msg_callback. SSL_set_SSL_CTX() does not update SSL->msg_callback
to use the callback value of the new context.

PySSL_set_context() now resets the callback and _PySSL_msg_callback()
resets thread state in error path.

Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit 77cde50)

Co-authored-by: Christian Heimes <christian@python.org>
@bedevere-bot
Copy link

GH-24958 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Mar 21, 2021
pythonGH-24957)

OpenSSL copies the internal message callback from SSL_CTX->msg_callback to
SSL->msg_callback. SSL_set_SSL_CTX() does not update SSL->msg_callback
to use the callback value of the new context.

PySSL_set_context() now resets the callback and _PySSL_msg_callback()
resets thread state in error path.

Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit 77cde50)

Co-authored-by: Christian Heimes <christian@python.org>
@bedevere-bot
Copy link

GH-24959 is a backport of this pull request to the 3.8 branch.

@miss-islington
Copy link
Contributor

Thanks @tiran for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒⛏🤖

miss-islington added a commit that referenced this pull request Mar 21, 2021
GH-24957)

OpenSSL copies the internal message callback from SSL_CTX->msg_callback to
SSL->msg_callback. SSL_set_SSL_CTX() does not update SSL->msg_callback
to use the callback value of the new context.

PySSL_set_context() now resets the callback and _PySSL_msg_callback()
resets thread state in error path.

Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit 77cde50)

Co-authored-by: Christian Heimes <christian@python.org>
miss-islington added a commit that referenced this pull request Mar 21, 2021
GH-24957)

OpenSSL copies the internal message callback from SSL_CTX->msg_callback to
SSL->msg_callback. SSL_set_SSL_CTX() does not update SSL->msg_callback
to use the callback value of the new context.

PySSL_set_context() now resets the callback and _PySSL_msg_callback()
resets thread state in error path.

Signed-off-by: Christian Heimes <christian@python.org>
(cherry picked from commit 77cde50)

Co-authored-by: Christian Heimes <christian@python.org>
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.

4 participants