diff options
author | Eric Dumazet <edumazet@google.com> | 2017-08-14 20:44:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-08-15 01:31:27 -0400 |
commit | d624d276d1ddacbcb12ad96832ce0c7b82cd25db (patch) | |
tree | b78aa1f2060bf2aa70b13af5d58a7bca994af306 /net/ipv6/tcp_ipv6.c | |
parent | 7749d4ff88d31b0be17c8683143135adaaadc6a7 (diff) |
tcp: fix possible deadlock in TCP stack vs BPF filter
Filtering the ACK packet was not put at the right place.
At this place, we already allocated a child and put it
into accept queue.
We absolutely need to call tcp_child_process() to release
its spinlock, or we will deadlock at accept() or close() time.
Found by syzkaller team (Thanks a lot !)
Fixes: 8fac365f63c8 ("tcp: Add a tcp_filter hook before handle ack packet")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Chenbo Feng <fengc@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/tcp_ipv6.c')
-rw-r--r-- | net/ipv6/tcp_ipv6.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 2521690d62d6..206210125fd7 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -1456,6 +1456,8 @@ process: | |||
1456 | } | 1456 | } |
1457 | sock_hold(sk); | 1457 | sock_hold(sk); |
1458 | refcounted = true; | 1458 | refcounted = true; |
1459 | if (tcp_filter(sk, skb)) | ||
1460 | goto discard_and_relse; | ||
1459 | nsk = tcp_check_req(sk, skb, req, false); | 1461 | nsk = tcp_check_req(sk, skb, req, false); |
1460 | if (!nsk) { | 1462 | if (!nsk) { |
1461 | reqsk_put(req); | 1463 | reqsk_put(req); |
@@ -1464,8 +1466,6 @@ process: | |||
1464 | if (nsk == sk) { | 1466 | if (nsk == sk) { |
1465 | reqsk_put(req); | 1467 | reqsk_put(req); |
1466 | tcp_v6_restore_cb(skb); | 1468 | tcp_v6_restore_cb(skb); |
1467 | } else if (tcp_filter(sk, skb)) { | ||
1468 | goto discard_and_relse; | ||
1469 | } else if (tcp_child_process(sk, nsk, skb)) { | 1469 | } else if (tcp_child_process(sk, nsk, skb)) { |
1470 | tcp_v6_send_reset(nsk, skb); | 1470 | tcp_v6_send_reset(nsk, skb); |
1471 | goto discard_and_relse; | 1471 | goto discard_and_relse; |