Thomas Wolf created SSHD-1158: --------------------------------- Summary: Channel closed by peer: extra SSH_MSG_CHANNEL_EOF sent Key: SSHD-1158 URL: https://issues.apache.org/jira/browse/SSHD-1158 Project: MINA SSHD Issue Type: Bug Affects Versions: 2.6.0, 2.7.0 Reporter: Thomas Wolf
I observe the following: {code:java} 2021-04-30 17:03:39 DEBUG sshd-JGitSshClient[7c440ee8]-nio2-thread-3 ChannelExec:528 - handleClose(ChannelExec[id=0, recipient=0]-JGitClientSession[g...@bitbucket.org/104.192.141.1:22]) SSH_MSG_CHANNEL_CLOSE 2021-04-30 17:03:39 DEBUG sshd-JGitSshClient[7c440ee8]-nio2-thread-3 ChannelExec:533 - handleClose(ChannelExec[id=0, recipient=0]-JGitClientSession[g...@bitbucket.org/104.192.141.1:22]) prevent sending EOF 2021-04-30 17:03:39 DEBUG sshd-JGitSshClient[7c440ee8]-nio2-thread-3 ChannelExec:107 - close(ChannelExec[id=0, recipient=0]-JGitClientSession[g...@bitbucket.org/104.192.141.1:22]) Closing gracefully 2021-04-30 17:03:39 DEBUG sshd-JGitSshClient[7c440ee8]-nio2-thread-3 ChannelExec:666 - close(ChannelExec[id=0, recipient=0]-JGitClientSession[g...@bitbucket.org/104.192.141.1:22]) prevent sending EOF 2021-04-30 17:03:39 DEBUG sshd-JGitSshClient[7c440ee8]-nio2-thread-3 Window:356 - Closing Window[client/local](ChannelExec[id=0, recipient=0]-JGitClientSession[g...@bitbucket.org/104.192.141.1:22]) 2021-04-30 17:03:39 DEBUG sshd-JGitSshClient[7c440ee8]-nio2-thread-3 Window:356 - Closing Window[client/remote](ChannelExec[id=0, recipient=0]-JGitClientSession[g...@bitbucket.org/104.192.141.1:22]) 2021-04-30 17:03:39 DEBUG sshd-JGitSshClient[7c440ee8]-nio2-thread-3 ChannelExec:901 - sendEof(ChannelExec[id=0, recipient=0]-JGitClientSession[g...@bitbucket.org/104.192.141.1:22]) SSH_MSG_CHANNEL_EOF (state=Graceful) 2021-04-30 17:03:39 DEBUG sshd-JGitSshClient[7c440ee8]-nio2-thread-3 JGitClientSession:1215 - encode(JGitClientSession[g...@bitbucket.org/104.192.141.1:22]) packet #14 sending command=96[SSH_MSG_CHANNEL_EOF] len=5 2021-04-30 17:03:39 DEBUG sshd-JGitSshClient[7c440ee8]-nio2-thread-3 Nio2Session:171 - writeBuffer(Nio2Session[local=/192.168.2.83:58913, remote=bitbucket.org/104.192.141.1:22]) writing 68 bytes 2021-04-30 17:03:39 DEBUG sshd-JGitSshClient[7c440ee8]-nio2-thread-3 AbstractChannel$GracefulChannelCloseable:594 - close(ChannelExec[id=0, recipient=0]-JGitClientSession[g...@bitbucket.org/104.192.141.1:22])[immediately=false] processing 2021-04-30 17:03:39 DEBUG sshd-JGitSshClient[7c440ee8]-nio2-thread-3 AbstractChannel$GracefulChannelCloseable:602 - close(ChannelExec[id=0, recipient=0]-JGitClientSession[g...@bitbucket.org/104.192.141.1:22])[immediately=false] send SSH_MSG_CHANNEL_CLOSE 2021-04-30 17:03:39 DEBUG sshd-JGitSshClient[7c440ee8]-nio2-thread-3 JGitClientSession:1215 - encode(JGitClientSession[g...@bitbucket.org/104.192.141.1:22]) packet #15 sending command=97[SSH_MSG_CHANNEL_CLOSE] len=5 2021-04-30 17:03:39 DEBUG sshd-JGitSshClient[7c440ee8]-nio2-thread-3 Nio2Session:171 - writeBuffer(Nio2Session[local=/192.168.2.83:58913, remote=bitbucket.org/104.192.141.1:22]) writing 68 bytes {code} * Client receives a SSH_MSG_CHANNEL_CLOSE from the server * Client logs (twice) is wouldn't send an EOF * Client sends SSH_MSG_CHANNEL_EOF all the same * Client sends SSH_MSG_CHANNEL_CLOSE In my reading of [RFC 4254, section 5.3|https://tools.ietf.org/html/rfc4254#section-5.3], this is wrong; the RFC says: {quote}Upon receiving this message, a party *MUST* send back an SSH_MSG_CHANNEL_CLOSE unless it has already sent this message for the channel. [...] A party MAY send SSH_MSG_CHANNEL_CLOSE without having sent or received SSH_MSG_CHANNEL_EOF. {quote} I take this to mean that on reception of a CLOSE one needs to reply CLOSE, not EOF followed by CLOSE. IMO {{AbstractChannel.handleClose()}} should not call {{isEofSent()}} but use {{eofSent.getAndSet(true)}} instead to really prevent sending the EOF. That code got changed in SSHD-836 (commit [bba23bf70|https://github.com/apache/mina-sshd/commit/bba23bf70bcd7e4d5a972806a9df62669e7cda81#diff-e9d125fde1660adf395b423e4e0831b4ad9092ddf73fe8285a9706fa4b74d030R540]). What was the reason for that? [~gnodet], do you remember? -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org For additional commands, e-mail: dev-h...@mina.apache.org