]> git.hungrycats.org Git - linux/commitdiff
tcp: tracepoint: only call trace_tcp_send_reset with full socket
authorSong Liu <songliubraving@fb.com>
Wed, 7 Feb 2018 04:50:23 +0000 (20:50 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 Mar 2018 06:47:41 +0000 (22:47 -0800)
[ Upstream commit 5c487bb9adddbc1d23433e09d2548759375c2b52 ]

tracepoint tcp_send_reset requires a full socket to work. However, it
may be called when in TCP_TIME_WAIT:

        case TCP_TW_RST:
                tcp_v6_send_reset(sk, skb);
                inet_twsk_deschedule_put(inet_twsk(sk));
                goto discard_it;

To avoid this problem, this patch checks the socket with sk_fullsock()
before calling trace_tcp_send_reset().

Fixes: c24b14c46bb8 ("tcp: add tracepoint trace_tcp_send_reset")
Signed-off-by: Song Liu <songliubraving@fb.com>
Reviewed-by: Lawrence Brakmo <brakmo@fb.com>
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 94e28350f4205b1a57809d5471d7e2ade51f5196..3b051b9b3743e581f7665c33e82e97d810b16b67 100644 (file)
@@ -705,7 +705,8 @@ static void tcp_v4_send_reset(const struct sock *sk, struct sk_buff *skb)
         */
        if (sk) {
                arg.bound_dev_if = sk->sk_bound_dev_if;
-               trace_tcp_send_reset(sk, skb);
+               if (sk_fullsock(sk))
+                       trace_tcp_send_reset(sk, skb);
        }
 
        BUILD_BUG_ON(offsetof(struct sock, sk_bound_dev_if) !=
index 7178476b3d2f64f01832fe3292c7dec849ec2265..6378f6fbc89f4037ac9e2f3fdd867ac7bb70669c 100644 (file)
@@ -943,7 +943,8 @@ static void tcp_v6_send_reset(const struct sock *sk, struct sk_buff *skb)
 
        if (sk) {
                oif = sk->sk_bound_dev_if;
-               trace_tcp_send_reset(sk, skb);
+               if (sk_fullsock(sk))
+                       trace_tcp_send_reset(sk, skb);
        }
 
        tcp_v6_send_response(sk, skb, seq, ack_seq, 0, 0, 0, oif, key, 1, 0, 0);