lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1510237564-6013-2-git-send-email-laoar.shao@gmail.com>
Date:   Thu,  9 Nov 2017 14:26:04 +0000
From:   Yafang Shao <laoar.shao@...il.com>
To:     davem@...emloft.net
Cc:     kuznet@....inr.ac.ru, yoshfuji@...ux-ipv6.org, rostedt@...dmis.org,
        mingo@...hat.com, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org, Yafang Shao <laoar.shao@...il.com>
Subject: [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint

When TCP connetion in TCP_TIME_WAIT or TCP_NEW_SYN_RECV state, it can't
get the sport/dport/saddr/daddr from inet_sock.

trace_tcp_set_state may be called when the oldstate in these two states.

Signed-off-by: Yafang Shao <laoar.shao@...il.com>
---
 include/trace/events/tcp.h | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index 07cccca..1982a71 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -196,7 +196,6 @@
 	),
 
 	TP_fast_assign(
-		struct inet_sock *inet = inet_sk(sk);
 		struct in6_addr *pin6;
 		__be32 *p32;
 
@@ -204,14 +203,34 @@
 		__entry->oldstate = oldstate;
 		__entry->newstate = newstate;
 
-		__entry->sport = ntohs(inet->inet_sport);
-		__entry->dport = ntohs(inet->inet_dport);
+		if (oldstate == TCP_TIME_WAIT) {
+			__entry->sport = ntohs(inet_twsk(sk)->tw_sport);
+			__entry->dport = ntohs(inet_twsk(sk)->tw_dport);
 
-		p32 = (__be32 *) __entry->saddr;
-		*p32 = inet->inet_saddr;
+			p32 = (__be32 *) __entry->saddr;
+			*p32 = inet_twsk(sk)->tw_rcv_saddr;
 
-		p32 = (__be32 *) __entry->daddr;
-		*p32 =  inet->inet_daddr;
+			p32 = (__be32 *) __entry->daddr;
+			*p32 = inet_twsk(sk)->tw_daddr;
+		} else if (oldstate == TCP_NEW_SYN_RECV) {
+			__entry->sport = inet_rsk(inet_reqsk(sk))->ir_num;
+			__entry->dport = ntohs(inet_rsk(inet_reqsk(sk))->ir_rmt_port);
+
+			p32 = (__be32 *) __entry->saddr;
+			*p32 = inet_rsk(inet_reqsk(sk))->ir_loc_addr;
+
+			p32 = (__be32 *) __entry->daddr;
+			*p32 = inet_rsk(inet_reqsk(sk))->ir_rmt_addr;
+		} else {
+			__entry->sport = ntohs(inet_sk(sk)->inet_sport);
+			__entry->dport = ntohs(inet_sk(sk)->inet_dport);
+
+			p32 = (__be32 *) __entry->saddr;
+			*p32 = inet_sk(sk)->inet_saddr;
+
+			p32 = (__be32 *) __entry->daddr;
+			*p32 =  inet_sk(sk)->inet_daddr;
+		}
 
 #if IS_ENABLED(CONFIG_IPV6)
 		if (sk->sk_family == AF_INET6) {
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