Skip to contentSkip to conversation

vsock: only deliver taps to namespaces that can reach the device

PATCH Applied Bobby Eshleman 6 participants 12 messages Nov 16 – Nov 24

Subsystems (7)
lore
Share & tools
lore

Bobby Eshleman

author reviewer
#0 lore raw

PATCH 1/1 vsock: only deliver taps to namespaces that can reach the device

vsock_deliver_tap() clones every packet to every vsockmon device on the system. Creating one needs only CAP_NET_ADMIN in the owning user namespace, so an unprivileged user can capture the traffic of local mode namespaces.

Pass the packet's netns to vsock_deliver_tap() and only deliver to devices that pass vsock_net_check_mode(), the same rule socket lookups use. vhost passes the vhost_vsock netns, loopback the sending socket's netns, and virtio-vsock NULL (global mode).

Fixes a69686327e42 ("vsock: add netns support to virtio transports")
---
 drivers/vhost/vsock.c                   |  4 ++--
 include/linux/virtio_vsock.h            |  2 +-
 include/net/af_vsock.h                  |  3 ++-
 net/vmw_vsock/af_vsock_tap.c            | 10 +++++++---
 net/vmw_vsock/virtio_transport.c        |  4 ++--
 net/vmw_vsock/virtio_transport_common.c |  4 ++--
 net/vmw_vsock/vsock_loopback.c          |  2 +-
 7 files changed, 17 insertions(+), 12 deletions(-)
drivers/vhost/vsock.c +2 -2
index 88a310390eb0..3de1f1920717 100644
@@ -229,7 +229,7 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock,
 		/* Deliver to monitoring devices all packets that we
 		 * will transmit.
 		 */
-		virtio_transport_deliver_tap_pkt(skb);
+		virtio_transport_deliver_tap_pkt(skb, vsock->net);
 
 		vhost_add_used(vq, head, sizeof(*hdr) + payload_len);
 		added = true;
@@ -567,7 +567,7 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work)
 		total_len += sizeof(*hdr) + skb->len;
 
 		/* Deliver to monitoring devices all received packets */
-		virtio_transport_deliver_tap_pkt(skb);
+		virtio_transport_deliver_tap_pkt(skb, vsock->net);
 
 		hdr = virtio_vsock_hdr(skb);
 
include/linux/virtio_vsock.h +1 -1
index f91704731057..46058d354940 100644
@@ -285,7 +285,7 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
 void virtio_transport_inc_tx_pkt(struct virtio_vsock_sock *vvs, struct sk_buff *skb);
 u32 virtio_transport_get_credit(struct virtio_vsock_sock *vvs, u32 wanted);
 void virtio_transport_put_credit(struct virtio_vsock_sock *vvs, u32 credit);
-void virtio_transport_deliver_tap_pkt(struct sk_buff *skb);
+void virtio_transport_deliver_tap_pkt(struct sk_buff *skb, struct net *net);
 int virtio_transport_purge_skbs(void *vsk, struct sk_buff_head *list);
 int virtio_transport_read_skb(struct vsock_sock *vsk, skb_read_actor_t read_actor);
 int virtio_transport_notify_set_rcvlowat(struct vsock_sock *vsk, int val);
include/net/af_vsock.h +2 -1
index e8481f12312e..3e28865578eb 100644
@@ -250,7 +250,8 @@ struct vsock_tap {
 
 int vsock_add_tap(struct vsock_tap *vt);
 int vsock_remove_tap(struct vsock_tap *vt);
-void vsock_deliver_tap(struct sk_buff *build_skb(void *opaque), void *opaque);
+void vsock_deliver_tap(struct sk_buff *build_skb(void *opaque), void *opaque,
+		       struct net *net);
 int __vsock_connectible_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
 				int flags);
 int vsock_connectible_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
net/vmw_vsock/af_vsock_tap.c +7 -3
index 7c5cdceabb2a..4c8821835251 100644
@@ -73,19 +73,23 @@ static int __vsock_deliver_tap_skb(struct sk_buff *skb,
 	return ret;
 }
 
