From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Jonas Berlin <xkr47@outerspace.dyndns.org>
Cc: Netfilter Development Mailinglist
<netfilter-devel@lists.netfilter.org>,
Patrick McHardy <kaber@trash.net>
Subject: Re: PANIC: divide by zero in xt_connbytes
Date: Thu, 18 Jan 2007 14:28:55 +0100 [thread overview]
Message-ID: <45AF7617.8010202@netfilter.org> (raw)
In-Reply-To: <45AF5318.8040204@outerspace.dyndns.org>
Jonas Berlin wrote:
> Hidden asked me (on irc) to bring your attention to this bug:
>
> ~ http://bugzilla.netfilter.org/bugzilla/show_bug.cgi?id=533
Copied from your patch available on bugzilla:
> diff -ur linux-2.6.19/net/netfilter/xt_connbytes.c linux-2.6.19-xt_connbytes_fix/net/netfilter/xt_connbytes.c
> --- linux-2.6.19/net/netfilter/xt_connbytes.c 2007-01-11 20:01:51.000000000 +0200
> +++ linux-2.6.19-xt_connbytes_fix/net/netfilter/xt_connbytes.c 2007-01-18 12:15:50.000000000 +0200
> @@ -89,26 +89,39 @@
> case XT_CONNBYTES_AVGPKT:
> switch (sinfo->direction) {
> case XT_CONNBYTES_DIR_ORIGINAL:
> - what = div64_64(counters[IP_CT_DIR_ORIGINAL].bytes,
> - counters[IP_CT_DIR_ORIGINAL].packets);
Better check that divisor must be != 0 inside div64_64.
> + if (counters[IP_CT_DIR_ORIGINAL].packets == 0) {
> + what = 0;
> + } else {
> + what = div64_64(counters[IP_CT_DIR_ORIGINAL].bytes,
> + counters[IP_CT_DIR_ORIGINAL].packets);
> + }
> break;
> case XT_CONNBYTES_DIR_REPLY:
> - what = div64_64(counters[IP_CT_DIR_REPLY].bytes,
> - counters[IP_CT_DIR_REPLY].packets);
> + if (counters[IP_CT_DIR_REPLY].packets == 0) {
> + what = 0;
> + } else {
> + what = div64_64(counters[IP_CT_DIR_REPLY].bytes,
> + counters[IP_CT_DIR_REPLY].packets);
> + }
> break;
> case XT_CONNBYTES_DIR_BOTH:
> {
> - u_int64_t bytes;
> u_int64_t pkts;
> - bytes = counters[IP_CT_DIR_ORIGINAL].bytes +
> - counters[IP_CT_DIR_REPLY].bytes;
> pkts = counters[IP_CT_DIR_ORIGINAL].packets+
> counters[IP_CT_DIR_REPLY].packets;
>
> - /* FIXME_THEORETICAL: what to do if sum
> - * overflows ? */
> + if (pkts == 0) {
> + what = 0;
> + } else {
> + u_int64_t bytes;
> + bytes = counters[IP_CT_DIR_ORIGINAL].bytes +
> + counters[IP_CT_DIR_REPLY].bytes;
> +
> + /* FIXME_THEORETICAL: what to do if sum
> + * overflows ? */
^^^
Hm, already had this discussion: This is really hard to happen with 64
bits counters, it would take years even in a high performance network.
--
The dawn of the fourth age of Linux firewalling is coming; a time of
great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris
next prev parent reply other threads:[~2007-01-18 13:28 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-18 10:59 PANIC: divide by zero in xt_connbytes Jonas Berlin
2007-01-18 11:56 ` Bugzilla webserver misconfigured? (was: Re: PANIC: divide by zero in xt_connbytes) Maximilian Wilhelm
2007-01-19 2:43 ` Bugzilla webserver misconfigured? Jonas Berlin
2007-01-18 13:28 ` Pablo Neira Ayuso [this message]
2007-01-18 13:38 ` PANIC: divide by zero in xt_connbytes Jonas Berlin
2007-01-18 14:22 ` KOVACS Krisztian
2007-01-22 8:52 ` KOVACS Krisztian
2007-01-26 17:24 ` Patrick McHardy
2007-01-26 20:11 ` KOVACS Krisztian
2007-01-27 16:36 ` Patrick McHardy
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=45AF7617.8010202@netfilter.org \
--to=pablo@netfilter.org \
--cc=kaber@trash.net \
--cc=netfilter-devel@lists.netfilter.org \
--cc=xkr47@outerspace.dyndns.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.