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/ipv4/tcp_ipv4.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/ipv4/tcp_ipv4.c')
-rw-r--r-- | net/ipv4/tcp_ipv4.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index a20e7f03d5f7..e9252c7df809 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -1722,6 +1722,8 @@ process: | |||
1722 | */ | 1722 | */ |
1723 | sock_hold(sk); | 1723 | sock_hold(sk); |
1724 | refcounted = true; | 1724 | refcounted = true; |
1725 | if (tcp_filter(sk, skb)) | ||
1726 | goto discard_and_relse; | ||
1725 | nsk = tcp_check_req(sk, skb, req, false); | 1727 | nsk = tcp_check_req(sk, skb, req, false); |
1726 | if (!nsk) { | 1728 | if (!nsk) { |
1727 | reqsk_put(req); | 1729 | reqsk_put(req); |
@@ -1729,8 +1731,6 @@ process: | |||
1729 | } | 1731 | } |
1730 | if (nsk == sk) { | 1732 | if (nsk == sk) { |
1731 | reqsk_put(req); | 1733 | reqsk_put(req); |
1732 | } else if (tcp_filter(sk, skb)) { | ||
1733 | goto discard_and_relse; | ||
1734 | } else if (tcp_child_process(sk, nsk, skb)) { | 1734 | } else if (tcp_child_process(sk, nsk, skb)) { |
1735 | tcp_v4_send_reset(nsk, skb); | 1735 | tcp_v4_send_reset(nsk, skb); |
1736 | goto discard_and_relse; | 1736 | goto discard_and_relse; |