From: Patrick McHardy <kaber@trash.net>
To: Pablo Neira <pablo@netfilter.org>
Cc: Harald Welte <laforge@netfilter.org>,
netfilter-devel@lists.netfilter.org,
Samir Bellabes <sbellabes@mandriva.com>,
"David S. Miller" <davem@davemloft.net>
Subject: Re: buffer overflow in ip_ct_{ftp,tftp,irc}
Date: Sat, 10 Sep 2005 00:59:49 +0200 [thread overview]
Message-ID: <432213E5.4000200@trash.net> (raw)
In-Reply-To: <431F7C38.50206@netfilter.org>
[-- Attachment #1: Type: text/plain, Size: 756 bytes --]
Pablo Neira wrote:
> Pablo Neira wrote:
>
>> Samir Bellabes wrote:
>>
>>> for (i = 0; i < ports_c; i++) {
>>> + /* don't allow bad port values */
>>> + if (ports[i] < 1 || ports[i] > 65535) {
>>> + printk(KERN_WARNING "ip_ct_ftp: ERROR port"
>>> + "should be between 1 and 65535\n");
>>> + fini();
>>> + return -EINVAL;
>>> + }
>>
>>
>>
>> Better something like this?
>
> Damn, sorry, my mail client has mangled the email, I meant:
>
> -static int ports[MAX_PORTS];
> +static short ports[MAX_PORTS];
> static int ports_c;
> -module_param_array(ports,int, &ports_c, 0400);
> +module_param_array(ports, short, &ports_c, 0400);
I agree, I've applied this patch instead. Thanks.
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 3432 bytes --]
[NETFILTER]: Use correct types for "ports" module parameter
With large port numbers the helper_names buffer can overflow.
Noticed by Samir Bellabes <sbellabes@mandriva.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit d53f0d343998b81945723c43046c4f2ee301e45b
tree 2e8a7c30c3fb32cae0eacb4231ac3554e18f6a47
parent 1d8674edb534a3c5cb549bfde5a39fa5598cb3bc
author Patrick McHardy <kaber@trash.net> Sat, 10 Sep 2005 00:58:11 +0200
committer Patrick McHardy <kaber@trash.net> Sat, 10 Sep 2005 00:58:11 +0200
net/ipv4/netfilter/ip_conntrack_ftp.c | 6 +++---
net/ipv4/netfilter/ip_conntrack_irc.c | 6 +++---
net/ipv4/netfilter/ip_conntrack_tftp.c | 6 +++---
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/net/ipv4/netfilter/ip_conntrack_ftp.c b/net/ipv4/netfilter/ip_conntrack_ftp.c
--- a/net/ipv4/netfilter/ip_conntrack_ftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_ftp.c
@@ -29,9 +29,9 @@ static char *ftp_buffer;
static DEFINE_SPINLOCK(ip_ftp_lock);
#define MAX_PORTS 8
-static int ports[MAX_PORTS];
+static short ports[MAX_PORTS];
static int ports_c;
-module_param_array(ports, int, &ports_c, 0400);
+module_param_array(ports, short, &ports_c, 0400);
static int loose;
module_param(loose, int, 0600);
@@ -450,7 +450,7 @@ out_update_nl:
}
static struct ip_conntrack_helper ftp[MAX_PORTS];
-static char ftp_names[MAX_PORTS][10];
+static char ftp_names[MAX_PORTS][sizeof("ftp-65535")];
/* Not __exit: called from init() */
static void fini(void)
diff --git a/net/ipv4/netfilter/ip_conntrack_irc.c b/net/ipv4/netfilter/ip_conntrack_irc.c
--- a/net/ipv4/netfilter/ip_conntrack_irc.c
+++ b/net/ipv4/netfilter/ip_conntrack_irc.c
@@ -34,7 +34,7 @@
#include <linux/moduleparam.h>
#define MAX_PORTS 8
-static int ports[MAX_PORTS];
+static short ports[MAX_PORTS];
static int ports_c;
static int max_dcc_channels = 8;
static unsigned int dcc_timeout = 300;
@@ -52,7 +52,7 @@ EXPORT_SYMBOL_GPL(ip_nat_irc_hook);
MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
MODULE_DESCRIPTION("IRC (DCC) connection tracking helper");
MODULE_LICENSE("GPL");
-module_param_array(ports, int, &ports_c, 0400);
+module_param_array(ports, short, &ports_c, 0400);
MODULE_PARM_DESC(ports, "port numbers of IRC servers");
module_param(max_dcc_channels, int, 0400);
MODULE_PARM_DESC(max_dcc_channels, "max number of expected DCC channels per IRC session");
@@ -240,7 +240,7 @@ static int help(struct sk_buff **pskb,
}
static struct ip_conntrack_helper irc_helpers[MAX_PORTS];
-static char irc_names[MAX_PORTS][10];
+static char irc_names[MAX_PORTS][sizeof("irc-65535")];
static void fini(void);
diff --git a/net/ipv4/netfilter/ip_conntrack_tftp.c b/net/ipv4/netfilter/ip_conntrack_tftp.c
--- a/net/ipv4/netfilter/ip_conntrack_tftp.c
+++ b/net/ipv4/netfilter/ip_conntrack_tftp.c
@@ -26,9 +26,9 @@ MODULE_DESCRIPTION("tftp connection trac
MODULE_LICENSE("GPL");
#define MAX_PORTS 8
-static int ports[MAX_PORTS];
+static short ports[MAX_PORTS];
static int ports_c;
-module_param_array(ports, int, &ports_c, 0400);
+module_param_array(ports, short, &ports_c, 0400);
MODULE_PARM_DESC(ports, "port numbers of tftp servers");
#if 0
@@ -100,7 +100,7 @@ static int tftp_help(struct sk_buff **ps
}
static struct ip_conntrack_helper tftp[MAX_PORTS];
-static char tftp_names[MAX_PORTS][10];
+static char tftp_names[MAX_PORTS][sizeof("tftp-65535")];
static void fini(void)
{
next prev parent reply other threads:[~2005-09-09 22:59 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-09-07 23:11 buffer overflow in ip_ct_{ftp,tftp,irc} Samir Bellabes
2005-09-07 23:15 ` Samir Bellabes
2005-09-07 23:43 ` Pablo Neira
2005-09-07 23:48 ` Pablo Neira
2005-09-09 22:59 ` Patrick McHardy [this message]
2005-09-12 8:44 ` Amin Azez
2005-09-12 8:49 ` Patrick McHardy
2005-09-20 7:11 ` Yasuyuki KOZAKAI
[not found] ` <200509200711.j8K7Bw3x002184@toshiba.co.jp>
2005-09-20 8:10 ` Pablo Neira
2005-09-20 9:35 ` Harald Welte
2005-09-20 12:48 ` Yasuyuki KOZAKAI
[not found] ` <200509201248.j8KCmNi9009046@toshiba.co.jp>
2005-09-20 14:15 ` Harald Welte
2005-09-24 8:43 ` Yasuyuki KOZAKAI
2005-09-10 7:38 ` [PATCH] " Harald Welte
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=432213E5.4000200@trash.net \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=laforge@netfilter.org \
--cc=netfilter-devel@lists.netfilter.org \
--cc=pablo@netfilter.org \
--cc=sbellabes@mandriva.com \
/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.