walters / rpms / kernel

Forked from rpms/kernel 5 years ago
Clone
4e55c73
From patchwork Wed Aug 17 16:04:31 2016
4e55c73
Content-Type: text/plain; charset="utf-8"
4e55c73
MIME-Version: 1.0
4e55c73
Content-Transfer-Encoding: 7bit
4e55c73
Subject: kernel panic TPROXY , vanilla 4.7.1
4e55c73
From: Eric Dumazet <eric.dumazet@gmail.com>
4e55c73
X-Patchwork-Id: 660174
4e55c73
X-Patchwork-Delegate: davem@davemloft.net
4e55c73
Message-Id: <1471449871.29842.3.camel@edumazet-glaptop3.roam.corp.google.com>
4e55c73
To: Denys Fedoryshchenko <nuclearcat@nuclearcat.com>
4e55c73
Cc: Linux Kernel Network Developers <netdev@vger.kernel.org>,
4e55c73
 netfilter-devel@vger.kernel.org
4e55c73
Date: Wed, 17 Aug 2016 09:04:31 -0700
4e55c73
4e55c73
On Wed, 2016-08-17 at 08:42 -0700, Eric Dumazet wrote:
4e55c73
> On Wed, 2016-08-17 at 17:31 +0300, Denys Fedoryshchenko wrote:
4e55c73
> > Hi!
4e55c73
> > 
4e55c73
> > Tried to run squid on latest kernel, and hit a panic
4e55c73
> > Sometimes it just shows warning in dmesg (but doesnt work properly)
4e55c73
> > [   75.701666] IPv4: Attempt to release TCP socket in state 10 
4e55c73
> > ffff88102d430780
4e55c73
> > [   83.866974] squid (2700) used greatest stack depth: 12912 bytes left
4e55c73
> > [   87.506644] IPv4: Attempt to release TCP socket in state 10 
4e55c73
> > ffff880078a48780
4e55c73
> > [  114.704295] IPv4: Attempt to release TCP socket in state 10 
4e55c73
> > ffff881029f8ad00
4e55c73
> > 
4e55c73
> > I cannot catch yet oops/panic message, netconsole not working.
4e55c73
> > 
4e55c73
> > After triggering warning message 3 times, i am unable to run squid 
4e55c73
> > anymore (without reboot), and in netstat it doesnt show port running.
4e55c73
> > 
4e55c73
> > firewall is:
4e55c73
> > *mangle
4e55c73
> > -A PREROUTING -p tcp -m socket -j DIVERT
4e55c73
> > -A PREROUTING -p tcp -m tcp --dport 80 -i eno1 -j TPROXY --on-port 3129 
4e55c73
> > --on-ip 0.0.0.0 --tproxy-mark 0x1/0x1
4e55c73
> > -A DIVERT -j MARK --set-xmark 0x1/0xffffffff
4e55c73
> > -A DIVERT -j ACCEPT
4e55c73
> > 
4e55c73
> > routing
4e55c73
> > ip rule add fwmark 1 lookup 100
4e55c73
> > ip route add local default dev eno1 table 100
4e55c73
> > 
4e55c73
> > 
4e55c73
> > squid config is default with tproxy option
4e55c73
> > http_port 3129 tproxy
4e55c73
> > 
4e55c73
> 
4e55c73
> Hmppff... sorry for this, I will send a fix.
4e55c73
> 
4e55c73
> Thanks for the report !
4e55c73
> 
4e55c73
4e55c73
4e55c73
Could you try the following ?
4e55c73
4e55c73
Thanks !
4e55c73
4e55c73
 net/netfilter/xt_TPROXY.c |    4 ++++
4e55c73
 1 file changed, 4 insertions(+)
4e55c73
4e55c73
diff --git a/net/netfilter/xt_TPROXY.c b/net/netfilter/xt_TPROXY.c
4e55c73
index 7f4414d26a66..663c4c3c9072 100644
4e55c73
--- a/net/netfilter/xt_TPROXY.c
4e55c73
+++ b/net/netfilter/xt_TPROXY.c
4e55c73
@@ -127,6 +127,8 @@ nf_tproxy_get_sock_v4(struct net *net, struct sk_buff *skb, void *hp,
4e55c73
 						    daddr, dport,
4e55c73
 						    in->ifindex);
4e55c73
 
4e55c73
+			if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
4e55c73
+				sk = NULL;
4e55c73
 			/* NOTE: we return listeners even if bound to
4e55c73
 			 * 0.0.0.0, those are filtered out in
4e55c73
 			 * xt_socket, since xt_TPROXY needs 0 bound
4e55c73
@@ -195,6 +197,8 @@ nf_tproxy_get_sock_v6(struct net *net, struct sk_buff *skb, int thoff, void *hp,
4e55c73
 						   daddr, ntohs(dport),
4e55c73
 						   in->ifindex);
4e55c73
 
4e55c73
+			if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
4e55c73
+				sk = NULL;
4e55c73
 			/* NOTE: we return listeners even if bound to
4e55c73
 			 * 0.0.0.0, those are filtered out in
4e55c73
 			 * xt_socket, since xt_TPROXY needs 0 bound