summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2016-08-17 12:56:46 -0400
committerPablo Neira Ayuso <pablo@netfilter.org>2016-08-17 18:51:13 -0400
commitdcbe35909c8426e1ace74b4b99c4cb403cdaca89 (patch)
tree23e69e6646920b3c7a14db09d3db696e83922708 /net
parentaca300183ed4f723837f6619facff0890c46d313 (diff)
netfilter: tproxy: properly refcount tcp listeners
inet_lookup_listener() and inet6_lookup_listener() no longer take a reference on the found listener. This minimal patch adds back the refcounting, but we might do this differently in net-next later. Fixes: 3b24d854cb35 ("tcp/dccp: do not touch listener sk_refcnt under synflood") Reported-and-tested-by: Denys Fedoryshchenko <nuclearcat@nuclearcat.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'net')
-rw-r--r--net/netfilter/xt_TPROXY.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/net/netfilter/xt_TPROXY.c b/net/netfilter/xt_TPROXY.c
index 7f4414d26a66..663c4c3c9072 100644
--- a/net/netfilter/xt_TPROXY.c
+++ b/net/netfilter/xt_TPROXY.c
@@ -127,6 +127,8 @@ nf_tproxy_get_sock_v4(struct net *net, struct sk_buff *skb, void *hp,
127 daddr, dport, 127 daddr, dport,
128 in->ifindex); 128 in->ifindex);
129 129
130 if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
131 sk = NULL;
130 /* NOTE: we return listeners even if bound to 132 /* NOTE: we return listeners even if bound to
131 * 0.0.0.0, those are filtered out in 133 * 0.0.0.0, those are filtered out in
132 * xt_socket, since xt_TPROXY needs 0 bound 134 * xt_socket, since xt_TPROXY needs 0 bound
@@ -195,6 +197,8 @@ nf_tproxy_get_sock_v6(struct net *net, struct sk_buff *skb, int thoff, void *hp,
195 daddr, ntohs(dport), 197 daddr, ntohs(dport),
196 in->ifindex); 198 in->ifindex);
197 199
200 if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
201 sk = NULL;
198 /* NOTE: we return listeners even if bound to 202 /* NOTE: we return listeners even if bound to
199 * 0.0.0.0, those are filtered out in 203 * 0.0.0.0, those are filtered out in
200 * xt_socket, since xt_TPROXY needs 0 bound 204 * xt_socket, since xt_TPROXY needs 0 bound