netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Haley <brian.haley@hp.com>
To: Anton Arapov <aarapov@redhat.com>
Cc: David Miller <davem@davemloft.net>, netdev@vger.kernel.org
Subject: Re: [PATCH] division-by-zero in inet_csk_get_port
Date: Wed, 10 Oct 2007 11:04:12 -0400	[thread overview]
Message-ID: <470CE9EC.10008@hp.com> (raw)
In-Reply-To: <m3sl4jjfsx.fsf@bandura.englab.brq.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 331 bytes --]

Anton Arapov wrote:
>   So, now the way suggested by Denis looks reasonable.
> 
>   What do you think?

If that's the case then you should fix __udp_lib_get_port() the same way.

Prevent division by zero in __udp_lib_get_port() when only one 
unsecured port is available.

-Brian


Signed-off-by: Brian Haley <brian.haley@hp.com>


[-- Attachment #2: udp_port_range.patch --]
[-- Type: text/x-patch, Size: 614 bytes --]

diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index ef4d901..61faa38 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -150,10 +150,11 @@ int __udp_lib_get_port(struct sock *sk, unsigned short snum,
 		int i;
 		int low = sysctl_local_port_range[0];
 		int high = sysctl_local_port_range[1];
+		int remaining = (high - low) + 1;
 		unsigned rover, best, best_size_so_far;
 
 		best_size_so_far = UINT_MAX;
-		best = rover = net_random() % (high - low) + low;
+		best = rover = net_random() % remaining + low;
 
 		/* 1st pass: look for empty (or shortest) hash chain */
 		for (i = 0; i < UDP_HTABLE_SIZE; i++) {

      reply	other threads:[~2007-10-10 15:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=470CE9EC.10008@hp.com \
    --to=brian.haley@hp.com \
    --cc=aarapov@redhat.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).