From: Olaf Kirch <okir@suse.de>
To: netdev@oss.sgi.com
Cc: netfilter-devel@lists.netfilter.org
Subject: [PATCH] netfilter6: Skip extension headers when matching icmp6-type
Date: Thu, 30 Sep 2004 14:16:20 +0200 [thread overview]
Message-ID: <20040930121620.GH19083@suse.de> (raw)
This patch fixes a bug in the ip6_tables code when matching ICMP type and
code within ICMPv6 packets. The icmpv6 packet matcher expects the nexthdr
to be ICMPv6 and does not deal with hop-by-hop headers etc.
Signed-off-by: Olaf Kirch <okir@suse.de>
Index: linux-2.6.8.nf/net/ipv6/netfilter/ip6_tables.c
===================================================================
--- linux-2.6.8.nf.orig/net/ipv6/netfilter/ip6_tables.c 2004-08-26 13:22:35.000000000 +0200
+++ linux-2.6.8.nf/net/ipv6/netfilter/ip6_tables.c 2004-09-30 14:07:51.000000000 +0200
@@ -1751,10 +1751,23 @@
u_int16_t datalen,
int *hotdrop)
{
- const struct icmp6hdr *icmp = hdr;
+ struct icmp6hdr icmph;
const struct ip6t_icmp *icmpinfo = matchinfo;
+ int hdroff;
+ u8 nexthdr = skb->nh.ipv6h->nexthdr;
- if (offset == 0 && datalen < 2) {
+ /* Must not be a fragment. */
+ if (offset)
+ return 0;
+
+ hdroff = (u8*)(skb->nh.ipv6h+1) - skb->data;
+ hdroff = ipv6_skip_exthdr(skb, hdroff, &nexthdr, skb->len - hdroff);
+ if (hdroff < 0 || hdroff > skb->len || nexthdr != IPPROTO_ICMPV6) {
+ *hotdrop = 1;
+ return 0;
+ }
+
+ if (skb_copy_bits(skb, hdroff, &icmph, sizeof(icmph)) < 0) {
/* We've been asked to examine this packet, and we
can't. Hence, no choice but to drop. */
duprintf("Dropping evil ICMP tinygram.\n");
@@ -1763,11 +1776,10 @@
}
/* Must not be a fragment. */
- return !offset
- && icmp6_type_code_match(icmpinfo->type,
+ return icmp6_type_code_match(icmpinfo->type,
icmpinfo->code[0],
icmpinfo->code[1],
- icmp->icmp6_type, icmp->icmp6_code,
+ icmph.icmp6_type, icmph.icmp6_code,
!!(icmpinfo->invflags&IP6T_ICMP_INV));
}
--
Olaf Kirch | Things that make Monday morning interesting, #1:
okir@suse.de | "I want to use NFS over AX25, can you help me?"
---------------+
next reply other threads:[~2004-09-30 12:16 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-09-30 12:16 Olaf Kirch [this message]
2004-09-30 12:29 ` [PATCH] netfilter6: Skip extension headers when matching icmp6-type YOSHIFUJI Hideaki / 吉藤英明
2004-09-30 12:39 ` Yasuyuki Kozakai
2004-09-30 12:44 ` Yasuyuki Kozakai
2004-09-30 14:48 ` Patrick McHardy
2004-10-01 0:19 ` Yasuyuki Kozakai
2004-10-01 5:09 ` Yasuyuki Kozakai
2004-10-01 9:02 ` When to submit to which list (was Re: [PATCH] netfilter6: Skip extension headers when matching icmp6-type) Harald Welte
2004-10-01 9:33 ` When to submit to which list Yasuyuki Kozakai
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=20040930121620.GH19083@suse.de \
--to=okir@suse.de \
--cc=netdev@oss.sgi.com \
--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.