From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796173688; b=wdci6MbtXcAwThZBZ09Y0t1NIJkHUNMzPtErzCdh0POixaVEez57afZ7D2gvcbMhWJxl 1SZbbuO0bPoz41IJFtefc3m8sgxznwgFtYwZcW30EHUGSXwq8nuo63LSUEoNJSs3+U87I WPlueW67f19mEP+fJ+XPZveJe9C8rsJ8xaDnh0cgdFqC4GvZOSSgI/EmFBlHWJVql/5dd iYARMnzV2b+G80jvzDaOYx2ojD0GznCWji/t5i+Blfak8NIZmPfiqpybUBW0aoF6n+Le0 fWbHKiC2LIPf7ogT/afp2mvwhyu4tbKwwErqGENljhgbIGg/ZHqtg77g1xGY9A9tBlA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796173688; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=P0kQ/efCzzq6E7tbAg3WWaB+I/B1Xh8byB28KBnEqDE=; b=DeJx0Zf9x5JQV0Nq7fPmQnc5s1mlPVM+O+1FYXsfQXOsas4H46apGooDT3h8cCouGSHZ cWrJGrKmhxdhu02lyponOuSzm9HaMhx5fPwzZyhOP25qG7fXijJ8D6wSCOyDzCzVPt92u xA9VJ9vtYd+FnQg+ptYZ2Vfh7Ta7zNsd3cPo1dZ7o4xsppt+ClguDbdgf2uN5yX1cOImw LnkI8u91A0fsb4ePpzARfiy1IlwpHwQ87VIgdVDRr5dz+IVYqHp7GHdAbPmigv1H+l+QN jyR4deWQHQO9u5XIa9QK7wwRQ7P6iDVASPMbMWYal9l8d3sYHiCz3yjB1Wf1zfmnrKw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kNEWNm2T; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F353E606A325; Wed, 2 Dec 2026 01:08:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kNEWNm2T Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9E221F00923; Wed, 2 Dec 2026 01:08:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796173687; bh=P0kQ/efCzzq6E7tbAg3WWaB+I/B1Xh8byB28KBnEqDE=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=kNEWNm2TyvYjNIrPLhUF0HQ8meVVQ9WN5Kccd53fP/pIMDGs3rxa9d4MJEAPl9Y+I xXKWfzjMxW5Z2MTzu3dPY4laH25MOxadf7bLdjpJ2mmbQMrX5QHH8EmaQ0sPYUGvxm BOfIYDzIeO4rysalDwyuq9BesT4foQgaKqHBZea0ZCyfwFR6UCzDySOERbx/VxyVfH 0n7tBHXxicQAmnURMTpUFyCTlKCpIpjPcp66Bxn9cKlODqlOjbU01hmFHOjanUsAp6 lAT/pujPfCTBsiXcZPLd2fFFdAWL2kOROtkW1AFQCTbYo28eKjoqLm1BaI9j8Yd08s J5zOGar3OFF3A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next v8 5/7] vsock/virtio: support guest device network namespace Reply-To: sashiko-reviews@lists.linux.dev To: "Bobby Eshleman" Cc: virtualization@lists.linux.dev, kvm@vger.kernel.org, "Michael S. Tsirkin" , "Eugenio Perez" In-Reply-To: <20261130-vsock-guest-ns-v8-5-5fff852d325b@meta.com> References: <20261130-vsock-guest-ns-v8-0-5fff852d325b@meta.com> <20261130-vsock-guest-ns-v8-5-5fff852d325b@meta.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 01:08:07 +0000 X-Mailing-List: kvm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] vsock: race between vsock_maybe_set_connected() and netns reset corrupts connect() - [Medium] vsock/virtio: swept sockets can still send packets after device reassign -- commit 8a88d97e551b287b3bd8b7283a009a1e7f59f9be Author: Bobby Eshleman vsock/virtio: support guest device network namespace This commit allows assigning the guest virtio-vsock device to a network namespace, updating socket reachability checks and handshake insertion in virtio_transport. > diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virt= io_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(str= uct 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 pat= h. > */ > 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 vsoc= k_sock *vsk, > if (unlikely(!t_ops)) > return -EFAULT; > =20 > + if (!vsock_g2h_reachable_sk(vsk)) > + return -ENETUNREACH; [Severity: Medium] Can a socket that was swept by VSOCK_CMD_DEV_NETNS_SET still send packets if the device is later reassigned back to a reachable namespace? vsock_g2h_reset_unreachable_sk() resets unreachable sockets to TCP_CLOSE while leaving sock->state as SS_CONNECTED. vsock_g2h_reachable_sk() only checks whether sock_net(sk) can currently reach vsock_g2h_net, not whether the socket itself was already closed by an earlier sweep. If the device moves back to a reachable namespace (such as init_net) before the socket fd is closed, paths that do not check sk->sk_state, such as vsock_shutdown() or virtio_transport_notify_set_rcvlowat(), pass this check and transmit VIRTIO_VSOCK_OP_SHUTDOWN or VIRTIO_VSOCK_OP_CREDIT_UPDATE from a dead TCP_CLOSE socket. > @@ -1468,8 +1474,8 @@ void virtio_transport_release(struct vsock_sock *vs= k) > EXPORT_SYMBOL_GPL(virtio_transport_release); > =20 > static int > -virtio_transport_recv_connecting(struct sock *sk, > - struct sk_buff *skb) > +virtio_transport_recv_connecting(struct sock *sk, struct sk_buff *skb, > + struct virtio_transport *t) > { > struct virtio_vsock_hdr *hdr =3D virtio_vsock_hdr(skb); > struct vsock_sock *vsk =3D vsock_sk(sk); > @@ -1478,9 +1484,18 @@ virtio_transport_recv_connecting(struct sock *sk, > =20 > switch (le16_to_cpu(hdr->op)) { > case VIRTIO_VSOCK_OP_RESPONSE: > - sk->sk_state =3D TCP_ESTABLISHED; > + if (!vsock_maybe_set_connected(vsk)) { > + /* The net arg is required but unused: only g2h can fail > + * vsock_maybe_set_connected(), and g2h > + * virtio_transport_reset_no_sock() ignores the net arg. > + */ > + virtio_transport_reset_no_sock(t, skb, sock_net(sk)); > + skerr =3D ECONNRESET; > + err =3D -ENETUNREACH; > + goto close; > + } > + > sk->sk_socket->state =3D SS_CONNECTED; > - vsock_insert_connected(vsk); > sk->sk_state_change(sk); > break; [Severity: High] Can a namespace assign sweep right after vsock_maybe_set_connected() leave vsk in vsock_connected_table while vsock_connect() resets sock->state to SS_UNCONNECTED? CPU0 (client connect) CPU1 (rx_work / netns assign) vsock_connect() sk->sk_state =3D TCP_SYN_SENT sock->state =3D SS_CONNECTING release_sock(sk) schedule_timeout() virtio_transport_recv_connecting() vsock_maybe_set_connected(vsk) sk->sk_state =3D TCP_ESTABLISHED __vsock_insert_connected(list, vsk) sock->state =3D SS_CONNECTED ... vsock_g2h_net_assign() vsock_g2h_reset_unreachable_sk(sk) sk->sk_state =3D TCP_CLOSE sk->sk_err =3D ECONNRESET lock_sock(sk) if (sk->sk_state =3D=3D TCP_ESTABLISHED || sk->sk_state =3D=3D TCP_CLOSING) // false ... err =3D sock_error(sk) // -ECONNRESET sock->state =3D SS_UNCONNECTED <-- vsk still in vsock_connected_table Because vsock_g2h_reset_unreachable_sk() runs under vsock_table_lock without lock_sock(sk) and sets sk->sk_state to TCP_CLOSE rather than TCP_CLOSING, vsock_connect() does not recognize that the socket was already established and inserted into vsock_connected_table. Resetting sock->state to SS_UNCONNECTED allows a second connect() on the same fd to call __vsock_insert_connected() again on the already-linked vsk->connected_table node, corrupting vsock_connected_table and leaking a socket reference. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130-vsock-gues= t-ns-v8-0-5fff852d325b@meta.com?part=3D5