netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dong Wei <dwei.zh@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: Port back 2.6 kernel patch to 2.4 which fixed bridge module panic when received special fragments
Date: Wed, 13 Jan 2010 17:30:38 +0800	[thread overview]
Message-ID: <3104bfb61001130130s4fbf1649oa9a12e7c855cc6e@mail.gmail.com> (raw)

Hi, All

linux-2.6.32.3 fixed a kernel panic problem in bridge module when
received special fragments.

see: http://git.kernel.org/?p=linux/kernel/git/hpa/linux-2.6-allstable.git;a=commit;h=8fa9ff6849bb86c59cc2ea9faadf3cb2d5223497

There is a ebtables kernel patch ebtables-brnf-11-2_vs_2.4.31.diff.gz
which port back bridge netfilter.  After applied the kernel patch, the
kernel panic problem will be introduced to the kernel. I made a kernel
patch on 2.4.37.7 which can fix this problem. I think this patch
should be merged to the ebtables-brnf-11-2_vs_2.4.31.diff.gz .


Signed-off-by Dong Wei<dwei.zh@gmail.com>


diff -ruNp linux-2.4.37.7/include/net/ip.h linux-2.4.37.7-new/include/net/ip.h
--- linux-2.4.37.7/include/net/ip.h	2009-11-08 00:52:20.000000000 +0800
+++ linux-2.4.37.7-new/include/net/ip.h	2010-01-13 15:46:32.000000000 +0800
@@ -234,6 +234,7 @@ enum ip_defrag_users
 	IP_DEFRAG_CALL_RA_CHAIN,
 	IP_DEFRAG_CONNTRACK_IN,
 	IP_DEFRAG_CONNTRACK_OUT,
+	IP_DEFRAG_CONNTRACK_BRIDGE_IN,
 	IP_DEFRAG_NAT_OUT,
 	IP_DEFRAG_VS_OUT,
 	IP_DEFRAG_VS_FWD
diff -ruNp linux-2.4.37.7/net/ipv4/netfilter/ip_conntrack_core.c
linux-2.4.37.7-new/net/ipv4/netfilter/ip_conntrack_core.c
--- linux-2.4.37.7/net/ipv4/netfilter/ip_conntrack_core.c	2009-11-08
00:52:20.000000000 +0800
+++ linux-2.4.37.7-new/net/ipv4/netfilter/ip_conntrack_core.c	2010-01-13
16:09:40.000000000 +0800
@@ -38,6 +38,7 @@
 #define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_conntrack_lock)
 #define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_conntrack_lock)

+#include <linux/netfilter_bridge.h>
 #include <linux/netfilter_ipv4/ip_conntrack.h>
 #include <linux/netfilter_ipv4/ip_conntrack_protocol.h>
 #include <linux/netfilter_ipv4/ip_conntrack_helper.h>
@@ -810,6 +811,20 @@ resolve_normal_ct(struct sk_buff *skb,
 	return h->ctrack;
 }

+static enum ip_defrag_users nf_ct_defrag_user(unsigned int hooknum,
+					      struct sk_buff *skb)
+{
+#if defined(CONFIG_BRIDGE) || defined(CONFIG_BRIDGE_MODULE)
+	if (skb->nf_bridge &&
+	    skb->nf_bridge->mask & BRNF_NF_BRIDGE_PREROUTING)
+		return IP_DEFRAG_CONNTRACK_BRIDGE_IN;
+#endif
+	if (hooknum == NF_IP_PRE_ROUTING)
+		return IP_DEFRAG_CONNTRACK_IN;
+	else
+		return IP_DEFRAG_CONNTRACK_OUT;
+}
+
 /* Netfilter hook itself. */
 unsigned int ip_conntrack_in(unsigned int hooknum,
 			     struct sk_buff **pskb,
@@ -848,10 +863,8 @@ unsigned int ip_conntrack_in(unsigned in

 	/* Gather fragments. */
 	if ((*pskb)->nh.iph->frag_off & htons(IP_MF|IP_OFFSET)) {
-		*pskb = ip_ct_gather_frags(*pskb,
-		                           hooknum == NF_IP_PRE_ROUTING ?
-		                           IP_DEFRAG_CONNTRACK_IN :
-		                           IP_DEFRAG_CONNTRACK_OUT);
+		enum ip_defrag_users user = nf_ct_defrag_user(hooknum, *pskb);
+		*pskb = ip_ct_gather_frags(*pskb, user);
 		if (!*pskb)
 			return NF_STOLEN;
 	}
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2010-01-13  9:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-13  9:30 Dong Wei [this message]
2010-01-13  9:33 ` Port back 2.6 kernel patch to 2.4 which fixed bridge module panic when received special fragments Patrick McHardy
2010-01-13  9:42   ` Dong Wei
2010-01-13  9:44     ` Patrick McHardy
2010-01-13 19:44       ` Bart De Schuymer
2010-01-14  8:46         ` 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=3104bfb61001130130s4fbf1649oa9a12e7c855cc6e@mail.gmail.com \
    --to=dwei.zh@gmail.com \
    --cc=netfilter-devel@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).