Bug 3454

Summary: client dies with exit code 141 (SIGPIPE) when ControlMaster times out during mux_client_hello_exchange()
Product: Portable OpenSSH Reporter: noamlewis+openssh-bugzilla
Component: sshAssignee: Damien Miller <djm>
Status: CLOSED FIXED    
Severity: normal CC: djm, dtucker
Priority: P5    
Version: 8.9p1   
Hardware: amd64   
OS: Linux   
Bug Depends on:    
Bug Blocks: 3418    
Attachments:
Description Flags
ignore SIGPIPE earlier dtucker: ok+

Description noamlewis+openssh-bugzilla 2022-06-30 04:01:23 AEST
If the client tries to start talking to a ControlMaster just as it's exiting (due to ControlPersist timeout), it will fail with exit code 141 (SIGPIPE).

To reproduce:

( while true; do \
  sleep 0.5 ; \
  gdb -ex r -ex q --args \
    ssh -o ControlMaster=auto \
        -o ControlPath=~/.ssh/elsa-ctrl-%C \
        -o ControlPersist=1 127.0.0.1 -- touch /tmp/thingy ; \
  done )


(You might need to fiddle with the sleep time)

Program received signal SIGPIPE, Broken pipe.
0x00007ffff7b38f33 in __GI___libc_write (fd=fd@entry=3, buf=buf@entry=0x55555565e060, nbytes=nbytes@entry=12) at ../sysdeps/unix/sysv/linux/write.c:26

(gdb) bt
#0  0x00007ffff7b38f33 in __GI___libc_write (fd=fd@entry=3, buf=buf@entry=0x55555565e060, nbytes=nbytes@entry=12) at ../sysdeps/unix/sysv/linux/write.c:26
#1  0x0000555555583380 in mux_client_write_packet (fd=fd@entry=3, m=m@entry=0x55555565deb0) at ../../mux.c:1513
#2  0x0000555555585944 in mux_client_hello_exchange (fd=3) at ../../mux.c:1589
#3  muxclient (path=0x55555565ba60 "/home/noamlewis/.ssh/elsa-ctrl-cfbf228b3cff12162e33cbe54c12340af8f78155") at ../../mux.c:2297
#4  0x0000555555561882 in main (ac=<optimized out>, av=<optimized out>) at ../../ssh.c:1526


Reproduces also with older clients (8.4)
Comment 1 Damien Miller 2022-06-30 14:51:06 AEST
Created attachment 3600 [details]
ignore SIGPIPE earlier

ssh.c:main() already ignores SIGPIPE, just not early enough :(
Comment 2 Damien Miller 2022-07-01 10:37:30 AEST
Patch applied and will be in OpenSSH 9.1 - thanks.
Comment 3 noamlewis+openssh-bugzilla 2022-07-05 00:32:40 AEST
Thanks for the very fast fix!
Comment 4 Damien Miller 2022-10-04 21:58:00 AEDT
Closing bugs from OpenSSH 9.1 release cycle