-static void __vsock_deliver_tap(struct sk_buff *skb)
+static void __vsock_deliver_tap(struct sk_buff *skb, struct net *net)
 {
 	int ret;
 	struct vsock_tap *tmp;
 
 	list_for_each_entry_rcu(tmp, &vsock_tap_all, list) {
+		if (!vsock_net_check_mode(dev_net(tmp->dev), net))
+			continue;
+
 		ret = __vsock_deliver_tap_skb(skb, tmp->dev);
 		if (unlikely(ret))
 			break;
 	}
 }
 
-void vsock_deliver_tap(struct sk_buff *build_skb(void *opaque), void *opaque)
+void vsock_deliver_tap(struct sk_buff *build_skb(void *opaque), void *opaque,
+		       struct net *net)
 {
 	struct sk_buff *skb;
 
@@ -96,7 +100,7 @@ void vsock_deliver_tap(struct sk_buff *build_skb(void *opaque), void *opaque)
 
 	skb = build_skb(opaque);
 	if (skb) {
-		__vsock_deliver_tap(skb);
+		__vsock_deliver_tap(skb, net);
 		consume_skb(skb);
 	}
 
net/vmw_vsock/virtio_transport.c +2 -2
index cf63bc99f3cc..b39c001260a9 100644
@@ -150,7 +150,7 @@ static int virtio_transport_send_skb(struct sk_buff *skb, struct virtqueue *vq,
 	if (ret < 0)
 		return ret;
 
-	virtio_transport_deliver_tap_pkt(skb);
+	virtio_transport_deliver_tap_pkt(skb, NULL);
 	return 0;
 }
 
@@ -680,7 +680,7 @@ static void virtio_transport_rx_work(struct work_struct *work)
 			if (payload_len)
 				virtio_vsock_skb_put(skb, payload_len);
 
-			virtio_transport_deliver_tap_pkt(skb);
+			virtio_transport_deliver_tap_pkt(skb, NULL);
 
 			/* Force virtio-transport into global mode since it
 			 * does not yet support local-mode namespacing.
net/vmw_vsock/virtio_transport_common.c +2 -2
index 1e762a480df4..027fe41c676a 100644
@@ -190,12 +190,12 @@ static struct sk_buff *virtio_transport_build_skb(void *opaque)
 	return skb;
 }
 
-void virtio_transport_deliver_tap_pkt(struct sk_buff *skb)
+void virtio_transport_deliver_tap_pkt(struct sk_buff *skb, struct net *net)
 {
 	if (virtio_vsock_skb_tap_delivered(skb))
 		return;
 
-	vsock_deliver_tap(virtio_transport_build_skb, skb);
+	vsock_deliver_tap(virtio_transport_build_skb, skb, net);
 	virtio_vsock_skb_set_tap_delivered(skb);
 }
 EXPORT_SYMBOL_GPL(virtio_transport_deliver_tap_pkt);
net/vmw_vsock/vsock_loopback.c +1 -1
index 8068d1b6e851..cacd313a454b 100644
@@ -138,7 +138,7 @@ static void vsock_loopback_work(struct work_struct *work)
 		 * It is freed by the receiver.
 		 */
 		virtio_transport_consume_skb_sent(skb, false);
-		virtio_transport_deliver_tap_pkt(skb);
+		virtio_transport_deliver_tap_pkt(skb, sock_net(skb->sk));
 		virtio_transport_recv_pkt(&loopback_transport, skb,
 					  sock_net(skb->sk));
 	}

---
base-commit: aa40afa831ebfe45e40a23721711059f2ac584d4
change-id: 20261116-vsock-tap-net-1b09a0945779

Best regards,

Signature · 1 line
Bobby Eshleman <[email protected]>
#1 lore raw
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.

- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.

Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
author reviewer
#2 lore raw
Quoted 13 lines · On Mon, Nov 16, 2026 at 11:52:38PM +0000, [email protected] wrote:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.

- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.

Quoted 9 lines

Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.

Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

This is a known issue and has come up in review of the guest netns series (so via code inspection).

Best,
Bobby

maintainer
#3 lore raw
Quoted 18 lines · Bobby Eshleman
Quoted 17 lines · On Mon, Nov 16, 2026 at 11:52:38PM +0000, [email protected] wrote:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.

- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.

Quoted 8 lines
Quoted 5 lines

*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.

Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.

This is a known issue and has come up in review of the guest netns series (so via code inspection).

