* [PATCH v2] vsock/vmci: reject datagram binds in local network namespaces
@ 2026-11-17 19:01 Sergio Lopez
2026-11-17 19:07 ` sashiko-bot
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Sergio Lopez @ 2026-11-17 19:01 UTC (permalink / raw)
To: Bryan Tan, Vishnu Dasa, Broadcom internal kernel review list,
Stefano Garzarella, Bobby Eshleman, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Michael S. Tsirkin
Cc: linux-kernel, virtualization, netdev, stable, Sergio Lopez
VMCI already rejects datagram sends from local network namespaces, but a
datagram bind still creates a receive handle in VMCI's global port space.
A VMCI sender outside the namespace can therefore deliver to the local
socket. Its handle also prevents a global-namespace socket from binding
the same port.
Reject VMCI datagram binds in local namespaces. No namespace-local
datagram transport exists, so EOPNOTSUPP reflects the available receive
paths. Unbound datagram connect() and sendmsg() also return EOPNOTSUPP
because both call vsock_auto_bind(). The receive callback rejects any
local-mode socket as a defensive check.
In a KASAN/lockdep QEMU guest, a reproducer observed cross-namespace
delivery and the global port collision before the fix. After the fix,
local bind returns EOPNOTSUPP, the global bind succeeds, and a global
VMCI datagram still reaches the global socket.
Fixes: eafb64f40ca4 ("vsock: add netns to vsock core")
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/sashiko-outbox-212907@kernel.org/
Acked-by: Bobby Eshleman <bobbyeshleman@meta.com>
Signed-off-by: Sergio Lopez <slp@redhat.com>
---
Changes in v2:
- Combine the VMCI receive checks and clarify the auto-bind effects on
datagram connect() and sendmsg() (thanks to Stefano Garzarella).
- Carry Bobby Eshleman's Acked-by.
- Link to v1: https://lore.kernel.org/r/20261113-vsock-vmci-netns-isolation-v1-1-ced02054ea61@redhat.com
---
net/vmw_vsock/vmci_transport.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c
index 1f186e8f8364..d53704e31af3 100644
--- a/net/vmw_vsock/vmci_transport.c
+++ b/net/vmw_vsock/vmci_transport.c
@@ -627,7 +627,8 @@ static int vmci_transport_recv_dgram_cb(void *data, struct vmci_datagram *dg)
* outside of the create and destruct socket functions.
*/
vsk = vsock_sk(sk);
- if (!vmci_transport_allow_dgram(vsk, dg->src.context))
+ if (!vsock_net_mode_global(vsk) ||
+ !vmci_transport_allow_dgram(vsk, dg->src.context))
return VMCI_ERROR_NO_ACCESS;
size = VMCI_DG_SIZE(dg);
@@ -1697,6 +1698,10 @@ static int vmci_transport_dgram_bind(struct vsock_sock *vsk,
u32 flags;
int err;
+ /* VMCI handles are global and cannot serve local namespaces. */
+ if (!vsock_net_mode_global(vsk))
+ return -EOPNOTSUPP;
+
/* VMCI will select a resource ID for us if we provide
* VMCI_INVALID_ID.
*/
---
base-commit: 65ba8f34ec886ec72b2c07ddc8cf3d815c32869d
change-id: 20261113-vsock-vmci-netns-isolation-7e46732dcd73
Best regards,
--
Sergio Lopez <slp@redhat.com>
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] vsock/vmci: reject datagram binds in local network namespaces
2026-11-17 19:01 [PATCH v2] vsock/vmci: reject datagram binds in local network namespaces Sergio Lopez
@ 2026-11-17 19:07 ` sashiko-bot
2026-11-18 22:07 ` Vishnu Dasa
2026-11-19 9:10 ` Stefano Garzarella
2 siblings, 0 replies; 4+ messages in thread
From: sashiko-bot @ 2026-11-17 19:07 UTC (permalink / raw)
To: Sergio Lopez; +Cc: virtualization, Michael S. Tsirkin, Eugenio Perez
> VMCI already rejects datagram sends from local network namespaces, but a
> datagram bind still creates a receive handle in VMCI's global port space.
> A VMCI sender outside the namespace can therefore deliver to the local
> socket. Its handle also prevents a global-namespace socket from binding
> the same port.
>
> Reject VMCI datagram binds in local namespaces. No namespace-local
> datagram transport exists, so EOPNOTSUPP reflects the available receive
> paths. Unbound datagram connect() and sendmsg() also return EOPNOTSUPP
> because both call vsock_auto_bind(). The receive callback rejects any
> local-mode socket as a defensive check.
>
> In a KASAN/lockdep QEMU guest, a reproducer observed cross-namespace
> delivery and the global port collision before the fix. After the fix,
> local bind returns EOPNOTSUPP, the global bind succeeds, and a global
> VMCI datagram still reaches the global socket.
>
> Fixes: eafb64f40ca4 ("vsock: add netns to vsock core")
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/all/sashiko-outbox-212907@kernel.org/
> Acked-by: Bobby Eshleman <bobbyeshleman@meta.com>
> Signed-off-by: Sergio Lopez <slp@redhat.com>
Sashiko has reviewed this patch and found no issues.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-vsock-vmci-netns-isolation-v2-1-d6f35e86416a@redhat.com?part=1
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] vsock/vmci: reject datagram binds in local network namespaces
2026-11-17 19:01 [PATCH v2] vsock/vmci: reject datagram binds in local network namespaces Sergio Lopez
2026-11-17 19:07 ` sashiko-bot
@ 2026-11-18 22:07 ` Vishnu Dasa
2026-11-19 9:10 ` Stefano Garzarella
2 siblings, 0 replies; 4+ messages in thread
From: Vishnu Dasa @ 2026-11-18 22:07 UTC (permalink / raw)
To: Sergio Lopez
Cc: Bryan Tan, Broadcom internal kernel review list,
Stefano Garzarella, Bobby Eshleman, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, Michael S. Tsirkin,
linux-kernel, virtualization, netdev, stable
[-- Attachment #1: Type: text/plain, Size: 3091 bytes --]
On Tue, Nov 17, 2026 at 11:02 AM 'Sergio Lopez' via
BCM-KERNEL-FEEDBACK-LIST,PDL
<bcm-kernel-feedback-list.pdl@broadcom.com> wrote:
>
> VMCI already rejects datagram sends from local network namespaces, but a
> datagram bind still creates a receive handle in VMCI's global port space.
> A VMCI sender outside the namespace can therefore deliver to the local
> socket. Its handle also prevents a global-namespace socket from binding
> the same port.
>
> Reject VMCI datagram binds in local namespaces. No namespace-local
> datagram transport exists, so EOPNOTSUPP reflects the available receive
> paths. Unbound datagram connect() and sendmsg() also return EOPNOTSUPP
> because both call vsock_auto_bind(). The receive callback rejects any
> local-mode socket as a defensive check.
>
> In a KASAN/lockdep QEMU guest, a reproducer observed cross-namespace
> delivery and the global port collision before the fix. After the fix,
> local bind returns EOPNOTSUPP, the global bind succeeds, and a global
> VMCI datagram still reaches the global socket.
>
> Fixes: eafb64f40ca4 ("vsock: add netns to vsock core")
> Cc: stable@vger.kernel.org
> Link: https://lore.kernel.org/all/sashiko-outbox-212907@kernel.org/
> Acked-by: Bobby Eshleman <bobbyeshleman@meta.com>
> Signed-off-by: Sergio Lopez <slp@redhat.com>
Acked-by: Vishnu Dasa <vishnu.dasa@broadcom.com>
> ---
> Changes in v2:
> - Combine the VMCI receive checks and clarify the auto-bind effects on
> datagram connect() and sendmsg() (thanks to Stefano Garzarella).
> - Carry Bobby Eshleman's Acked-by.
> - Link to v1: https://lore.kernel.org/r/20261113-vsock-vmci-netns-isolation-v1-1-ced02054ea61@redhat.com
> ---
> net/vmw_vsock/vmci_transport.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c
> index 1f186e8f8364..d53704e31af3 100644
> --- a/net/vmw_vsock/vmci_transport.c
> +++ b/net/vmw_vsock/vmci_transport.c
> @@ -627,7 +627,8 @@ static int vmci_transport_recv_dgram_cb(void *data, struct vmci_datagram *dg)
> * outside of the create and destruct socket functions.
> */
> vsk = vsock_sk(sk);
> - if (!vmci_transport_allow_dgram(vsk, dg->src.context))
> + if (!vsock_net_mode_global(vsk) ||
> + !vmci_transport_allow_dgram(vsk, dg->src.context))
> return VMCI_ERROR_NO_ACCESS;
>
> size = VMCI_DG_SIZE(dg);
> @@ -1697,6 +1698,10 @@ static int vmci_transport_dgram_bind(struct vsock_sock *vsk,
> u32 flags;
> int err;
>
> + /* VMCI handles are global and cannot serve local namespaces. */
> + if (!vsock_net_mode_global(vsk))
> + return -EOPNOTSUPP;
> +
> /* VMCI will select a resource ID for us if we provide
> * VMCI_INVALID_ID.
> */
>
> ---
> base-commit: 65ba8f34ec886ec72b2c07ddc8cf3d815c32869d
> change-id: 20261113-vsock-vmci-netns-isolation-7e46732dcd73
>
> Best regards,
> --
> Sergio Lopez <slp@redhat.com>
>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5417 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH v2] vsock/vmci: reject datagram binds in local network namespaces
2026-11-17 19:01 [PATCH v2] vsock/vmci: reject datagram binds in local network namespaces Sergio Lopez
2026-11-17 19:07 ` sashiko-bot
2026-11-18 22:07 ` Vishnu Dasa
@ 2026-11-19 9:10 ` Stefano Garzarella
2 siblings, 0 replies; 4+ messages in thread
From: Stefano Garzarella @ 2026-11-19 9:10 UTC (permalink / raw)
To: Sergio Lopez
Cc: Bryan Tan, Vishnu Dasa, Broadcom internal kernel review list,
Bobby Eshleman, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Michael S. Tsirkin, linux-kernel,
virtualization, netdev, stable
On Tue, Nov 17, 2026 at 08:01:52PM +0100, Sergio Lopez wrote:
>VMCI already rejects datagram sends from local network namespaces, but a
>datagram bind still creates a receive handle in VMCI's global port space.
>A VMCI sender outside the namespace can therefore deliver to the local
>socket. Its handle also prevents a global-namespace socket from binding
>the same port.
>
>Reject VMCI datagram binds in local namespaces. No namespace-local
>datagram transport exists, so EOPNOTSUPP reflects the available receive
>paths. Unbound datagram connect() and sendmsg() also return EOPNOTSUPP
>because both call vsock_auto_bind(). The receive callback rejects any
>local-mode socket as a defensive check.
>
>In a KASAN/lockdep QEMU guest, a reproducer observed cross-namespace
>delivery and the global port collision before the fix. After the fix,
>local bind returns EOPNOTSUPP, the global bind succeeds, and a global
>VMCI datagram still reaches the global socket.
>
>Fixes: eafb64f40ca4 ("vsock: add netns to vsock core")
>Cc: stable@vger.kernel.org
>Link: https://lore.kernel.org/all/sashiko-outbox-212907@kernel.org/
>Acked-by: Bobby Eshleman <bobbyeshleman@meta.com>
>Signed-off-by: Sergio Lopez <slp@redhat.com>
>---
>Changes in v2:
>- Combine the VMCI receive checks and clarify the auto-bind effects on
> datagram connect() and sendmsg() (thanks to Stefano Garzarella).
>- Carry Bobby Eshleman's Acked-by.
>- Link to v1: https://lore.kernel.org/r/20261113-vsock-vmci-netns-isolation-v1-1-ced02054ea61@redhat.com
>---
> net/vmw_vsock/vmci_transport.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-19 9:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-17 19:01 [PATCH v2] vsock/vmci: reject datagram binds in local network namespaces Sergio Lopez
2026-11-17 19:07 ` sashiko-bot
2026-11-18 22:07 ` Vishnu Dasa
2026-11-19 9:10 ` Stefano Garzarella
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox