Mailing List Archive

[Bug 3067] New: Fails to unlink ControlMaster socket early enough, confuses other clients

Bug ID: 3067
Summary: Fails to unlink ControlMaster socket early enough,
confuses other clients
Product: Portable OpenSSH
Version: 7.9p1
Hardware: Other
OS: Linux
Status: NEW
Severity: normal
Priority: P5
Component: ssh


TL;DR: ssh(1) must unlink local socket _before_ attempting more network
traffic otherwise broken TCP sockets will stall the entire thing.


I make heavy use of the shared control sockets to multiplex multiple
shells, sftp, and other commands down a single TCP connection to remote

ControlPath ~/var/run/ssh-master-%r@%h:%p.sock
ControlPersist 1s
ControlMaster auto

In this setup, under stable networking all works nicely.

However, my machine is a laptop, and sometimes due to mobile data,
ethernet cable swapping, or other issues my IP address and hence
change. After such a change, all existing TCP sockets are now unuseable
and must be closed and reopened.

Simply closing all ssh clients is insufficient here, because the client
tries to perform a controlled shutdown of the TCP socket *first* and
will only unlink(2) the control master socket from the local filesystem
after it has done this. By ordering the operations thus, the client
stalls trying to perform this controlled TCP shutdown over now-invalid
networking, and never gets around to removing the local unix socket.
ssh clients would try to use this and similarly stall.

The correct order of operation ought to be that the control master
socket is unlinked *before* trying to send any traffic, thus restoring
the user's "turn it off and on again" approach to fixing the problem -
namely by just killing all their clients and making a new one.


Additionally I should add; a workaround for this is to simply

$ rm ~/var/run/ssh-master-*.sock

after closing the previous master clients, before starting them up
afresh. The lack of existing unix socket causes the first one to take
master control again and all resumes fine.

You are receiving this mail because:
You are watching the assignee of the bug.
openssh-bugs mailing list