netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] division-by-zero in inet_csk_get_port
@ 2007-10-10  8:55 Denis V. Lunev
  2007-10-10  9:00 ` Anton Arapov
  0 siblings, 1 reply; 7+ messages in thread
From: Denis V. Lunev @ 2007-10-10  8:55 UTC (permalink / raw)
  To: netdev; +Cc: aarapov, dev, den

This patch fixed a possible division-by-zero in inet_csk_get_port
treating situation low > high as if low == high.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Antov Arapov  <aarapov@redhat.com>

--- ./net/ipv4/inet_connection_sock.c.getport	2007-10-09 15:16:02.000000000 +0400
+++ ./net/ipv4/inet_connection_sock.c	2007-10-10 12:44:04.000000000 +0400
@@ -80,7 +80,14 @@ int inet_csk_get_port(struct inet_hashin
 		int low = sysctl_local_port_range[0];
 		int high = sysctl_local_port_range[1];
 		int remaining = (high - low) + 1;
-		int rover = net_random() % (high - low) + low;
+		int rover;
+
+		/* Treat low > high as high == low */
+		if (remaining <= 1) {
+			remaining = 1;
+			rover = low;
+		} else
+			rover = net_random() % (high - low) + low;
 
 		do {
 			head = &hashinfo->bhash[inet_bhashfn(rover, hashinfo->bhash_size)];

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

end of thread, other threads:[~2007-10-10 15:04 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-10  8:55 [PATCH] division-by-zero in inet_csk_get_port Denis V. Lunev
2007-10-10  9:00 ` Anton Arapov
2007-10-10  9:35   ` David Miller
2007-10-10  9:56     ` Anton Arapov
2007-10-10 10:01       ` David Miller
2007-10-10 12:49         ` Anton Arapov
2007-10-10 15:04           ` Brian Haley

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).