]> git.hungrycats.org Git - linux/commitdiff
tcp: fix a request socket leak
authorEric Dumazet <edumazet@google.com>
Fri, 8 Sep 2017 19:44:47 +0000 (12:44 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Sep 2017 06:27:47 +0000 (08:27 +0200)
[ Upstream commit 1f3b359f1004bd34b7b0bad70b93e3c7af92a37b ]

While the cited commit fixed a possible deadlock, it added a leak
of the request socket, since reqsk_put() must be called if the BPF
filter decided the ACK packet must be dropped.

Fixes: d624d276d1dd ("tcp: fix possible deadlock in TCP stack vs BPF filter")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ipv4/tcp_ipv4.c
net/ipv6/tcp_ipv6.c

index e9252c7df8091a8e0d2fc9d7e5722e9fd605a857..21022db7a2a6c2aaee803c6c31795c042ad15855 100644 (file)
@@ -1722,9 +1722,9 @@ process:
                 */
                sock_hold(sk);
                refcounted = true;
-               if (tcp_filter(sk, skb))
-                       goto discard_and_relse;
-               nsk = tcp_check_req(sk, skb, req, false);
+               nsk = NULL;
+               if (!tcp_filter(sk, skb))
+                       nsk = tcp_check_req(sk, skb, req, false);
                if (!nsk) {
                        reqsk_put(req);
                        goto discard_and_relse;
index 206210125fd71d129a9ed2ead51a536749ab62b8..660b9b2a8a2522034e2b5cc5ae1e680d9ac6d1c9 100644 (file)
@@ -1456,9 +1456,9 @@ process:
                }
                sock_hold(sk);
                refcounted = true;
-               if (tcp_filter(sk, skb))
-                       goto discard_and_relse;
-               nsk = tcp_check_req(sk, skb, req, false);
+               nsk = NULL;
+               if (!tcp_filter(sk, skb))
+                       nsk = tcp_check_req(sk, skb, req, false);
                if (!nsk) {
                        reqsk_put(req);
                        goto discard_and_relse;