From: Patrick McHardy <kaber@trash.net>
To: David S. Miller <davem@davemloft.net>
Cc: netfilter-devel@lists.netfilter.org, Patrick McHardy <kaber@trash.net>
Subject: [NETFILTER 04/18]: ctnetlink: Add sanity checkings for ICMP
Date: Thu, 5 Jan 2006 05:06:35 +0100 (MET) [thread overview]
Message-ID: <20060105040559.23512.56695.sendpatchset@localhost.localdomain> (raw)
In-Reply-To: <20060105040554.23512.27346.sendpatchset@localhost.localdomain>
[NETFILTER]: ctnetlink: Add sanity checkings for ICMP
Signed-off-by: Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp>
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit f067059d5e3d09c6679d860eb8c283df7f0f3420
tree 705f9f9add15dd8aff99e0ab45884c91af74348e
parent da3dc79a37546feb6572bff1a36b23830c799c58
author Yasuyuki Kozakai <yasuyuki.kozakai@toshiba.co.jp> Thu, 05 Jan 2006 02:54:00 +0100
committer Patrick McHardy <kaber@trash.net> Thu, 05 Jan 2006 02:54:00 +0100
net/ipv4/netfilter/ip_conntrack_proto_icmp.c | 43 +++++++++++++++-----------
1 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
index 19cc550..30fc21d 100644
--- a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c
@@ -47,20 +47,21 @@ static int icmp_pkt_to_tuple(const struc
return 1;
}
+/* Add 1; spaces filled with 0. */
+static const u_int8_t invmap[] = {
+ [ICMP_ECHO] = ICMP_ECHOREPLY + 1,
+ [ICMP_ECHOREPLY] = ICMP_ECHO + 1,
+ [ICMP_TIMESTAMP] = ICMP_TIMESTAMPREPLY + 1,
+ [ICMP_TIMESTAMPREPLY] = ICMP_TIMESTAMP + 1,
+ [ICMP_INFO_REQUEST] = ICMP_INFO_REPLY + 1,
+ [ICMP_INFO_REPLY] = ICMP_INFO_REQUEST + 1,
+ [ICMP_ADDRESS] = ICMP_ADDRESSREPLY + 1,
+ [ICMP_ADDRESSREPLY] = ICMP_ADDRESS + 1
+};
+
static int icmp_invert_tuple(struct ip_conntrack_tuple *tuple,
const struct ip_conntrack_tuple *orig)
{
- /* Add 1; spaces filled with 0. */
- static const u_int8_t invmap[]
- = { [ICMP_ECHO] = ICMP_ECHOREPLY + 1,
- [ICMP_ECHOREPLY] = ICMP_ECHO + 1,
- [ICMP_TIMESTAMP] = ICMP_TIMESTAMPREPLY + 1,
- [ICMP_TIMESTAMPREPLY] = ICMP_TIMESTAMP + 1,
- [ICMP_INFO_REQUEST] = ICMP_INFO_REPLY + 1,
- [ICMP_INFO_REPLY] = ICMP_INFO_REQUEST + 1,
- [ICMP_ADDRESS] = ICMP_ADDRESSREPLY + 1,
- [ICMP_ADDRESSREPLY] = ICMP_ADDRESS + 1};
-
if (orig->dst.u.icmp.type >= sizeof(invmap)
|| !invmap[orig->dst.u.icmp.type])
return 0;
@@ -110,17 +111,17 @@ static int icmp_packet(struct ip_conntra
return NF_ACCEPT;
}
-static const u_int8_t valid_new[] = {
- [ICMP_ECHO] = 1,
- [ICMP_TIMESTAMP] = 1,
- [ICMP_INFO_REQUEST] = 1,
- [ICMP_ADDRESS] = 1
-};
-
/* Called when a new connection for this protocol found. */
static int icmp_new(struct ip_conntrack *conntrack,
const struct sk_buff *skb)
{
+ static const u_int8_t valid_new[] = {
+ [ICMP_ECHO] = 1,
+ [ICMP_TIMESTAMP] = 1,
+ [ICMP_INFO_REQUEST] = 1,
+ [ICMP_ADDRESS] = 1
+ };
+
if (conntrack->tuplehash[0].tuple.dst.u.icmp.type >= sizeof(valid_new)
|| !valid_new[conntrack->tuplehash[0].tuple.dst.u.icmp.type]) {
/* Can't create a new ICMP `conn' with this. */
@@ -291,7 +292,7 @@ static int icmp_nfattr_to_tuple(struct n
if (!tb[CTA_PROTO_ICMP_TYPE-1]
|| !tb[CTA_PROTO_ICMP_CODE-1]
|| !tb[CTA_PROTO_ICMP_ID-1])
- return -1;
+ return -EINVAL;
tuple->dst.u.icmp.type =
*(u_int8_t *)NFA_DATA(tb[CTA_PROTO_ICMP_TYPE-1]);
@@ -300,6 +301,10 @@ static int icmp_nfattr_to_tuple(struct n
tuple->src.u.icmp.id =
*(u_int16_t *)NFA_DATA(tb[CTA_PROTO_ICMP_ID-1]);
+ if (tuple->dst.u.icmp.type >= sizeof(invmap)
+ || !invmap[tuple->dst.u.icmp.type])
+ return -EINVAL;
+
return 0;
}
#endif
next prev parent reply other threads:[~2006-01-05 4:06 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-05 4:06 [NETFILTER 00/18]: 2.6.15 netfilter update Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 01/18]: Decrease number of pointer derefs in nfnetlink_queue.c Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 02/18]: Decrease number of pointer derefs in nf_conntrack_core.c Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 03/18]: ctnetlink: remove bogus checks in ICMP protocol at dumping Patrick McHardy
2006-01-05 4:06 ` Patrick McHardy [this message]
2006-01-05 4:06 ` [NETFILTER 05/18]: ctnetlink: propagate ctnetlink_dump_tuples_proto return value back Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 06/18]: ctnetlink: use u_int32_t instead of unsigned int Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 07/18]: ctnetlink: ctnetlink_event cleanup Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 08/18]: ctnetlink: fix conntrack mark race Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 09/18]: ctnetlink: remove unused variable Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 10/18]: Add ctnetlink port for nf_conntrack Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 11/18]: Filter dumped entries based on the layer 3 protocol number Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 12/18]: Fix module_param types and permissions Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 13/18]: ctnetlink: Fix dumping of helper name Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 14/18]: Remove okfn usage in ip_vs_core.c Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 15/18]: Call POST_ROUTING hook before fragmentation Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 16/18]: make ipv6_find_hdr() find transport protocol header Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 17/18]: Export ip6_masked_addrcmp, don't pass IPv6 addresses on stack Patrick McHardy
2006-01-05 4:06 ` [NETFILTER 18/18]: nf_conntrack_l3proto_ipv4.c needs net/route.h 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=20060105040559.23512.56695.sendpatchset@localhost.localdomain \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=netfilter-devel@lists.netfilter.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.