From: sashiko-bot@kernel.org
To: "Bobby Eshleman" <bobbyeshleman@meta.com>
Cc: virtualization@lists.linux.dev, kvm@vger.kernel.org,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH net-next v7 5/7] vsock/virtio: support guest device network namespace
Date: Thu, 19 Nov 2026 01:55:37 +0000 [thread overview]
Message-ID: <sashiko-outbox-222311@kernel.org> (raw)
In-Reply-To: <20261117-vsock-guest-ns-v7-5-7e522ea9dd9b@meta.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] vsock/virtio: swept sockets can still send and receive after
device reassign
- [Medium] vsock/virtio: bytes_unsent not decremented in
virtio_transport_purge_skbs()
--
commit 9aa3064a70d9c211d00810f1b687d67543df5469
Author: Bobby Eshleman <bobbyeshleman@meta.com>
vsock/virtio: support guest device network namespace
This commit allows assigning the virtio-vsock guest device to a network
namespace and updates connection setup, packet reception, and packet
transmission to check whether sockets can reach the assigned namespace.
> diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c
> index 1ddb6839a8fbe..ba90815362120 100644
> --- a/net/vmw_vsock/virtio_transport.c
> +++ b/net/vmw_vsock/virtio_transport.c
[ ... ]
> @@ -587,6 +589,7 @@ static struct virtio_transport virtio_transport = {
> .seqpacket_has_data = virtio_transport_seqpacket_has_data,
>
> .msgzerocopy_allow = virtio_transport_msgzerocopy_allow,
> + .netns_assign_allow = true,
>
> .notify_poll_in = virtio_transport_notify_poll_in,
> .notify_poll_out = virtio_transport_notify_poll_out,
[Severity: Medium]
Does purging queued packets on an established socket leave
vvs->bytes_unsent elevated?
Previously, virtio_transport_cancel_pkt() was only called on TCP_SYN_SENT
sockets, whose queued packets have zero payload length. With
.netns_assign_allow enabled, vsock_g2h_reset_unreachable() now calls
t->cancel_pkt(vsk) -> virtio_transport_cancel_pkt() ->
virtio_transport_purge_skbs() on TCP_ESTABLISHED sockets that may have
data SKBs queued in vsock->send_pkt_queue. virtio_transport_get_credit()
already added those payload bytes to vvs->bytes_unsent, and normally
virtio_transport_consume_skb_sent() subtracts skb->len on TX completion,
but virtio_transport_purge_skbs() frees matching SKBs with
__skb_queue_purge(&freeme) without decrementing vvs->bytes_unsent.
As a result, SIOCOUTQ reports stale unsent bytes on the reset socket, and
a concurrent close() sleeping in vsock_linger() stalls until
sk_lingertime expires because virtio_transport_unsent_bytes() never
reaches zero.
> diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
> index 027fe41c676aa..c8049dd80cbcd 100644
> --- a/net/vmw_vsock/virtio_transport_common.c
> +++ b/net/vmw_vsock/virtio_transport_common.c
> @@ -295,6 +295,9 @@ static struct sk_buff *virtio_transport_alloc_skb(struct virtio_vsock_pkt_info *
> * since a socket assigned to a transport is required.
> *
> * Do not use on listener sockets!
> + *
> + * This checks that the socket can reach the g2h device, so device-only replies
> + * such as virtio_transport_reset_no_sock() must keep not using this path.
> */
> static int virtio_transport_send_pkt_info(struct vsock_sock *vsk,
> struct virtio_vsock_pkt_info *info)
> @@ -317,6 +320,9 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk,
> if (unlikely(!t_ops))
> return -EFAULT;
>
> + if (!vsock_g2h_reachable_sk(vsk))
> + return -ENETUNREACH;
> +
> src_cid = t_ops->transport.get_local_cid();
> src_port = vsk->local_addr.svm_port;
> if (!info->remote_cid) {
[Severity: Medium]
Can a socket swept by vsock_g2h_reset_unreachable() still send packets to
the host if the device is reassigned back to a reachable namespace before
the file descriptor is closed?
vsock_g2h_reachable_sk(vsk) only checks whether sock_net(sk_vsock(vsk))
can currently reach vsock_g2h_net, not whether vsk was already terminated
by an earlier namespace assignment. When vsock_g2h_reset_unreachable()
sweeps a connected socket, it sets SOCK_DONE and
vsk->peer_shutdown = SHUTDOWN_MASK, leaves the socket in
vsock_connected_table, and keeps sk->sk_state as TCP_CLOSING (or
TCP_ESTABLISHED if unread RX data remains). If the device is later moved
back to a reachable namespace such as init_net, vsock_g2h_reachable_sk()
returns true again:
- close() -> virtio_transport_close() checks
(vsk->peer_shutdown & SHUTDOWN_MASK) == SHUTDOWN_MASK before SOCK_DONE
and sends VIRTIO_VSOCK_OP_RST to the host.
- recvmsg() or setsockopt(SO_RCVLOWAT) sends
VIRTIO_VSOCK_OP_CREDIT_UPDATE.
- shutdown() -> vsock_shutdown() sends VIRTIO_VSOCK_OP_SHUTDOWN and clears
SOCK_DONE via sock_reset_flag(sk, SOCK_DONE), which also allows the
socket in vsock_connected_table to pass the SOCK_DONE check in
virtio_transport_recv_pkt() again.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-vsock-guest-ns-v7-0-7e522ea9dd9b@meta.com?part=5
next prev parent reply other threads:[~2026-11-19 1:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 1:54 [PATCH net-next v7 0/7] vsock: assign the guest vsock device to a network namespace Bobby Eshleman
2026-11-18 1:54 ` [PATCH net-next v7 1/7] vsock: constify the transport in vsock_for_each_connected_socket() Bobby Eshleman
2026-11-19 1:55 ` sashiko-bot
2026-11-18 1:54 ` [PATCH net-next v7 2/7] vsock: rename the vsock pernet operations Bobby Eshleman
2026-11-19 1:55 ` sashiko-bot
2026-11-18 1:54 ` [PATCH net-next v7 3/7] vsock: pass the netns to ->has_remote_cid() Bobby Eshleman
2026-11-19 1:55 ` sashiko-bot
2026-11-18 1:54 ` [PATCH net-next v7 4/7] vsock: add a netlink command to assign the g2h device to a netns Bobby Eshleman
2026-11-19 1:55 ` sashiko-bot
2026-11-18 1:54 ` [PATCH net-next v7 5/7] vsock/virtio: support guest device network namespace Bobby Eshleman
2026-11-19 1:55 ` sashiko-bot [this message]
2026-11-18 1:54 ` [PATCH net-next v7 6/7] selftests/vsock: test the guest vsock " Bobby Eshleman
2026-11-19 1:55 ` sashiko-bot
2026-11-18 1:54 ` [PATCH net-next v7 7/7] selftests/vsock: test the netns assign privilege checks Bobby Eshleman
2026-11-19 1:55 ` sashiko-bot
2026-11-19 2:28 ` [PATCH net-next v7 0/7] vsock: assign the guest vsock device to a network namespace Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-222311@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bobbyeshleman@meta.com \
--cc=eperezma@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=virtualization@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox