[Bug 3971] Race condition when using ControlMaster=auto with simultaneous connections

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Sat Jun 27 17:16:34 AEST 2026


https://bugzilla.mindrot.org/show_bug.cgi?id=3971

--- Comment #4 from Jens Rosenboom <jens.rosenboom at web.de> ---
(In reply to Baptiste Jonglez from comment #3)
> Thanks for opening the bug report, I'm happy to see somebody else
> had the same issue.

You're welcome :)
Yes, I had the same issue. (A somehow related report is even from 2007:
https://lists.debian.org/debian-ssh/2007/12/msg00019.html )

[...]
> However, what happens if the first process binds the control socket
> and then hangs while establishing the SSH connection? Or if it
> outright fails to connect to the remote server for some reason?
> Would the other processes be able to recover from that?

I tested this and IMHO it works fine:

The first ssh process creates the control socket and then waits for the
TCP connection to the target server. (Target server was reachable, but
did not serve TCP port 1234 and did not send ICMP message about that,
so the TCP connection time-out applied.)
The second ssh process connects to the control socket, and waits after
its hello message.
After two minutes the first process gets a TCP connection time-out and
closes (and deletes) the control socket again (and terminates).
Then the second process sees the control socket breaking and tries a
direct connection on its own (which also fails after another 2
minutes).

Log of first ssh process (NB: with user and server names anonymized):
--
$ ssh -vvv example.org -p 1234
debug1: OpenSSH_10.3p1, OpenSSL 3.5.7 9 Jun 2026
debug3: Running on Linux 7.0.12-201.fc44.x86_64 #1 SMP PREEMPT_DYNAMIC
Thu Jun 11 01:30:16 UTC 2026 x86_64
debug3: Started with: ssh -vvv example.org -p 1234
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 15: Applying options for
example.org
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' ->
'/home/user/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' ->
'/home/user/.ssh/known_hosts2'
debug1: trying to set-up a multiplex master socket
debug3: muxserver: temporary control path
/tmp/ssh_mux_example.org_1234_user.wzL3Owpafm6S5rYh
debug2: fd 3 setting O_NONBLOCK
debug1: We will be multiplex master, not client.
debug2: resolving "example.org" port 1234
debug3: resolve_host: lookup example.org:1234
debug3: channel_clear_timeouts: clearing
debug3: ssh_connect_direct: entering
debug1: Connecting to example.org [xxx.xxx.xxx.xxx] port 1234.
debug3: set_sock_tos: set socket 4 IP_TOS 0xb8
debug1: connect to address xxx.xxx.xxx.xxx port 1234: Connection timed
out
ssh: connect to host example.org port 1234: Connection timed out
$
--

Log of second ssh process:
--
$ ssh -vvv example.org -p 1234
debug1: OpenSSH_10.3p1, OpenSSL 3.5.7 9 Jun 2026
debug3: Running on Linux 7.0.12-201.fc44.x86_64 #1 SMP PREEMPT_DYNAMIC
Thu Jun 11 01:30:16 UTC 2026 x86_64
debug3: Started with: ssh -vvv example.org -p 1234
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 15: Applying options for
example.org
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' ->
'/home/user/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' ->
'/home/user/.ssh/known_hosts2'
debug1: trying to set-up a multiplex master socket
debug3: muxserver: temporary control path
/tmp/ssh_mux_example.org_1234_user.c7OEs9YW8jdrvKBA
debug2: fd 3 setting O_NONBLOCK
debug1: ControlSocket /tmp/ssh_mux_example.org_1234_user already exists
debug1: auto-mux: Trying existing master at
'/tmp/ssh_mux_example.org_1234_user'
debug2: fd 3 setting O_NONBLOCK
debug1: mux_client_hello_exchange: read packet failed
muxclient: master hello exchange failed
debug2: resolving "example.org" port 1234
debug3: resolve_host: lookup example.org:1234
debug3: channel_clear_timeouts: clearing
debug3: ssh_connect_direct: entering
debug1: Connecting to example.org [xxx.xxx.xxx.xxx] port 1234.
debug3: set_sock_tos: set socket 3 IP_TOS 0xb8
debug1: connect to address xxx.xxx.xxx.xxx port 1234: Connection timed
out
ssh: connect to host example.org port 1234: Connection timed out
$
--

-- 
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list