vsock/vmci: Clear the vmci transport packet properly when initializing it
Subsystems (5)
PATCH 1/1 vsock/vmci: Clear the vmci transport packet properly when initializing it
From: HarshaVardhana S A <[email protected]>
In vmci_transport_packet_init memset the vmci_transport_packet before populating the fields to avoid any uninitialised data being left in the structure.
---
Tweaked from original version by rewording the text and adding a blank line and correctly sending it to the proper people for inclusion in net.
net/vmw_vsock/vmci_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/vmw_vsock/vmci_transport.c +2 -2
@@ -119,6 +119,8 @@ vmci_transport_packet_init(struct vmci_transport_packet *pkt,u16 proto, struct vmci_handle handle) { + memset(pkt, 0, sizeof(*pkt)); +/* We register the stream control handler as an any cid handle so we * must always send from a source address of VMADDR_CID_ANY */
@@ -131,8 +133,6 @@ vmci_transport_packet_init(struct vmci_transport_packet *pkt, pkt->type = type; pkt->src_port = src->svm_port; pkt->dst_port = dst->svm_port; -memset (&pkt->proto,0 ,sizeof (pkt->proto)); -memset (&pkt->_reserved2,0 ,sizeof (pkt->_reserved2));switch (pkt->type) {case VMCI_TRANSPORT_PACKET_TYPE_INVALID :
Signature · 1 line
2.50.0
Stefano Garzarella
maintainerQuoted 5 lines · Greg Kroah-Hartman
From: HarshaVardhana S A <[email protected]>
In
vmci_transport_packet_initmemset thevmci_transport_packetbefore populating the fields to avoid any uninitialised data being left in the structure.
Usually I would suggest inserting a Fixes tag, but if you didn't put it, there's probably a reason :-)
If we are going to add it, I think it should be:
Quoted 36 lines
Cc Bryan Tan <[email protected]>Cc Vishnu Dasa <[email protected]>Cc Broadcom internal kernel review listCc Stefano Garzarella <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Simon Horman <[email protected]>Cc stable <[email protected]>Signed-off-by HarshaVardhana S A <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>---
Tweaked from original version by rewording the text and adding a blank line and correctly sending it to the proper people for inclusion in net.
net/vmw_vsock/vmci_transport.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)net/vmw_vsock/vmci_transport.c +2
-0@@ -119,6 +119,8 @@ vmci_transport_packet_init(struct vmci_transport_packet *pkt,u16 proto, struct vmci_handle handle) { + memset(pkt, 0, sizeof(*pkt)); +/* We register the stream control handler as an any cid handle so we * must always send from a source address of VMADDR_CID_ANY */
net/vmw_vsock/vmci_transport.c vmci_transport_packet_init(struct vmci_transport_packet *pkt, · line 135
Quoted 5 lines
net/vmw_vsock/vmci_transport.c +0
-2@@ -131,8 +133,6 @@ vmci_transport_packet_init(struct vmci_transport_packet *pkt, pkt->type = type; pkt->src_port = src->svm_port; pkt->dst_port = dst->svm_port; -memset (&pkt->proto,0 ,sizeof (pkt->proto)); -memset (&pkt->_reserved2,0 ,sizeof (pkt->_reserved2));
Should we also remove some cases in the following switch? I mean something like this:
net/vmw_vsock/vmci_transport.c +0 -10
@@ -135,10 +135,6 @@ vmci_transport_packet_init(struct vmci_transport_packet *pkt,memset (&pkt->_reserved2,0 ,sizeof (pkt->_reserved2));switch (pkt->type) { -case VMCI_TRANSPORT_PACKET_TYPE_INVALID : - pkt->u.size =0 ; -break ; -case VMCI_TRANSPORT_PACKET_TYPE_REQUEST :case VMCI_TRANSPORT_PACKET_TYPE_NEGOTIATE : pkt->u.size = size;
@@ -149,12 +145,6 @@ vmci_transport_packet_init(struct vmci_transport_packet *pkt, pkt->u.handle = handle;break ; -case VMCI_TRANSPORT_PACKET_TYPE_WROTE : -case VMCI_TRANSPORT_PACKET_TYPE_READ : -case VMCI_TRANSPORT_PACKET_TYPE_RST : - pkt->u.size =0 ; -break ; -case VMCI_TRANSPORT_PACKET_TYPE_SHUTDOWN : pkt->u.mode = mode;break ;
Thanks,
Stefano
Quoted 6 lines
net/vmw_vsock/vmci_transport.c +0
-0switch (pkt->type) {case VMCI_TRANSPORT_PACKET_TYPE_INVALID :Signature · 1 line
2.50.0
Quoted 7 lines · Stefano Garzarella
Quoted 5 lines · Greg Kroah-Hartman
From: HarshaVardhana S A <[email protected]>
In
vmci_transport_packet_initmemset thevmci_transport_packetbefore populating the fields to avoid any uninitialised data being left in the structure.
Quoted 6 lines
Usually I would suggest inserting a Fixes tag, but if you didn't put it, there's probably a reason :-)
If we are going to add it, I think it should be:
Fixes d021c344051a ("VSOCK: Introduce VM Sockets")
Yeah, I didn't think it was needed as this is obviously a "ever since this file has been there" type of thing, so it will be backported everywhere once it hits Linus's tree.
thanks,
greg k-h
Stefano Garzarella
maintainerQuoted 11 lines · Greg Kroah-Hartman
Quoted 10 lines · Stefano Garzarella
Quoted 5 lines · Greg Kroah-Hartman
From: HarshaVardhana S A <[email protected]>
In
vmci_transport_packet_initmemset thevmci_transport_packetbefore populating the fields to avoid any uninitialised data being left in the structure.Usually I would suggest inserting a Fixes tag, but if you didn't put it, there's probably a reason :-)
Quoted 7 lines
Quoted 3 lines
If we are going to add it, I think it should be:
Fixes d021c344051a ("VSOCK: Introduce VM Sockets")Yeah, I didn't think it was needed as this is obviously a "ever since this file has been there" type of thing, so it will be backported everywhere once it hits Linus's tree.
I see, thanks!
Stefano
Quoted 20 lines · Greg Kroah-Hartman
From: HarshaVardhana S A <[email protected]>
In
vmci_transport_packet_initmemset thevmci_transport_packetbefore populating the fields to avoid any uninitialised data being left in the structure.Cc Bryan Tan <[email protected]>Cc Vishnu Dasa <[email protected]>Cc Broadcom internal kernel review listCc Stefano Garzarella <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Simon Horman <[email protected]>Cc stable <[email protected]>Signed-off-by HarshaVardhana S A <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 6 lines
---
Tweaked from original version by rewording the text and adding a blank line and correctly sending it to the proper people for inclusion in net.
net/vmw_vsock/vmci_transport.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)
Patch LGTM, we can fix the switch later.
Stefano
Quoted 26 lines
net/vmw_vsock/vmci_transport.c +2
-2@@ -119,6 +119,8 @@ vmci_transport_packet_init(struct vmci_transport_packet *pkt,u16 proto, struct vmci_handle handle) { + memset(pkt, 0, sizeof(*pkt)); +/* We register the stream control handler as an any cid handle so we * must always send from a source address of VMADDR_CID_ANY */ @@ -131,8 +133,6 @@ vmci_transport_packet_init(struct vmci_transport_packet *pkt, pkt->type = type; pkt->src_port = src->svm_port; pkt->dst_port = dst->svm_port; -memset (&pkt->proto,0 ,sizeof (pkt->proto)); -memset (&pkt->_reserved2,0 ,sizeof (pkt->_reserved2));switch (pkt->type) {case VMCI_TRANSPORT_PACKET_TYPE_INVALID :Signature · 1 line
2.50.0
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 21 lines · On Tue, 1 Jul 2025 14:22:54 +0200 you wrote:
From: HarshaVardhana S A <[email protected]>
In
vmci_transport_packet_initmemset thevmci_transport_packetbefore populating the fields to avoid any uninitialised data being left in the structure.Cc Bryan Tan <[email protected]>Cc Vishnu Dasa <[email protected]>Cc Broadcom internal kernel review listCc Stefano Garzarella <[email protected]>Cc "David S. Miller" <[email protected]>Cc Eric Dumazet <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Paolo Abeni <[email protected]>Cc Simon Horman <[email protected]>Cc stable <[email protected]>Signed-off-by HarshaVardhana S A <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Quoted 1 line
[...]
Here is the summary with links:
- [net] vsock/vmci: Clear the vmci transport packet properly when initializing it
https://git.kernel.org/netdev/net/c/223e2288f4b8
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html