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: <20210218054219.1069224-1-arseny.krasnov@kaspersky.com>
Date:   Thu, 18 Feb 2021 08:42:15 +0300
From:   Arseny Krasnov <arseny.krasnov@...persky.com>
To:     Stefan Hajnoczi <stefanha@...hat.com>,
        Stefano Garzarella <sgarzare@...hat.com>,
        "Michael S. Tsirkin" <mst@...hat.com>,
        Jason Wang <jasowang@...hat.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        Ingo Molnar <mingo@...hat.com>,
        Arseny Krasnov <arseny.krasnov@...persky.com>,
        Jorgen Hansen <jhansen@...are.com>,
        Norbert Slusarek <nslusarek@....net>,
        Andra Paraschiv <andraprs@...zon.com>,
        Colin Ian King <colin.king@...onical.com>
CC:     <kvm@...r.kernel.org>, <virtualization@...ts.linux-foundation.org>,
        <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <stsp2@...dex.ru>, <oxffffaa@...il.com>
Subject: [RFC PATCH v5 19/19] virtio/vsock: update trace event for SEQPACKET

This updates current implementation for trace event of virtio vsock:
SEQPACKET socket's type, SEQPACKET specific ops and SEQPACKET 'msg_len'
and 'msg_cnt' fields are added.

Signed-off-by: Arseny Krasnov <arseny.krasnov@...persky.com>
---
 .../events/vsock_virtio_transport_common.h    | 48 +++++++++++++++----
 net/vmw_vsock/virtio_transport_common.c       | 25 +++++++++-
 2 files changed, 61 insertions(+), 12 deletions(-)

diff --git a/include/trace/events/vsock_virtio_transport_common.h b/include/trace/events/vsock_virtio_transport_common.h
index 6782213778be..23bc0f39c450 100644
--- a/include/trace/events/vsock_virtio_transport_common.h
+++ b/include/trace/events/vsock_virtio_transport_common.h
@@ -9,9 +9,12 @@
 #include <linux/tracepoint.h>
 
 TRACE_DEFINE_ENUM(VIRTIO_VSOCK_TYPE_STREAM);
+TRACE_DEFINE_ENUM(VIRTIO_VSOCK_TYPE_SEQPACKET);
 
 #define show_type(val) \
-	__print_symbolic(val, { VIRTIO_VSOCK_TYPE_STREAM, "STREAM" })
+	__print_symbolic(val, \
+				{ VIRTIO_VSOCK_TYPE_STREAM, "STREAM" }, \
+				{ VIRTIO_VSOCK_TYPE_SEQPACKET, "SEQPACKET" })
 
 TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_INVALID);
 TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_REQUEST);
@@ -21,6 +24,8 @@ TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_SHUTDOWN);
 TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_RW);
 TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_CREDIT_UPDATE);
 TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_CREDIT_REQUEST);
+TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_SEQ_BEGIN);
+TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_SEQ_END);
 
 #define show_op(val) \
 	__print_symbolic(val, \
@@ -31,7 +36,9 @@ TRACE_DEFINE_ENUM(VIRTIO_VSOCK_OP_CREDIT_REQUEST);
 			 { VIRTIO_VSOCK_OP_SHUTDOWN, "SHUTDOWN" }, \
 			 { VIRTIO_VSOCK_OP_RW, "RW" }, \
 			 { VIRTIO_VSOCK_OP_CREDIT_UPDATE, "CREDIT_UPDATE" }, \
-			 { VIRTIO_VSOCK_OP_CREDIT_REQUEST, "CREDIT_REQUEST" })
+			 { VIRTIO_VSOCK_OP_CREDIT_REQUEST, "CREDIT_REQUEST" }, \
+			 { VIRTIO_VSOCK_OP_SEQ_BEGIN, "SEQ_BEGIN" }, \
+			 { VIRTIO_VSOCK_OP_SEQ_END, "SEQ_END" })
 
 TRACE_EVENT(virtio_transport_alloc_pkt,
 	TP_PROTO(
@@ -40,7 +47,9 @@ TRACE_EVENT(virtio_transport_alloc_pkt,
 		 __u32 len,
 		 __u16 type,
 		 __u16 op,
-		 __u32 flags
+		 __u32 flags,
+		 __u32 msg_len,
+		 __u32 msg_cnt
 	),
 	TP_ARGS(
 		src_cid, src_port,
@@ -48,7 +57,9 @@ TRACE_EVENT(virtio_transport_alloc_pkt,
 		len,
 		type,
 		op,
-		flags
+		flags,
+		msg_len,
+		msg_cnt
 	),
 	TP_STRUCT__entry(
 		__field(__u32, src_cid)
@@ -59,6 +70,8 @@ TRACE_EVENT(virtio_transport_alloc_pkt,
 		__field(__u16, type)
 		__field(__u16, op)
 		__field(__u32, flags)
+		__field(__u32, msg_len)
+		__field(__u32, msg_cnt)
 	),
 	TP_fast_assign(
 		__entry->src_cid = src_cid;
@@ -69,14 +82,19 @@ TRACE_EVENT(virtio_transport_alloc_pkt,
 		__entry->type = type;
 		__entry->op = op;
 		__entry->flags = flags;
+		__entry->msg_len = msg_len;
+		__entry->msg_cnt = msg_cnt;
 	),
-	TP_printk("%u:%u -> %u:%u len=%u type=%s op=%s flags=%#x",
+	TP_printk("%u:%u -> %u:%u len=%u type=%s op=%s flags=%#x "
+		  "msg_len=%u msg_cnt=%u",
 		  __entry->src_cid, __entry->src_port,
 		  __entry->dst_cid, __entry->dst_port,
 		  __entry->len,
 		  show_type(__entry->type),
 		  show_op(__entry->op),
-		  __entry->flags)
+		  __entry->flags,
+		  __entry->msg_len,
+		  __entry->msg_cnt)
 );
 
 TRACE_EVENT(virtio_transport_recv_pkt,
@@ -88,7 +106,9 @@ TRACE_EVENT(virtio_transport_recv_pkt,
 		 __u16 op,
 		 __u32 flags,
 		 __u32 buf_alloc,
-		 __u32 fwd_cnt
+		 __u32 fwd_cnt,
+		 __u32 msg_len,
+		 __u32 msg_cnt
 	),
 	TP_ARGS(
 		src_cid, src_port,
@@ -98,7 +118,9 @@ TRACE_EVENT(virtio_transport_recv_pkt,
 		op,
 		flags,
 		buf_alloc,
-		fwd_cnt
+		fwd_cnt,
+		msg_len,
+		msg_cnt
 	),
 	TP_STRUCT__entry(
 		__field(__u32, src_cid)
@@ -111,6 +133,8 @@ TRACE_EVENT(virtio_transport_recv_pkt,
 		__field(__u32, flags)
 		__field(__u32, buf_alloc)
 		__field(__u32, fwd_cnt)
+		__field(__u32, msg_len)
+		__field(__u32, msg_cnt)
 	),
 	TP_fast_assign(
 		__entry->src_cid = src_cid;
@@ -123,9 +147,11 @@ TRACE_EVENT(virtio_transport_recv_pkt,
 		__entry->flags = flags;
 		__entry->buf_alloc = buf_alloc;
 		__entry->fwd_cnt = fwd_cnt;
+		__entry->msg_len = msg_len;
+		__entry->msg_cnt = msg_cnt;
 	),
 	TP_printk("%u:%u -> %u:%u len=%u type=%s op=%s flags=%#x "
-		  "buf_alloc=%u fwd_cnt=%u",
+		  "buf_alloc=%u fwd_cnt=%u msg_len=%u msg_cnt=%u",
 		  __entry->src_cid, __entry->src_port,
 		  __entry->dst_cid, __entry->dst_port,
 		  __entry->len,
@@ -133,7 +159,9 @@ TRACE_EVENT(virtio_transport_recv_pkt,
 		  show_op(__entry->op),
 		  __entry->flags,
 		  __entry->buf_alloc,
-		  __entry->fwd_cnt)
+		  __entry->fwd_cnt,
+		  __entry->msg_len,
+		  __entry->msg_cnt)
 );
 
 #endif /* _TRACE_VSOCK_VIRTIO_TRANSPORT_COMMON_H */
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index 8431d0a891ed..2ab5291e2bf7 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -47,6 +47,8 @@ virtio_transport_alloc_pkt(struct virtio_vsock_pkt_info *info,
 {
 	struct virtio_vsock_pkt *pkt;
 	int err;
+	u32 msg_len = 0;
+	u32 msg_cnt = 0;
 
 	pkt = kzalloc(sizeof(*pkt), GFP_KERNEL);
 	if (!pkt)
@@ -74,6 +76,14 @@ virtio_transport_alloc_pkt(struct virtio_vsock_pkt_info *info,
 		err = memcpy_from_msg(pkt->buf, info->msg, len);
 		if (err)
 			goto out;
+
+		if (info->op == VIRTIO_VSOCK_OP_SEQ_BEGIN ||
+		    info->op == VIRTIO_VSOCK_OP_SEQ_END) {
+			struct virtio_vsock_seq_hdr *seq_hdr = pkt->buf;
+
+			msg_len = le32_to_cpu(seq_hdr->msg_len);
+			msg_cnt = le32_to_cpu(seq_hdr->msg_cnt);
+		}
 	}
 
 	trace_virtio_transport_alloc_pkt(src_cid, src_port,
@@ -81,7 +91,7 @@ virtio_transport_alloc_pkt(struct virtio_vsock_pkt_info *info,
 					 len,
 					 info->type,
 					 info->op,
-					 info->flags);
+					 info->flags, msg_len, msg_cnt);
 
 	return pkt;
 
@@ -1336,12 +1346,22 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
 	struct vsock_sock *vsk;
 	struct sock *sk;
 	bool space_available;
+	u32 msg_len = 0;
+	u32 msg_cnt = 0;
 
 	vsock_addr_init(&src, le64_to_cpu(pkt->hdr.src_cid),
 			le32_to_cpu(pkt->hdr.src_port));
 	vsock_addr_init(&dst, le64_to_cpu(pkt->hdr.dst_cid),
 			le32_to_cpu(pkt->hdr.dst_port));
 
+	if (le16_to_cpu(pkt->hdr.op) == VIRTIO_VSOCK_OP_SEQ_BEGIN ||
+	    le16_to_cpu(pkt->hdr.op) == VIRTIO_VSOCK_OP_SEQ_END) {
+		struct virtio_vsock_seq_hdr *seq_hdr = pkt->buf;
+
+		msg_len = le32_to_cpu(seq_hdr->msg_len);
+		msg_cnt = le32_to_cpu(seq_hdr->msg_cnt);
+	}
+
 	trace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,
 					dst.svm_cid, dst.svm_port,
 					le32_to_cpu(pkt->hdr.len),
@@ -1349,7 +1369,8 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
 					le16_to_cpu(pkt->hdr.op),
 					le32_to_cpu(pkt->hdr.flags),
 					le32_to_cpu(pkt->hdr.buf_alloc),
-					le32_to_cpu(pkt->hdr.fwd_cnt));
+					le32_to_cpu(pkt->hdr.fwd_cnt),
+					msg_len, msg_cnt);
 
 	if (!virtio_transport_valid_type(le16_to_cpu(pkt->hdr.type))) {
 		(void)virtio_transport_reset_no_sock(t, pkt);
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