My reading of the above is this feels like more an improvement than a regression fix. As such I'll move this to net-next. Please scream out loudly very soon if you disagree.

/P

author reviewer
#4 lore raw
Quoted 25 lines · Paolo Abeni
Quoted 24 lines · Bobby Eshleman
Quoted 22 lines · On Mon, Nov 16, 2026 at 11:52:38PM +0000, [email protected] wrote:

Hi!

This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:

- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.

- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.

Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account.

*IMPORTANT*: If you do repost (for other reasons) - please include the relevant info in the cover letter or commit messages.

Signature · 2 lines
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
Quoted 8 lines
Quoted 2 lines

This is a known issue and has come up in review of the guest netns series (so via code inspection).

My reading of the above is this feels like more an improvement than a regression fix. As such I'll move this to net-next. Please scream out loudly very soon if you disagree.

/P

My net-next guest ns series actually needs this to build, maybe I should pull it back into that series?

My rationale for sending to net was that it also fixes the issue for the already merged vhost-vsock ns support. I don't have a strong opinion either way.

Best,
Bobby

#5 lore raw
In reply to Bobby Eshleman
Sashiko has reviewed this patch and found no issues.
Quoted 5 lines

vsock_deliver_tap() clones every packet to every vsockmon device on the system. Creating one needs only CAP_NET_ADMIN in the owning user namespace, so an unprivileged user can capture the traffic of local mode namespaces.

Quoted 7 lines

Pass the packet's netns to vsock_deliver_tap() and only deliver to devices that pass vsock_net_check_mode(), the same rule socket lookups use. vhost passes the vhost_vsock netns, loopback the sending socket's netns, and virtio-vsock NULL (global mode).

Fixes a69686327e42 ("vsock: add netns support to virtio transports")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#6 lore raw
In reply to Bobby Eshleman
Quoted 9 lines · Bobby Eshleman

vsock_deliver_tap() clones every packet to every vsockmon device on the system. Creating one needs only CAP_NET_ADMIN in the owning user namespace, so an unprivileged user can capture the traffic of local mode namespaces.

Pass the packet's netns to vsock_deliver_tap() and only deliver to devices that pass vsock_net_check_mode(), the same rule socket lookups use. vhost passes the vhost_vsock netns, loopback the sending socket's netns, and virtio-vsock NULL (global mode).

For local namespaces I think we are fine, but what about global?

Is it okay that a namespace with global can capture all the packets of other global namespaces?

Asking because at this point the CAP_NET_ADMIN is useless, since an user on a global namespace, without CAP_NET_ADMIN, can just create a namespace to have CAP_NET_ADMIN and access all the traffic. Should we fix also that?

Thanks,
Stefano

Quoted 164 lines
Fixes a69686327e42 ("vsock: add netns support to virtio transports")

---

