Bug 156835 - nc enters infinite loop when pipe closes.
nc enters infinite loop when pipe closes.
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: nc (Show other bugs)
rawhide
All Linux
medium Severity medium
: ---
: ---
Assigned To: Radek Vokal
Ben Levenson
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-05-04 12:18 EDT by David Woodhouse
Modified: 2007-11-30 17:11 EST (History)
0 users

See Also:
Fixed In Version: 1.78-2
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2005-05-11 06:41:41 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
strace of offending nc. (18.84 KB, text/plain)
2005-05-11 06:24 EDT, David Woodhouse
no flags Details

  None (edit)
Description David Woodhouse 2005-05-04 12:18:56 EDT
nc is being used as a ssh ProxyCommand. When SSH is finished with it it ought to
die gracefully. It doesn't; it ends up eating CPU...

poll([{fd=4, events=POLLIN}, {fd=0, events=POLLIN, revents=POLLHUP}], 2, -1) = 1
poll([{fd=4, events=POLLIN}, {fd=0, events=POLLIN, revents=POLLHUP}], 2, -1) = 1
poll([{fd=4, events=POLLIN}, {fd=0, events=POLLIN, revents=POLLHUP}], 2, -1) = 1
poll([{fd=4, events=POLLIN}, {fd=0, events=POLLIN, revents=POLLHUP}], 2, -1) = 1
poll([{fd=4, events=POLLIN}, {fd=0, events=POLLIN, revents=POLLHUP}], 2, -1) = 1
Comment 1 Radek Vokal 2005-05-05 06:17:27 EDT
David, may I have some steps how to reproduce this? 
Comment 2 David Woodhouse 2005-05-05 06:34:14 EDT
I'd imagine this should trigger it for you fairly easily...

cat >> ~/.ssh/config <<EOF
Host *
  ProxyCommand nc %h %p
EOF
Comment 3 David Woodhouse 2005-05-10 13:52:25 EDT
Any progress? If you added that to your SSH configuration you ought to be seeing
a lot of this now...
Comment 4 Radek Vokal 2005-05-11 06:09:59 EDT
Nope, I still don't see this. Running nc host 22 gives no errors and if I try
your steps, I see that nc is running while sshed and after closing the ssh
session nc ends corectly .. 
Comment 6 David Woodhouse 2005-05-11 06:19:27 EDT
#0  0x0ff43cb8 in poll () from /lib/libc.so.6
#1  0x10001928 in readwrite (nfd=3) at netcat.c:615
#2  0x10002278 in main (argc=Variable "argc" is not available.
) at netcat.c:375
Comment 7 David Woodhouse 2005-05-11 06:24:33 EDT
Created attachment 114240 [details]
strace of offending nc.
Comment 8 Radek Vokal 2005-05-11 06:37:13 EDT
The else branch looks really strange to me. If you're calling exec on nc, should
this create a whole new shell for nc? That's maybe why it's still open after
closing ssh session. 
Comment 9 David Woodhouse 2005-05-11 06:43:53 EDT
fsh isn't a shell. It's a faster version of ssh, which re-uses a single
authenticated connection for running multiple commands. 

The logic is "if we're within the internal network use netcat, else ssh to the
bastion host and run netcat there". It's the former case which is failing. 

I don't actually know why it's not 'exec nc' in the first case, which does also
work around the problem -- but fixing netcat to react appropriately to POLLHUP
is also appropriate. 

Note You need to log in before you can comment on or make changes to this bug.