Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vsock/vmci: Clear the vmci transport packet properly when initializing it

In vmci_transport_packet_init memset the vmci_transport_packet before
populating the fields to avoid any uninitialised data being left in the
structure.

Cc: Bryan Tan <bryan-bt.tan@broadcom.com>
Cc: Vishnu Dasa <vishnu.dasa@broadcom.com>
Cc: Broadcom internal kernel review list
Cc: Stefano Garzarella <sgarzare@redhat.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>
Cc: virtualization@lists.linux.dev
Cc: netdev@vger.kernel.org
Cc: stable <stable@kernel.org>
Signed-off-by: HarshaVardhana S A <harshavardhana.sa@broadcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Fixes: d021c344051a ("VSOCK: Introduce VM Sockets")
Acked-by: Stefano Garzarella <sgarzare@redhat.com>
Link: https://patch.msgid.link/20250701122254.2397440-1-gregkh@linuxfoundation.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

HarshaVardhana S A and committed by
Paolo Abeni
223e2288 f030713e

+2 -2
+2 -2
net/vmw_vsock/vmci_transport.c
··· 119 119 u16 proto, 120 120 struct vmci_handle handle) 121 121 { 122 + memset(pkt, 0, sizeof(*pkt)); 123 + 122 124 /* We register the stream control handler as an any cid handle so we 123 125 * must always send from a source address of VMADDR_CID_ANY 124 126 */ ··· 133 131 pkt->type = type; 134 132 pkt->src_port = src->svm_port; 135 133 pkt->dst_port = dst->svm_port; 136 - memset(&pkt->proto, 0, sizeof(pkt->proto)); 137 - memset(&pkt->_reserved2, 0, sizeof(pkt->_reserved2)); 138 134 139 135 switch (pkt->type) { 140 136 case VMCI_TRANSPORT_PACKET_TYPE_INVALID: