tcp: tracepoint: only call trace_tcp_send_reset with full socket

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/5c487bb9adddbc1d23433e09d2548759375c2b52
Commit:     5c487bb9adddbc1d23433e09d2548759375c2b52
Parent:     043e337f555e610ad8237fd23522d97c968d72b9
Refname:    refs/heads/master
Author:     Song Liu <[email protected]>
AuthorDate: Tue Feb 6 20:50:23 2018 -0800
Committer:  David S. Miller <[email protected]>
CommitDate: Wed Feb 7 22:00:42 2018 -0500

    tcp: tracepoint: only call trace_tcp_send_reset with full socket
    
    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 <[email protected]>
    Reviewed-by: Lawrence Brakmo <[email protected]>
    Signed-off-by: David S. Miller <[email protected]>
---
 net/ipv4/tcp_ipv4.c | 3 ++-
 net/ipv6/tcp_ipv6.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 95738aa0d8a6..f8ad397e285e 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -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) !=
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index a1ab29e2ab3b..412139f4eccd 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -942,7 +942,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);
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.