]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
netfilter -stable: nf_conntrack_tcp: fix endless loop
authorPatrick McHardy <kaber@trash.net>
Thu, 17 Jul 2008 12:07:47 +0000 (14:07 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 1 Aug 2008 18:51:02 +0000 (11:51 -0700)
netfilter: nf_conntrack_tcp: fix endless loop

Upstream commit 6b69fe0:

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/netfilter/nf_conntrack_proto_tcp.c

index fc43e223ab3985f4571184f4225fee500ea4d3aa..3ddf1c001dae6e20f207910058cf330ad58694f9 100644 (file)
@@ -845,9 +845,15 @@ 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);
-                       if (del_timer(&ct->timeout))
+                       /* 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_REPEAT;
+                       }
+                       return -NF_DROP;
                }
                /* Fall through */
        case TCP_CONNTRACK_IGNORE: