Bug 2200 - ssh -W causes "getsockname failed: Bad file descriptor" errors
Summary: ssh -W causes "getsockname failed: Bad file descriptor" errors
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: 6.5p1
Hardware: All Linux
: P5 normal
Assignee: Damien Miller
URL: http://bugs.debian.org/738693
Keywords:
Depends on:
Blocks: V_6_6
  Show dependency treegraph
 
Reported: 2014-02-12 22:22 AEDT by Colin Watson
Modified: 2014-10-08 08:00 AEDT (History)
2 users (show)

See Also:


Attachments
Skip get_sock_port call for c->sock==-1 (633 bytes, patch)
2014-02-13 09:02 AEDT, Damien Miller
dtucker: ok+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Watson 2014-02-12 22:22:57 AEDT
Marco d'Itri reports in http://bugs.debian.org/738693 that "ssh -W" has started causing "getsockname failed: Bad file descriptor" errors; these are new in 6.5p1 and reported via error().  I think this was triggered by the new calls to get_sock_port from port_open_helper in https://anongit.mindrot.org/openssh.git/commit/?id=4def184; gdb shows that c->sock is -1 here.

Full -vvv output in the Debian bug; relevant-looking excerpt:

debug3: ssh_init_stdio_forwarding: server2.example.net:22
debug1: channel_connect_stdio_fwd server2.example.net:22
debug1: channel 0: new [stdio-forward]
debug2: fd 4 setting O_NONBLOCK
debug3: fd 5 is O_NONBLOCK
getsockname failed: Bad file descriptor
debug1: getpeername failed: Bad file descriptor

It looks like it still works fine, but the extra non-debug error is annoying.
Comment 1 Damien Miller 2014-02-13 09:02:22 AEDT
Created attachment 2407 [details]
Skip get_sock_port call for c->sock==-1

Thanks for the detailed report as always. This should fix it.
Comment 2 Colin Watson 2014-02-15 13:36:29 AEDT
Thanks, that indeed seems to solve the problem here.
Comment 3 Damien Miller 2014-02-16 10:05:50 AEDT
applied - thanks.
Comment 4 Damien Miller 2014-10-08 08:00:56 AEDT
Close all bugs left open from 6.6 and 6.7 releases.