-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug 5390: Non-POD SquidConfig::ssl_client::sslContext exit crash #273
base: master
Are you sure you want to change the base?
Conversation
Squid may crash when SquidConfig global destruction is initiated by exit() handlers. The problem is that when its non-POD ssl_client::sslContext field is destructed and and SSL_CTX_free() cleanup starts, some of the required SSL environment may be already unavailable. Now we avoid these problems by allocating ssl_client::sslContext dynamically and ensuring that its destructor never starts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one minor adjustment, thank you!
src/SquidConfig.h
Outdated
@@ -505,7 +505,7 @@ class SquidConfig | |||
struct { | |||
Security::FuturePeerContext *defaultPeerContext; | |||
// TODO: Remove when FuturePeerContext above becomes PeerContext | |||
Security::ContextPointer sslContext; | |||
Security::ContextPointer *sslContext; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that this field only shows up in construction/destruction code diff. Let's confirm and ban its use elsewhere:
Security::ContextPointer *sslContext; | |
/// \deprecated Legacy storage. Use defaultPeerContext instead. | |
Security::ContextPointer *sslContext_; |
... and then adjust the rest of PR code to compile, of course.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (dc66a68).
src/cache_cf.cc
Outdated
@@ -968,9 +970,9 @@ configDoConfigure(void) | |||
#endif | |||
} | |||
#if USE_OPENSSL | |||
Ssl::useSquidUntrusted(Config.ssl_client.sslContext.get()); | |||
Ssl::useSquidUntrusted(Config.ssl_client.sslContext->get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically, this code should be using defaultPeerContext.raw instead, but defaultPeerContext is initialized later. I suggest using the deprecated field here unless others insist on reordering a few lines of code to use defaultPeerContext for this useSquidUntrusted() call:
Ssl::useSquidUntrusted(Config.ssl_client.sslContext->get()); | |
Ssl::useSquidUntrusted(Config.ssl_client.sslContext_->get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (dc66a68).
Squid may crash when the SquidConfig global is auto-destructed after
main() ends. Since SquidConfig global is used by cleanup code, we should
keep its fields alive, essentially emulating "No New Globals" policy
effects. This surgical fix will be followed up with more changes to
address general OpenSSL cleanup problems exposed by this bug.
This bug fix facilitates backporting by using FuturePeerContext shim.