-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
fix deadlock in crypto setup when it is closed while handling a message #2802
Conversation
1d92b2a
to
a44c65d
Compare
Codecov Report
@@ Coverage Diff @@
## master #2802 +/- ##
==========================================
- Coverage 86.02% 85.98% -0.04%
==========================================
Files 133 133
Lines 12063 12068 +5
==========================================
Hits 10376 10376
- Misses 1355 1360 +5
Partials 332 332
Continue to review full report at Codecov.
|
I often try to separate the concurrency bits and channel handling into a separate struct, such that it can be separately tested... however seems bit difficult here. If you could hook into |
@@ -506,11 +507,12 @@ func (h *cryptoSetup) ReadHandshakeMessage() ([]byte, error) { | |||
} else { |
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.
On line 488, is there a possibility the go func() { <-h.isReadingHandshakeMessage
gets stuck somehow?
I noticed that it doesn't have an obvious (to me) condition for shutting down on close.
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.
Good catch. That one should probably be protected by a select
statement as well.
@egonelbre Yes, that would be nice, but the way the TLS library is structured doesn't allow that. func Handshake() {
for {
msg := cryptosetup.ReadHandshakeMessage()
if err := handleMsg(msg); err != nil {
cryptosetup.SendAlert()
break
}
if handshake complete {
break
}
}
} |
a44c65d
to
9ce5426
Compare
Fixes #2737.
@egonelbre's analysis (option B) in #2737 (comment) was right.
Unfortunately, I didn't manage to write an integration test that would trigger the bug, so I'm not 100% sure that this fix actually works under all circumstances.