Bug 1907718

Summary: Socat udp4-recvfrom cause endless loop error when target is not vaild
Product: Red Hat Enterprise Linux 7 Reporter: xuchunmei <xuchunmei>
Component: socatAssignee: Paul Wouters <pwouters>
Status: CLOSED WONTFIX QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: high Docs Contact:
Priority: medium    
Version: 7.9Keywords: Patch, Rebase, Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1914989 (view as bug list) Environment:
Last Closed: 2021-01-11 17:04:03 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:
Bug Depends On:    
Bug Blocks: 1914989    

Description xuchunmei 2020-12-15 03:49:10 UTC
My socat version is 1.7.3.2,with the following steps,socat will get endless loop error like this:
2020/12/15 11:36:13 socat[7065] E connect(6, AF=2 127.0.0.1:6667, 16): Connection refused
2020/12/15 11:36:13 socat[7066] E connect(6, AF=2 127.0.0.1:6667, 16): Connection refused
2020/12/15 11:36:13 socat[7067] E connect(6, AF=2 127.0.0.1:6667, 16): Connection refused
2020/12/15 11:36:13 socat[7068] E connect(6, AF=2 127.0.0.1:6667, 16): Connection refused
2020/12/15 11:36:13 socat[7069] E connect(6, AF=2 127.0.0.1:6667, 16): Connection refused
2020/12/15 11:36:13 socat[7070] E connect(6, AF=2 127.0.0.1:6667, 16): Connection refused
2020/12/15 11:36:13 socat[7071] E connect(6, AF=2 127.0.0.1:6667, 16): Connection refused
2020/12/15 11:36:13 socat[7072] E connect(6, AF=2 127.0.0.1:6667, 16): Connection refused
2020/12/15 11:36:13 socat[7073] E connect(6, AF=2 127.0.0.1:6667, 16): Connection refused

Steps to reproduce:
1. setup ssh tunnel:
ssh -NfL 6667:192.168.122.23:6667 192.168.122.23
2. setup socket udp to tcp:
socat -T15 udp4-recvfrom:8888,reuseaddr,fork tcp:127.0.0.1:6667
3.  Kill ssh process to produce target address invalid
4. Send a udp packet to 127.0.0.1:8888



With -d -d -d -d options to debug socat, the endless loop is caused by select always return true, and recvmsg can always read data. 


2020/12/15 11:27:43 socat[4346] N receiving on AF=2 0.0.0.0:8888
2020/12/15 11:27:43 socat[4346] D select(6, &0x20, &0x0, &0x0, NULL/0.000000)
2020/12/15 11:27:43 socat[4346] D select -> (, 0x20, 0x0, 0x0, NULL/0.000000), 1
2020/12/15 11:27:43 socat[4346] D recvmsg(5, 0x7ffdeff59140{0x7ffdeff59180,112,0x7ffdeff590b0,1,0x7ffdeff59800,1024,0}, 34)
2020/12/15 11:27:43 socat[4346] D recvmsg(, {AF=2 127.0.0.1:0,16,,1,,0,}, ) -> 4


Expected results:
only print error once

Comment 3 Paul Wouters 2021-01-11 17:04:03 UTC
This issue was not selected to be included in Red Hat Enterprise Linux 7 because it is seen either as low or moderate impact to a small number of use-cases. The current release is in Maintenance Support 1 Phase, which means that qualified Critical and Important Security errata advisories (RHSAs) and Urgent Priority Bug Fix errata advisories (RHBAs) may be released as they become available. We are deferring this issue to Red Hat Enterprise Linux 8, but if you believe that it qualifies for the Maintenance Support 1 Phase, please re-open.

Comment 4 xuchunmei 2021-01-12 01:31:05 UTC
(In reply to Paul Wouters from comment #3)
> This issue was not selected to be included in Red Hat Enterprise Linux 7
> because it is seen either as low or moderate impact to a small number of
> use-cases. The current release is in Maintenance Support 1 Phase, which
> means that qualified Critical and Important Security errata advisories
> (RHSAs) and Urgent Priority Bug Fix errata advisories (RHBAs) may be
> released as they become available. We are deferring this issue to Red Hat
> Enterprise Linux 8, but if you believe that it qualifies for the Maintenance
> Support 1 Phase, please re-open.

Thanks, actually, the recent socat release version has fix this problem, related commit is https://repo.or.cz/socat.git/commitdiff/ff8de6c5cd4e380d7867f5fdeda15098cb55514d?spm=a2o8d.corp_prod_issue_detail_v2.0.0.78f46b86aZuLQ1