netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* UDPv4 port allocation problem
@ 2007-08-23  7:16 Tóth László Attila
  2007-08-23 17:04 ` Rick Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Tóth László Attila @ 2007-08-23  7:16 UTC (permalink / raw)
  To: netdev

Hello,

I noticed that it is possible that the kernel allocates the same UDP
port to an application that was used and closed immediately before the
new application got it. This means that applications that do not specify
an exact port and rely on the  kernel to allocate a port for them might
see traffic originally meant for another application.

Imagine that two applications want to resolve a name in DNS at about the
same time. The following happens:
 * first app sends out the DNS query then closes the socket without
waiting for an answer (e.g. it got interrupted by Ctrl+C)
 * second app opens an UDP socket, and gets the same port, originally
assigned to app#1, sends out the DNS query
 * DNS server responds, the response goes to app#2

DNS might not be the perfect example, but you get the idea. 
Applications do not expect to receive data on newly opened sockets, not
to mention the security implications.

TCP on the other hand increases the allocated port number for each new
socket, the same behaviour for UDP would add certain amount of time that
decreases this risk.

Is the current behaviour intended?

Regards,
Laszlo Attila Toth

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-08-25  6:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-23  7:16 UDPv4 port allocation problem Tóth László Attila
2007-08-23 17:04 ` Rick Jones
2007-08-23 18:32   ` [PATCH] udp: randomize port selection Stephen Hemminger
2007-08-25  6:10     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).