drivers/vhost/vsock.c                   |  4 ++--
include/linux/virtio_vsock.h            |  2 +-
include/net/af_vsock.h                  |  3 ++-
net/vmw_vsock/af_vsock_tap.c            | 10 +++++++---
net/vmw_vsock/virtio_transport.c        |  4 ++--
net/vmw_vsock/virtio_transport_common.c |  4 ++--
net/vmw_vsock/vsock_loopback.c          |  2 +-
7 files changed, 17 insertions(+), 12 deletions(-)
drivers/vhost/vsock.c +2 -2
index 88a310390eb0..3de1f1920717 100644
@@ -229,7 +229,7 @@ vhost_transport_do_send_pkt(struct vhost_vsock *vsock,
 		/* Deliver to monitoring devices all packets that we
 		 * will transmit.
 		 */
-		virtio_transport_deliver_tap_pkt(skb);
+		virtio_transport_deliver_tap_pkt(skb, vsock->net);
 
 		vhost_add_used(vq, head, sizeof(*hdr) + payload_len);
 		added = true;
@@ -567,7 +567,7 @@ static void vhost_vsock_handle_tx_kick(struct vhost_work *work)
 		total_len += sizeof(*hdr) + skb->len;
 
 		/* Deliver to monitoring devices all received packets */
-		virtio_transport_deliver_tap_pkt(skb);
+		virtio_transport_deliver_tap_pkt(skb, vsock->net);
 
 		hdr = virtio_vsock_hdr(skb);
 
include/linux/virtio_vsock.h +1 -1
index f91704731057..46058d354940 100644
@@ -285,7 +285,7 @@ void virtio_transport_recv_pkt(struct virtio_transport *t,
 void virtio_transport_inc_tx_pkt(struct virtio_vsock_sock *vvs, struct sk_buff *skb);
 u32 virtio_transport_get_credit(struct virtio_vsock_sock *vvs, u32 wanted);
 void virtio_transport_put_credit(struct virtio_vsock_sock *vvs, u32 credit);
-void virtio_transport_deliver_tap_pkt(struct sk_buff *skb);
+void virtio_transport_deliver_tap_pkt(struct sk_buff *skb, struct net *net);
 int virtio_transport_purge_skbs(void *vsk, struct sk_buff_head *list);
 int virtio_transport_read_skb(struct vsock_sock *vsk, skb_read_actor_t read_actor);
 int virtio_transport_notify_set_rcvlowat(struct vsock_sock *vsk, int val);
include/net/af_vsock.h +2 -1
index e8481f12312e..3e28865578eb 100644
@@ -250,7 +250,8 @@ struct vsock_tap {
 
 int vsock_add_tap(struct vsock_tap *vt);
 int vsock_remove_tap(struct vsock_tap *vt);
-void vsock_deliver_tap(struct sk_buff *build_skb(void *opaque), void *opaque);
+void vsock_deliver_tap(struct sk_buff *build_skb(void *opaque), void *opaque,
+		       struct net *net);
 int __vsock_connectible_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
 				int flags);
 int vsock_connectible_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
net/vmw_vsock/af_vsock_tap.c +7 -3
index 7c5cdceabb2a..4c8821835251 100644
@@ -73,19 +73,23 @@ static int __vsock_deliver_tap_skb(struct sk_buff *skb,
 	return ret;
 }
 
-static void __vsock_deliver_tap(struct sk_buff *skb)
+static void __vsock_deliver_tap(struct sk_buff *skb, struct net *net)
 {
 	int ret;
 	struct vsock_tap *tmp;
 
 	list_for_each_entry_rcu(tmp, &vsock_tap_all, list) {
+		if (!vsock_net_check_mode(dev_net(tmp->dev), net))
+			continue;
+
 		ret = __vsock_deliver_tap_skb(skb, tmp->dev);
 		if (unlikely(ret))
 			break;
 	}
 }
 
-void vsock_deliver_tap(struct sk_buff *build_skb(void *opaque), void *opaque)
+void vsock_deliver_tap(struct sk_buff *build_skb(void *opaque), void *opaque,
+		       struct net *net)
 {
 	struct sk_buff *skb;
 
@@ -96,7 +100,7 @@ void vsock_deliver_tap(struct sk_buff *build_skb(void *opaque), void *opaque)
 
 	skb = build_skb(opaque);
 	if (skb) {
-		__vsock_deliver_tap(skb);
+		__vsock_deliver_tap(skb, net);
 		consume_skb(skb);
 	}
 
net/vmw_vsock/virtio_transport.c +2 -2
index cf63bc99f3cc..b39c001260a9 100644
@@ -150,7 +150,7 @@ static int virtio_transport_send_skb(struct sk_buff *skb, struct virtqueue *vq,
 	if (ret < 0)
 		return ret;
 
-	virtio_transport_deliver_tap_pkt(skb);
+	virtio_transport_deliver_tap_pkt(skb, NULL);
 	return 0;
 }
 
@@ -680,7 +680,7 @@ static void virtio_transport_rx_work(struct work_struct *work)
 			if (payload_len)
 				virtio_vsock_skb_put(skb, payload_len);
 
-			virtio_transport_deliver_tap_pkt(skb);
+			virtio_transport_deliver_tap_pkt(skb, NULL);
 
 			/* Force virtio-transport into global mode since it
 			 * does not yet support local-mode namespacing.
net/vmw_vsock/virtio_transport_common.c +2 -2
index 1e762a480df4..027fe41c676a 100644
@@ -190,12 +190,12 @@ static struct sk_buff *virtio_transport_build_skb(void *opaque)
 	return skb;
 }
 
-void virtio_transport_deliver_tap_pkt(struct sk_buff *skb)
+void virtio_transport_deliver_tap_pkt(struct sk_buff *skb, struct net *net)
 {
 	if (virtio_vsock_skb_tap_delivered(skb))
 		return;
 
-	vsock_deliver_tap(virtio_transport_build_skb, skb);
+	vsock_deliver_tap(virtio_transport_build_skb, skb, net);
 	virtio_vsock_skb_set_tap_delivered(skb);
 }
 EXPORT_SYMBOL_GPL(virtio_transport_deliver_tap_pkt);
net/vmw_vsock/vsock_loopback.c +1 -2
index 8068d1b6e851..cacd313a454b 100644
@@ -138,7 +138,7 @@ static void vsock_loopback_work(struct work_struct *work)
 		 * It is freed by the receiver.
 		 */
 		virtio_transport_consume_skb_sent(skb, false);
-		virtio_transport_deliver_tap_pkt(skb);
+		virtio_transport_deliver_tap_pkt(skb, sock_net(skb->sk));
 		virtio_transport_recv_pkt(&loopback_transport, skb,
 					  sock_net(skb->sk));
 	}
 
---

base-commit: aa40afa831ebfe45e40a23721711059f2ac584d4
change-id: 20261116-vsock-tap-net-1b09a0945779

Best regards,

Signature · 1 line
Bobby Eshleman <[email protected]>
maintainer
#7 lore raw
Quoted 11 lines · Stefano Garzarella
Quoted 9 lines · Bobby Eshleman

vsock_deliver_tap() clones every packet to every vsockmon device on the system. Creating one needs only CAP_NET_ADMIN in the owning user namespace, so an unprivileged user can capture the traffic of local mode namespaces.

Pass the packet's netns to vsock_deliver_tap() and only deliver to devices that pass vsock_net_check_mode(), the same rule socket lookups use. vhost passes the vhost_vsock netns, loopback the sending socket's netns, and virtio-vsock NULL (global mode).

Quoted 5 lines

For local namespaces I think we are fine, but what about global?

Is it okay that a namespace with global can capture all the packets of other global namespaces?

Asking because at this point the CAP_NET_ADMIN is useless, since an user on a global namespace, without CAP_NET_ADMIN, can just create a namespace to have CAP_NET_ADMIN and access all the traffic. Should we fix also that?

My take is that the above question is quite orthogonal to the current patch and may impact old applications relying on the legacy behavior.

/P

maintainer Reviewed-by
#8 lore raw
Quoted 12 lines · Paolo Abeni
Quoted 11 lines · Stefano Garzarella
Quoted 9 lines · Bobby Eshleman

vsock_deliver_tap() clones every packet to every vsockmon device on the system. Creating one needs only CAP_NET_ADMIN in the owning user namespace, so an unprivileged user can capture the traffic of local mode namespaces.

Pass the packet's netns to vsock_deliver_tap() and only deliver to devices that pass vsock_net_check_mode(), the same rule socket lookups use. vhost passes the vhost_vsock netns, loopback the sending socket's netns, and virtio-vsock NULL (global mode).

Quoted 7 lines
Quoted 5 lines

For local namespaces I think we are fine, but what about global?

Is it okay that a namespace with global can capture all the packets of other global namespaces?

Asking because at this point the CAP_NET_ADMIN is useless, since an user on a global namespace, without CAP_NET_ADMIN, can just create a namespace to have CAP_NET_ADMIN and access all the traffic. Should we fix also that?

My take is that the above question is quite orthogonal to the current patch and may impact old applications relying on the legacy behavior.

True, but I'm not sure that behavior was correct since the beginning.
E.g., what is the point of having CAP_NET_ADMIN requirement if an unprivileged user can just crate a new namespace and get it?

Anyway, it's eventually pre-existing netns support in vsock, so it should be fixed with a followup.

Thanks,
Stefano

author reviewer
#9 lore raw
Quoted 25 lines · Stefano Garzarella
Quoted 12 lines · Paolo Abeni
Quoted 11 lines · Stefano Garzarella
Quoted 9 lines · Bobby Eshleman

vsock_deliver_tap() clones every packet to every vsockmon device on the system. Creating one needs only CAP_NET_ADMIN in the owning user namespace, so an unprivileged user can capture the traffic of local mode namespaces.

Pass the packet's netns to vsock_deliver_tap() and only deliver to devices that pass vsock_net_check_mode(), the same rule socket lookups use. vhost passes the vhost_vsock netns, loopback the sending socket's netns, and virtio-vsock NULL (global mode).

Quoted 7 lines
Quoted 5 lines

For local namespaces I think we are fine, but what about global?

Is it okay that a namespace with global can capture all the packets of other global namespaces?

Asking because at this point the CAP_NET_ADMIN is useless, since an user on a global namespace, without CAP_NET_ADMIN, can just create a namespace to have CAP_NET_ADMIN and access all the traffic. Should we fix also that?

My take is that the above question is quite orthogonal to the current patch and may impact old applications relying on the legacy behavior.

True, but I'm not sure that behavior was correct since the beginning. E.g., what is the point of having CAP_NET_ADMIN requirement if an unprivileged user can just crate a new namespace and get it?

Quoted 9 lines

Anyway, it's eventually pre-existing netns support in vsock, so it should be fixed with a followup.

Thanks,
Stefano

Its a fair point and I agree we should take it up in a follow up. My current instinct is that CAP_NET_ADMIN probably shouldn't be enforced for some (all?) of these global-mode paths.

Best,
Bobby

#10 lore raw
Quoted 32 lines · Bobby Eshleman
Quoted 31 lines · Stefano Garzarella
Quoted 12 lines · Paolo Abeni
Quoted 11 lines · Stefano Garzarella
Quoted 9 lines · Bobby Eshleman

vsock_deliver_tap() clones every packet to every vsockmon device on the system. Creating one needs only CAP_NET_ADMIN in the owning user namespace, so an unprivileged user can capture the traffic of local mode namespaces.

Pass the packet's netns to vsock_deliver_tap() and only deliver to devices that pass vsock_net_check_mode(), the same rule socket lookups use. vhost passes the vhost_vsock netns, loopback the sending socket's netns, and virtio-vsock NULL (global mode).

Quoted 7 lines
Quoted 5 lines

For local namespaces I think we are fine, but what about global?

Is it okay that a namespace with global can capture all the packets of other global namespaces?

Asking because at this point the CAP_NET_ADMIN is useless, since an user on a global namespace, without CAP_NET_ADMIN, can just create a namespace to have CAP_NET_ADMIN and access all the traffic. Should we fix also that?

My take is that the above question is quite orthogonal to the current patch and may impact old applications relying on the legacy behavior.

True, but I'm not sure that behavior was correct since the beginning. E.g., what is the point of having CAP_NET_ADMIN requirement if an unprivileged user can just crate a new namespace and get it?

Anyway, it's eventually pre-existing netns support in vsock, so it should be fixed with a followup.

Quoted 7 lines
Quoted 3 lines

Thanks,
Stefano

Its a fair point and I agree we should take it up in a follow up. My current instinct is that CAP_NET_ADMIN probably shouldn't be enforced for some (all?) of these global-mode paths.

Why not?

I should take a closer look at what’s going on with the NICs, what permissions does someone intercepting traffic need to have?

Ideally, even though the addressing is global, maybe we should set it up so that within a namespace, you can only observe traffic generated by that namespace or its children.

But honestly, I don’t know how complicated that is. In fact, if you want isolation, you have to enable “local,” and at that point, with this patch, we’re all set.

Thanks,
Stefano

#11 lore raw
In reply to Bobby Eshleman
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 11 lines · On Mon, 16 Nov 2026 15:46:49 -0800 you wrote:

vsock_deliver_tap() clones every packet to every vsockmon device on the system. Creating one needs only CAP_NET_ADMIN in the owning user namespace, so an unprivileged user can capture the traffic of local mode namespaces.

Pass the packet's netns to vsock_deliver_tap() and only deliver to devices that pass vsock_net_check_mode(), the same rule socket lookups use. vhost passes the vhost_vsock netns, loopback the sending socket's netns, and virtio-vsock NULL (global mode).

[...]

Here is the summary with links:
- [net] vsock: only deliver taps to namespaces that can reach the device

    https://git.kernel.org/netdev/net-next/c/2388bb763e32

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html