netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Patrick McHardy <kaber@trash.net>
Cc: "David S. Miller" <davem@davemloft.net>,
	David Stevens <dlstevens@us.ibm.com>,
	davem@redhat.com, laforge@netfilter.org, netdev@oss.sgi.com,
	netdev-bounce@oss.sgi.com, netfilter-devel@lists.netfilter.org,
	okir@suse.de
Subject: Re: [PATCH] Prevent crash on ip_conntrack removal
Date: Sun, 29 Aug 2004 23:48:28 +0200	[thread overview]
Message-ID: <41324F2C.4090003@trash.net> (raw)
In-Reply-To: <4132303C.2060807@trash.net>

[-- Attachment #1: Type: text/plain, Size: 1373 bytes --]

Patrick McHardy wrote:

> Attached. The first patch still crashed, we need to prevent new
> fragments from getting queued after the queue is flushed until the
> hook in unregistered.

The patch is racy, another CPU could already have passed the check
for ip_ct_no_defrag and queue the packet after __ip_evictor calculated
the work to do, so the packet (or another one) will not get evicted.
This patch on top calls synchronize_net() to prevent this.

>
>@@ -1181,6 +1183,12 @@
> #ifdef CONFIG_NETFILTER_DEBUG
> 	unsigned int olddebug = skb->nf_debug;
> #endif
>+
>+	if (unlikely(ip_ct_no_defrag)) {
>+		kfree_skb(skb);
>+		return NULL;
>+	}
>+
> 	if (sk) {
> 		sock_hold(sk);
> 		skb_orphan(skb);
>diff -Nru a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
>--- a/net/ipv4/netfilter/ip_conntrack_standalone.c	2004-08-29 20:55:13 +02:00
>+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c	2004-08-29 20:55:13 +02:00
>@@ -805,6 +805,12 @@
>  cleanup_defraglocalops:
> 	nf_unregister_hook(&ip_conntrack_defrag_local_out_ops);
>  cleanup_defragops:
>+	/* Frag queues may hold fragments with skb->dst == NULL */
>+	ip_ct_no_defrag = 1;
>+	smp_wmb();
>+	local_bh_disable();
>+	ipfrag_flush();
>+	local_bh_enable();
> 	nf_unregister_hook(&ip_conntrack_defrag_ops);
>  cleanup_proc_stat:
> 	proc_net_remove("ip_conntrack_stat");
>  
>


[-- Attachment #2: x --]
[-- Type: text/plain, Size: 875 bytes --]

# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
#   2004/08/29 23:36:17+02:00 kaber@coreworks.de 
#   [NETFILTER]: Fix race when flushing fragment queue
#   
#   Signed-off-by: Patrick McHardy <kaber@trash.net>
# 
# net/ipv4/netfilter/ip_conntrack_standalone.c
#   2004/08/29 23:35:54+02:00 kaber@coreworks.de +1 -1
#   [NETFILTER]: Fix race when flushing fragment queue
# 
diff -Nru a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c
--- a/net/ipv4/netfilter/ip_conntrack_standalone.c	2004-08-29 23:39:07 +02:00
+++ b/net/ipv4/netfilter/ip_conntrack_standalone.c	2004-08-29 23:39:07 +02:00
@@ -807,7 +807,7 @@
  cleanup_defragops:
 	/* Frag queues may hold fragments with skb->dst == NULL */
 	ip_ct_no_defrag = 1;
-	smp_wmb();
+	synchronize_net();
 	local_bh_disable();
 	ipfrag_flush();
 	local_bh_enable();

  parent reply	other threads:[~2004-08-29 21:48 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-18  9:13 [PATCH] Prevent crash on ip_conntrack removal Olaf Kirch
2004-08-19 10:11 ` Harald Welte
2004-08-19 14:18   ` David S. Miller
2004-08-19 14:55     ` Patrick McHardy
2004-08-19 15:14       ` David S. Miller
2004-08-21 15:10         ` Patrick McHardy
2004-08-22  5:13           ` David S. Miller
2004-08-22 12:58             ` Patrick McHardy
2004-08-23  5:03               ` David S. Miller
2004-08-23 21:18               ` David Stevens
2004-08-24  0:45                 ` Nivedita Singhvi
2004-08-24  0:45                 ` Patrick McHardy
2004-08-24 21:28                   ` David Stevens
2004-08-29  6:15                     ` David S. Miller
2004-08-29 19:36                       ` Patrick McHardy
2004-08-29 19:57                         ` David S. Miller
2004-08-29 20:06                           ` Patrick McHardy
2004-08-29 21:58                           ` Patrick McHardy
2004-08-29 23:38                             ` David S. Miller
2004-08-30  0:50                               ` Patrick McHardy
2004-08-30  4:28                                 ` David S. Miller
2004-08-29 21:48                         ` Patrick McHardy [this message]
2004-08-30  7:57                         ` Olaf Kirch

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=41324F2C.4090003@trash.net \
    --to=kaber@trash.net \
    --cc=davem@davemloft.net \
    --cc=davem@redhat.com \
    --cc=dlstevens@us.ibm.com \
    --cc=laforge@netfilter.org \
    --cc=netdev-bounce@oss.sgi.com \
    --cc=netdev@oss.sgi.com \
    --cc=netfilter-devel@lists.netfilter.org \
    --cc=okir@suse.de \
    /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).