ssh: drop unexpected message types in channel.handlePacket#355
ssh: drop unexpected message types in channel.handlePacket#355adilburaksen wants to merge 1 commit into
Conversation
|
This PR (HEAD: 2716b0f) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/crypto/+/788740. Important tips:
|
(*channel).handlePacket handles the channel response and request messages explicitly and falls back to `ch.msg <- msg` in the default arm for every other decoded type. Nothing ever reads those types from ch.msg: it is only consumed by SendRequest (channelRequestSuccess/Failure) and the channel-open wait (channelOpenConfirm/Failure), all handled in explicit cases above. A peer can route any decode()-able message (for example a service-request or ext-info packet) to an existing channel id; it falls through to the default arm and is queued to the bounded ch.msg. On an open, idle channel nothing drains ch.msg, so after chanSize such messages the blocking send in the default arm stalls the single mux read loop for the whole connection (the mux/readLoop goroutines leak; closing the connection does not release them). When a SendRequest is in flight, the queued messages instead corrupt its response handling. This is the same primitive that was addressed for the unexpected-response case (the fix for the deadlock on unexpected channel responses), which moved channelRequestSuccess/Failure out of the default arm into a gated, non-blocking case but left the default arm unchanged. Since no consumer awaits any default-arm type, ignore them instead of queuing to ch.msg. Adds a regression test (TestChannelUnexpectedDefaultMessagesDiscarded) that floods a channel with default-arm messages and confirms the channel and mux loop remain usable; it fails without the fix. go test ./ssh/... passes. Updates golang/go#79564
2716b0f to
df564be
Compare
|
Message from Gopher Robot: Patch Set 1: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/788740. |
|
Message from Adil Burak ŞEN: Patch Set 1: (1 comment) Done. Addressed both points in the updated PR: the commit message body is now wrapped at ~76 characters, and added Please don’t reply on this GitHub thread. Visit golang.org/cl/788740. |
|
This PR (HEAD: df564be) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/crypto/+/788740. Important tips:
|
|
Message from Nicola Murino: Patch Set 2: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/788740. |
|
Message from Adil Burak ŞEN: Patch Set 2: Thanks for confirming. Happy to leave the regression test (TestChannelUnexpectedDefaultMessagesDiscarded) here if it's useful for your fix; otherwise feel free to close this CL in favour of yours. Glad the default-arm sibling is being addressed. Please don’t reply on this GitHub thread. Visit golang.org/cl/788740. |
(*channel).handlePacket handles the channel response and request messages
explicitly and falls back to
ch.msg <- msgin the default arm for everyother decoded type. Nothing ever reads those types from ch.msg: it is only
consumed by SendRequest (channelRequestSuccess/Failure) and the channel-open
wait (channelOpenConfirm/Failure), all handled in explicit cases above.
A peer can route any decode()-able message (for example a service-request or
ext-info packet) to an existing channel id; it falls through to the default
arm and is queued to the bounded ch.msg. On an open, idle channel nothing
drains ch.msg, so after chanSize such messages the blocking send in the
default arm stalls the single mux read loop for the whole connection (the
mux/readLoop goroutines leak; closing the connection does not release them).
When a SendRequest is in flight, the queued messages instead corrupt its
response handling.
This is the same primitive that was addressed for the unexpected-response
case (the fix for the deadlock on unexpected channel responses), which moved
channelRequestSuccess/Failure out of the default arm into a gated,
non-blocking case but left the default arm unchanged. Since no consumer
awaits any default-arm type, ignore them instead of queuing to ch.msg.
Adds a regression test (TestChannelUnexpectedDefaultMessagesDiscarded) that
floods a channel with default-arm messages and confirms the channel and mux
loop remain usable; it fails without the fix. go test ./ssh/... passes.
Updates golang/go#79564