net/vmw_vsock/vmci_transport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
From: HarshaVardhana S A <harshavardhana.sa@broadcom.com>
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>
---
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(-)
diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c
index b370070194fa..7eccd6708d66 100644
--- a/net/vmw_vsock/vmci_transport.c
+++ b/net/vmw_vsock/vmci_transport.c
@@ -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:
--
2.50.0
On Tue, Jul 01, 2025 at 02:22:54PM +0200, Greg Kroah-Hartman wrote: >From: HarshaVardhana S A <harshavardhana.sa@broadcom.com> > >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> >--- >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(-) Acked-by: Stefano Garzarella <sgarzare@redhat.com> Patch LGTM, we can fix the switch later. Stefano > >diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c >index b370070194fa..7eccd6708d66 100644 >--- a/net/vmw_vsock/vmci_transport.c >+++ b/net/vmw_vsock/vmci_transport.c >@@ -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: >-- >2.50.0 >
On Tue, Jul 01, 2025 at 02:22:54PM +0200, Greg Kroah-Hartman wrote: >From: HarshaVardhana S A <harshavardhana.sa@broadcom.com> > >In vmci_transport_packet_init memset the vmci_transport_packet before >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: Fixes: d021c344051a ("VSOCK: Introduce VM Sockets") > >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> >--- >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(-) > >diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c >index b370070194fa..7eccd6708d66 100644 >--- a/net/vmw_vsock/vmci_transport.c >+++ b/net/vmw_vsock/vmci_transport.c >@@ -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)); Should we also remove some `case`s in the following switch? I mean something like this: diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c index b370070194fa..d821ddcc62d8 100644 --- a/net/vmw_vsock/vmci_transport.c +++ b/net/vmw_vsock/vmci_transport.c @@ -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 > > switch (pkt->type) { > case VMCI_TRANSPORT_PACKET_TYPE_INVALID: >-- >2.50.0 >
On Tue, Jul 01, 2025 at 02:42:10PM +0200, Stefano Garzarella wrote: > On Tue, Jul 01, 2025 at 02:22:54PM +0200, Greg Kroah-Hartman wrote: > > From: HarshaVardhana S A <harshavardhana.sa@broadcom.com> > > > > In vmci_transport_packet_init memset the vmci_transport_packet before > > 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: > > 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
On Tue, Jul 01, 2025 at 02:56:14PM +0200, Greg Kroah-Hartman wrote: >On Tue, Jul 01, 2025 at 02:42:10PM +0200, Stefano Garzarella wrote: >> On Tue, Jul 01, 2025 at 02:22:54PM +0200, Greg Kroah-Hartman wrote: >> > From: HarshaVardhana S A <harshavardhana.sa@broadcom.com> >> > >> > In vmci_transport_packet_init memset the vmci_transport_packet before >> > 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: >> >> 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
© 2016 - 2025 Red Hat, Inc.