From: Patrick McHardy <kaber@trash.net>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: David Miller <davem@davemloft.net>, linux-next@vger.kernel.org
Subject: Re: linux-next: manual merge of the net tree
Date: Thu, 10 Jul 2008 14:11:06 +0200 [thread overview]
Message-ID: <4875FC5A.7000109@trash.net> (raw)
In-Reply-To: <20080710140212.753c3bce.sfr@canb.auug.org.au>
[-- Attachment #1: Type: text/plain, Size: 1634 bytes --]
Stephen Rothwell wrote:
> Hi Dave,
>
> Today's linux-next merge of the net tree got a conflict in
> net/netfilter/nf_conntrack_proto_tcp.c between commit
> 6b69fe0c73c0f5a8dacf8f889db3cc9adee53649 ("netfilter: nf_conntrack_tcp:
> fix endless loop") from the net-current tree and commit
> 51091764f26ec36c02e35166f083193a30f426fc ("netfilter: nf_conntrack: add
> nf_ct_kill()") from the net tree.
>
> Not a simple fixup. I did what I thought was right, please check.
>
> The conflict was in tcp_packet() and looked like this:
>
> if (((ct->proto.tcp.seen[dir].flags
> | ct->proto.tcp.seen[!dir].flags)
> & IP_CT_TCP_FLAG_CLOSE_INIT)
> || (ct->proto.tcp.last_dir == dir
> && ct->proto.tcp.last_index == TCP_RST_SET)) {
> /* Attempt to reopen a closed/aborted connection.
> * Delete this connection and look up again. */
> write_unlock_bh(&tcp_lock);
> <<<<<<< HEAD:net/netfilter/nf_conntrack_proto_tcp.c
> /* Only repeat if we can actually remove the timer.
> * Destruction may already be in progress in process
> * context and we must give it a chance to terminate.
> */
> if (del_timer(&ct->timeout)) {
> ct->timeout.function((unsigned long)ct);
> return -NF_REPEAT;
> }
> return -NF_DROP;
> =======
> nf_ct_kill(ct);
> return -NF_REPEAT;
>>>>>>>> net/master:net/netfilter/nf_conntrack_proto_tcp.c
> }
> /* Fall through */
> case TCP_CONNTRACK_IGNORE:
>
> I used the HEAD version. You may need to return a value from nf_ct_kill()
> indicating if the timer was deleted to fix this properly.
Indeed. The attached against net-next does this.
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 3009 bytes --]
commit 6b672c85d01e46b3fddf6c4285330df98a90d462
Author: Patrick McHardy <kaber@trash.net>
Date: Thu Jul 10 14:10:04 2008 +0200
netfilter: nf_conntrack_tcp: fix endless loop
When a conntrack entry is destroyed in process context and destruction
is interrupted by packet processing and the packet is an attempt to
reopen a closed connection, TCP conntrack tries to kill the old entry
itself and returns NF_REPEAT to pass the packet through the hook
again. This may lead to an endless loop: TCP conntrack repeatedly
finds the old entry, but can not kill it itself since destruction
is already in progress, but destruction in process context can not
complete since TCP conntrack is keeping the CPU busy.
Drop the packet in TCP conntrack if we can't kill the connection
ourselves to avoid this.
Reported by: hemao77@gmail.com [ Kernel bugzilla #11058 ]
Signed-off-by: Patrick McHardy <kaber@trash.net>
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index d5d76ec..4f367a0 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -223,23 +223,23 @@ static inline void nf_ct_refresh(struct nf_conn *ct,
__nf_ct_refresh_acct(ct, 0, skb, extra_jiffies, 0);
}
-extern void __nf_ct_kill_acct(struct nf_conn *ct,
- enum ip_conntrack_info ctinfo,
- const struct sk_buff *skb,
- int do_acct);
+extern int __nf_ct_kill_acct(struct nf_conn *ct,
+ enum ip_conntrack_info ctinfo,
+ const struct sk_buff *skb,
+ int do_acct);
/* kill conntrack and do accounting */
-static inline void nf_ct_kill_acct(struct nf_conn *ct,
- enum ip_conntrack_info ctinfo,
- const struct sk_buff *skb)
+static inline int nf_ct_kill_acct(struct nf_conn *ct,
+ enum ip_conntrack_info ctinfo,
+ const struct sk_buff *skb)
{
- __nf_ct_kill_acct(ct, ctinfo, skb, 1);
+ return __nf_ct_kill_acct(ct, ctinfo, skb, 1);
}
/* kill conntrack without accounting */
-static inline void nf_ct_kill(struct nf_conn *ct)
+static inline int nf_ct_kill(struct nf_conn *ct)
{
- __nf_ct_kill_acct(ct, 0, NULL, 0);
+ return __nf_ct_kill_acct(ct, 0, NULL, 0);
}
/* These are for NAT. Icky. */
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 740acd6..47f2516 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -844,8 +844,13 @@ static int tcp_packet(struct nf_conn *ct,
/* Attempt to reopen a closed/aborted connection.
* Delete this connection and look up again. */
write_unlock_bh(&tcp_lock);
- nf_ct_kill(ct);
- return -NF_REPEAT;
+ /* Only repeat if we can actually remove the timer.
+ * Destruction may already be in progress in process
+ * context and we must give it a chance to terminate.
+ */
+ if (nf_ct_kill(ct))
+ return -NF_REPEAT;
+ return -NF_DROP;
}
/* Fall through */
case TCP_CONNTRACK_IGNORE:
next prev parent reply other threads:[~2008-07-10 12:11 UTC|newest]
Thread overview: 77+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-10 4:02 linux-next: manual merge of the net tree Stephen Rothwell
2008-07-10 12:11 ` Patrick McHardy [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-12-23 23:19 Stephen Rothwell
2008-12-24 2:15 ` David Miller
2008-12-24 14:41 ` Cyrill Gorcunov
2008-12-23 23:15 Stephen Rothwell
2008-12-24 2:16 ` David Miller
2008-12-15 3:44 Stephen Rothwell
2008-12-15 6:59 ` David Miller
2008-12-09 2:21 Stephen Rothwell
2008-12-09 22:17 ` J. Bruce Fields
2008-12-09 23:22 ` David Miller
2008-12-09 23:41 ` Stephen Rothwell
2008-12-09 2:13 Stephen Rothwell
2008-12-08 3:48 Stephen Rothwell
2008-12-08 7:26 ` David Miller
2008-12-29 3:53 ` Stephen Rothwell
2008-12-29 4:00 ` David Miller
2008-12-29 4:14 ` Stephen Rothwell
2008-12-01 3:26 Stephen Rothwell
2008-12-01 7:20 ` David Miller
2008-12-01 17:06 ` Mike Frysinger
2008-12-01 3:16 Stephen Rothwell
2008-11-27 3:40 Stephen Rothwell
2008-11-27 8:03 ` David Miller
2008-11-26 6:42 Stephen Rothwell
2008-11-26 6:34 Stephen Rothwell
2008-11-21 2:33 Stephen Rothwell
2008-11-21 2:29 Stephen Rothwell
2008-11-21 4:11 ` David Miller
2008-11-21 4:22 ` Stephen Rothwell
2008-11-20 2:10 Stephen Rothwell
2008-11-18 0:51 Stephen Rothwell
2008-11-12 2:59 Stephen Rothwell
2008-11-12 3:07 ` John W. Linville
2008-11-10 3:02 Stephen Rothwell
2008-11-11 7:00 ` David Miller
2008-11-11 8:24 ` Stephen Rothwell
2008-11-11 9:21 ` David Miller
2008-11-11 23:17 ` Stephen Rothwell
2008-11-07 4:33 Stephen Rothwell
2008-11-07 4:24 Stephen Rothwell
2008-11-07 4:47 ` David Miller
2008-10-29 3:11 Stephen Rothwell
2008-10-29 4:53 ` David Miller
2008-10-29 12:34 ` John W. Linville
2008-10-29 20:20 ` David Miller
2008-08-28 3:55 Stephen Rothwell
2008-08-28 8:15 ` David Miller
2008-07-16 7:00 Stephen Rothwell
2008-07-16 6:56 Stephen Rothwell
2008-07-08 4:27 Stephen Rothwell
2008-07-08 6:03 ` Tobias Diedrich
2008-07-08 14:23 ` Rafael J. Wysocki
2008-07-08 4:16 Stephen Rothwell
2008-07-08 12:22 ` John W. Linville
2008-07-08 13:00 ` Stephen Rothwell
2008-07-08 4:10 Stephen Rothwell
2008-07-08 5:14 ` David Miller
2008-07-08 5:44 ` David Miller
2008-07-08 6:15 ` Stephen Rothwell
2008-07-03 4:08 Stephen Rothwell
2008-07-03 4:14 ` David Miller
2008-07-03 3:56 Stephen Rothwell
2008-07-03 4:11 ` Stephen Rothwell
2008-07-03 4:13 ` David Miller
2008-07-01 7:19 Stephen Rothwell
2008-07-01 9:33 ` David Miller
2008-07-01 15:09 ` Stephen Rothwell
2008-07-01 7:11 Stephen Rothwell
2008-06-19 3:04 Stephen Rothwell
2008-06-19 5:01 ` David Miller
2008-06-19 5:49 ` Stephen Rothwell
2008-06-13 21:56 linux-next: pending wireless/wireless-current merge conflict John W. Linville
2008-06-25 18:04 ` John W. Linville
2008-06-26 5:40 ` linux-next: manual merge of the net tree Stephen Rothwell
2008-06-26 5:54 ` David Miller
2008-06-26 6:58 ` Stephen Rothwell
2008-06-26 9:08 ` David Miller
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=4875FC5A.7000109@trash.net \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=linux-next@vger.kernel.org \
--cc=sfr@canb.auug.org.au \
/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).