Bug 76521 - no-blocking socket can send data through non-existent local port
Summary: no-blocking socket can send data through non-existent local port
Status: NEW
Alias: None
Product: Networking
Classification: Unclassified
Component: IPV4 (show other bugs)
Hardware: All Linux
: P1 high
Assignee: Stephen Hemminger
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-20 01:21 UTC by billhong1998
Modified: 2016-02-15 20:46 UTC (History)
2 users (show)

See Also:
Kernel Version: 3.11.0-15
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Run code to reproduce the issue (1.79 KB, application/x-gzip)
2014-05-20 01:21 UTC, billhong1998
Details
2nd version bug report source code, 'gcc -o findbug findbug.c' and run it (4.57 KB, text/plain)
2014-06-06 02:32 UTC, billhong1998
Details
final version (2.17 KB, text/plain)
2014-06-09 04:42 UTC, billhong1998
Details

Description billhong1998 2014-05-20 01:21:11 UTC
Created attachment 136811 [details]
Run code to reproduce the issue

The attached code is a epoll network client supposed to test a network server in high traffic case. Multiple threads create non-blocking sockets to simulate heavy network load. Most sockets work well, but occasionally some sockets can send data via non-existent local port, and can read data from the port as well. Maybe I am not acquainted enough with epoll networking programming, and even not sure if it is a bug in no-blocking i/o or epoll, and also not certain which websites are the right place to discuss epoll or no-blocking i/o technologies.  

Anyone has any ideas would be greatly appreciated. Thanks.
Comment 1 Eric Dumazet 2014-05-20 22:50:12 UTC
What guarantee do you have port 8888 is not used ?

If you change 8888 to say 777 (notice its not 7777, but 777),
is the 'bug' happening ?

This looks like SYN crossing, which is allowed by TCP protocol.
Comment 2 billhong1998 2014-06-06 02:32:56 UTC
Created attachment 138331 [details]
2nd version bug report source code, 'gcc -o findbug findbug.c' and run it

The attached code(findbug.c) is an improved version. Local host ip address and port can be designated, for example ./findbug 127.0.0.1 777

And there is another question: The code will stop accepting event eventually after a long while. Is there a punitive algorithm in the case?
Comment 3 billhong1998 2014-06-09 04:40:50 UTC
(In reply to Eric Dumazet from comment #1)
> What guarantee do you have port 8888 is not used ?
> 
> If you change 8888 to say 777 (notice its not 7777, but 777),
> is the 'bug' happening ?
> 
> This looks like SYN crossing, which is allowed by TCP protocol.

Eric, thank you for providing the right direction helping me find the eventual problem. It does not matter to non-blocking io and epoll. It just a weird thing, which probably does not threaten system security, but in some cases, it could hinder some people like me to write right code. Maybe I have to remember not to use the same socket number which services used since I could not guarantee my code not running in the case of connecting local listening port.
Comment 4 billhong1998 2014-06-09 04:42:36 UTC
Created attachment 138551 [details]
final version

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