Bug 1724416

Summary: [ncat] no output when sctp, but tcp/udp has
Product: Red Hat Enterprise Linux 7 Reporter: yiche <yiche>
Component: nmapAssignee: Pavel Zhukov <pzhukov>
Status: CLOSED WONTFIX QA Contact: qe-baseos-daemons
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.6CC: jiji, pzhukov, thozza
Target Milestone: rcKeywords: Reproducer, TestCaseNeeded
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1784751 (view as bug list) Environment:
Last Closed: 2020-01-09 12:23:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description yiche 2019-06-27 03:54:16 UTC
Description of problem:
In this format:  
echo ncat --sctp -l 127.0.0.1 | bash
ncat no output for sctp, but tcp/udp has

Version-Release number of selected component (if applicable):
nmap-ncat-7.70-4.el8.x86_64
nmap-ncat-6.40-19.el7.x86_64
Both exists on RHEL7 and RHEL8

How reproducible:
always

Steps to Reproduce:
1.
# echo ncat -l 127.0.0.1 2000 |bash
abc
# echo ncat -u -l 127.0.0.1 2000 |bash
abc
# echo ncat --sctp -l 127.0.0.1 2000 |bash
#
Get nothing here!

2.
At another terminal
# ncat  127.0.0.1 2000 <<<'abc'
# ncat -u 127.0.0.1 2000 <<<'abc'
# ncat --sctp 127.0.0.1 2000 <<<'abc'

3.

Actual results:
# echo ncat --sctp -l 127.0.0.1 2000 |bash
This command returned but has no ouput.

Expected results:
ncat --sctp work as expected.

Additional info:
This issue affect our test script. Please fix it.

Comment 4 Pavel Zhukov 2019-07-31 11:54:24 UTC
This is not a bug in ncat.
Ncat adds stdin to select() and wait for ready FDs. In your case select() returns with [1a]
while "normal" execution doesn't return STDIN as ready [1b]

Thus ncat sees 0 input and returns [2]
This was done to properly handle protocols which don't support half-closed sockets like sctp [3]

I'd suggest to adjust your script not to proxy ncat input or redirect /dev/full to stdin
[1a]

[pid  3252] select(5, [0<pipe:[39940975]> 4<socket:[39941357]>], [], NULL, NULL) = 1 (in [0])
[pid  3252] read(0<pipe:[39940975]>, "", 8192) = 0
[1b]
select(5, [0 4], [], NULL, NULL)        = 1 (in [4])
recvfrom(4, "abc\n", 8192, 0, NULL, NULL) = 4
write(1, "abc\n", 4abc
)                    = 4
select(5, [0 4], [], NULL, NULL)        = 1 (in [4])
recvfrom(4, "", 8192, 0, NULL, NULL)    = 0
close(4)                                = 0
exit_group(0)                           = ?
+++ exited with 0 +++

[2]             } else if (i == STDIN_FILENO) {
                    /* Read from stdin and write to all clients. */
                    rc = read_stdin();
                    if (rc == 0) {
                        if (o.proto != IPPROTO_TCP || (o.proto == IPPROTO_TCP && o.sendonly)) {
                            /* There will be nothing more to send. If we're not
                               receiving anything, we can quit here. */
                            return 0;
                        }
                        if (!o.noshutdown) shutdown_sockets(SHUT_WR);
                   

[3]
https://github.com/nmap/nmap/commit/811d6096e1e7f2380c7ab3a4ae098a8f997c81b7

Comment 5 Pavel Zhukov 2019-07-31 13:27:23 UTC
I thought about the issue a bit more and looks there's room for improvement at least
Will send patch upstream for review

Comment 8 Tomáš Hozza 2020-01-09 12:22:19 UTC
Red Hat Enterprise Linux version 7 entered the Maintenance Support 1 phase in August 2019. In this phase only qualified Critical and Important Security errata advisories (RHSAs) and Urgent Priority Bug Fix errata advisories (RHBAs) may be released as they become available. Other errata advisories may be delivered as appropriate.

This bug has been reviewed by Support and Engineering representative and does not meet the inclusion criteria for Maintenance Support 1 phase. If this issue still exists in newer major version of Red Hat Enterprise Linux, it has been cloned there and work will continue in the cloned bug.

For more information about Red Hat Enterprise Linux Lifecycle, please see https://access.redhat.com/support/policy/updates/errata#Maintenance_Support_1_Phase.

Comment 9 RHEL Program Management 2020-01-09 12:23:13 UTC
Development Management has reviewed and declined this request. You may appeal this decision by using your Red Hat support channels, who will make certain  the issue receives the proper prioritization with product and development management.

https://www.redhat.com/support/process/production/#howto