🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25940

Re: [PATCH net-next v8 6/7] selftests/vsock: test the guest vsock device network namespace

#25940
From: netdev-bot+sashiko
Date: Wed, 02 Dec 2026 19:07
139 lines
13557 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] In tools/testing/selftests/vsock/vmtest.sh,
  test_ns_guest_assign_g2h_netns_pins_ns_ok is described in TEST_DESCS…
- [Low] This patch rewrote the --skip=29 comment in
  test_ns_same_local_host_connect_to_local_vm_ok (vmtest.sh ~1352-1357),…

--

selftests/vsock: test the guest vsock device network namespace

This adds vmtest.sh tests for assigning the guest vsock device to a
network namespace, including namespace destruction and moving the device
between namespaces. The tests drive the device through ynl's cli.py, and
only these tests are skipped when python3, PyYAML or unshare is missing.

> diff --git a/tools/testing/selftests/vsock/vmtest.sh b/tools/testing/selftests/vsock/vmtest.sh
> index 310dfc2a39ad5..c771d0cb9268a 100755
> --- a/tools/testing/selftests/vsock/vmtest.sh
> +++ b/tools/testing/selftests/vsock/vmtest.sh

[ ... ]

> @@ -1168,11 +1350,11 @@ test_ns_same_local_host_connect_to_local_vm_ok() {
>  	vm_vsock_test "${ns}" "server" 2 "${TEST_GUEST_PORT}"
>  
>  	# Skip test 29 (transport release use-after-free): This test attempts
> -	# binding both G2H and H2G CIDs. Because virtio-vsock (G2H) doesn't
> -	# support local namespaces the test will fail when
> -	# transport_g2h->stream_allow() returns false. This edge case only
> -	# happens for vsock_test in client mode on the host in a local
> -	# namespace. This is a false positive.
> +	# binding both G2H and H2G CIDs. The virtio-vsock (G2H) device stays
> +	# assigned to init_net, which a local namespace cannot reach, so the
> +	# test will fail when transport_g2h->stream_allow() returns false. This
> +	# edge case only happens for vsock_test in client mode on the host in a
> +	# local namespace. This is a false positive.
>  	host_vsock_test "${ns}" "127.0.0.1" "${VSOCK_CID}" "${TEST_HOST_PORT}" --skip=29

[Severity: Low]
Is stream_allow() still the check that makes test 29 fail here?

In this series, virtio-vsock sets .netns_assign_allow = true. In
vsock_connect(), vsock_assign_transport() runs first. It rejects the
unreachable G2H device before the stream_allow() check is reached:

net/vmw_vsock/af_vsock.c:vsock_assign_transport() {
    ...
	if (vsock_g2h_unreachable(new_transport, sock_net(sk))) {
		ret = -ENETUNREACH;
		goto err;
	}
    ...
}

test_stream_transport_uaf() in tools/testing/vsock/vsock_test.c only
accepts EADDRNOTAVAIL, or ENODEV for CID_HOST. The ENETUNREACH from
vsock_assign_transport() is what makes test 29 fail:

	if (errno != EADDRNOTAVAIL) {
		perror("Unexpected connect() errno");
		exit(EXIT_FAILURE);
	}

The v7 notes say this comment was fixed, but it still points at
transport_g2h->stream_allow(). Could it name the vsock_g2h_unreachable()
check in vsock_assign_transport() instead?

[ ... ]

> +test_ns_guest_assign_g2h_netns_pins_ns_ok() {

[ ... ]

> +	vm_ns_stop "init_ns" "${nspid}"
> +	sleep "${WAIT_PERIOD}"
> +
> +	outfile=$(mktemp)
> +	guest_send_to_host "init_ns" "" "${port}" "${outfile}"
> +	result=$(cat "${outfile}")
> +	if [[ "${result}" == TEST ]]; then
> +		log_host "device returned to the init ns instead of pinning it"
> +		rm -f "${outfile}"
> +		vm_reset_g2h
> +		return "${KSFT_FAIL}"
> +	fi
> +
> +	# Assigning it back is what releases the deleted namespace.
> +	vm_reset_g2h
> +
> +	guest_send_to_host "init_ns" "" "$(( port + 1 ))" "${outfile}"
> +	result=$(cat "${outfile}")
> +	rm -f "${outfile}"
> +
> +	if [[ "${result}" != TEST ]]; then
> +		log_host "device did not come back on reassign: [${result}]"
> +		return "${KSFT_FAIL}"
> +	fi

[Severity: Low]
Does this test check what its description says?

The TEST_DESCS entry is "Check the assignment keeps the ns alive when
deleted, and that reassigning releases it". The comment above
vm_reset_g2h() also says the reassign is what releases the deleted
namespace.

The test checks only two things:

  - a send from the guest's init ns fails after the holder exits
  - a send from init ns works again after vm_reset_g2h()

Nothing here checks that the namespace stays alive, or that it is
released (put_net / cleanup_net) after the reassign. A netns reference
leaked on reassign would still pass.

vm_ns_stop() only waits for the holder process to exit, and netns
teardown runs asynchronously on netns_wq. Only the fixed
sleep "${WAIT_PERIOD}" stands between the two before the first assertion.

Suppose a broken implementation moved the device back to init_net from a
pernet exit hook, and that cleanup ran after the first
guest_send_to_host(). The first check would not fire, vm_reset_g2h()
would then reassign explicitly, and the test would still pass.

Could the description and the in-body comment be narrowed to what is
actually checked? Or could the test check the namespace lifetime
directly? The same applies to "including ns destruction" in the commit
message.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130-vsock-guest-ns-v8-0-5fff852d325b%40meta.com
Technical Details
Message-ID: <179623843754.3146.16114719734929000830@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376016-linux-kernel-netdev=dewy.ru
References: <20261130-vsock-guest-ns-v8-6-5fff852d325b@meta.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376016-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v8 6/7] selftests/vsock: test the guest vsock
 device network namespace
Date: Wed, 02 Dec 2026 19:07:17 +0000
Organization: Usenet Network
Message-ID: <179623843754.3146.16114719734929000830@kernel.org>
References: <20261130-vsock-guest-ns-v8-6-5fff852d325b@meta.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2037461"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:oL6fEVTXAaKwSaIcYP1u+wzVUlI= sha256:B3P0lpIoLlGVdarDwpqco2+RsUoYhEXWBFHsPp/2t5c=
	sha1:vaY+YLWAgvhzPqHglUaX3nrzezA= sha256:mBR0VIhLvoMlufqF+bLJgyatnPSJW93179HFTHqSQAI=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 3CEBB1176F7; Wed,  2 Dec 2026 22:07:43 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id Y3FSoSINvv93;
	Wed,  2 Dec 2026 22:07:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376016-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 66CE7117702; Wed,  2 Dec 2026 22:07:29 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 7223E283B8; Wed,  2 Dec 2026 19:07:22 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796238441;
	b=DldDzTTOjuZ8ucn7bhXQRh1NI8RWyT3WYC2i86hpX+Amr0p80ojfzPzxSqN3izFOc75h
	 jjk26eM3+VS+rAPBZJc0nCK7ES5AlAV7TLWykBQ0mZh2e9uOjyMiZSNXvS+Dvz1eTF+jl
	 pLyahVQsHwp+0XxA+4uLTl+Ln1dGWwHy8E5MTg/kFFYUbqmJraJPqxHtLYiNsfRWtm+bW
	 ktIk6ydhJpP42I4j/5Vf2uiMGFa4H1kUHLZpUB+Xkw50Y7EFoPpxYZLzJEgISJEXuvb0Y
	 9LWYeLtHkQv8aY7vFwVGoeoZ4C0ZSX7yTIByvP4gt8pcVa4ylz8ZlyuhQ64wvFAXcZg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796238441;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=PaREL6DgbE68fR26XwLlPsGLbfZT1vkhDfP1V2sa770=;
	b=FCSVpBV35Mnf3AglDz/BUQDSrlcqLPtsf/PmZKB3sTbnUHgIasezoXDxJ2oNWOi3iiY+
	 cKpSHVv3ZVE6RcJxq5zYjVmzWMwT1UHez0s4aExCIXWYDb21b59QTuHrxOBcwI7ID/qMQ
	 FXt+KnHfAXk0bheMeO9/ZRUhkCjEAGmTm6QoqNpvfsZ73RYlb3aFgWrJyoBmd9eri+X5B
	 Mlmzz5zsycF+grU+F0DuypQgWsOWuTqWJoIkmPsAPTTqtumoAiivajZwUo+U0Odf1u0IF
	 Y8qAT0kZgx36b+rFZHoLYyswZXQwBx+UdEIcfwo6EwgEqgN0eOxiDLaG+GskrKMOxtw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bsoLEtd5;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id E9A51606A335;
	Wed,  2 Dec 2026 19:07:20 +0000 (UTC)
X-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=bsoLEtd5
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796238440;
	b=0qBbOxwgN2HP/rwOGhkfPt/hfB0OzWe80gdPhz1Htglio3I3OoPWUGxPAaNRqqxpSp67
	 odFITM+rB48eNLp5p++uU0r3ft7/V6BLQ59/qejTU70n2xtoYZca3Sc2pJAA4cCZxJZfc
	 DMZNbSy/mR6vh2TcZrSlP0jgh6tCkVBWlCnOib5Td0R67sItA4pqvbbx8t13KuogP5IId
	 BrmtN/yF77XRf6rKw03g5p/HttHYX4oC6u54mePy81Z+yYSspiEnilk42BsDCmlpvyEcn
	 /v4IGnTu77VEaW8O7zHGDNFBRT+eAVFVD2ot/qtjbFnBi3WwYxtZQNYQiqjpTfMJtrg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796238440;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=PaREL6DgbE68fR26XwLlPsGLbfZT1vkhDfP1V2sa770=;
	b=rQ5YqVpJsW1PryYalfM0B12QlaJq05LVVV0ubFo6kKzEnoYzZGiUaam7PG3XrbpIwywj
	 JNY5/bvwKExbIQcd6NBoRGCqr8ReGara55PzjoUrck81ibi/OaCeSe5zaPvlaNmpz8Knp
	 JiPxluT25k9zUr6tW9DxUomgGUeDFco8yB0PCL+qEjuaiEcyo3w/s/khoLvS7tTo+2Grm
	 vDglaF8kIi4hiApQRCBpuJd6MQ4n041htm+iDEXpZcxxyY4QGNvPmw5+yps28o6fJIyoF
	 qzb3LbKxKf19Ay6oYHEv8CVR8l2ERz8Svo5JxHkU4BSEiBLHlQocKpSsCI7dQjoeWOg==
X-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=bsoLEtd5;
	arc=none smtp.remote-ip=100.103.45.18
X-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 16060606A32C;
	Wed,  2 Dec 2026 19:07:19 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06A5E1F00893;
	Wed,  2 Dec 2026 19:07:17 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796238439;
	bh=PaREL6DgbE68fR26XwLlPsGLbfZT1vkhDfP1V2sa770=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=bsoLEtd5h6yJBDwoDjgjvJJBIHapbYuRFzKy42r6/A/2fsBnGUA5Ctx511Ffb31+0
	 w362UTn4lzT060lJgy9PzdnMBsswbUCJ501IgV1a+54LwZLydtumO4J+61sVLY9E/N
	 uXkJb/ZU1dluGhsV15Yx4Ms//35AeqN1zdOf3vbhVkv75DO5tvi+2bGoBbVH6ly2ep
	 6W0wIYZ4fxzFWr/dpIUYCQOZiF3LjEkWVepEGLU6abd3qIrB4OpSL5/NClaa3fHasB
	 lFdcd0hPmUAVMcMCIHfcCsfXCYGyLPbIAPdrZQAVZuHiAb1t4F+ZxjnAyvM2pL7sAE
	 qWGrz3FuoQWuA==
X-Cc: sgarzare@redhat.com, davem@davemloft.net, kuba@kernel.org,
 pabeni@redhat.com, horms@kernel.org, corbet@lwn.net,
 skhan@linuxfoundation.org, stefanha@redhat.com, mst@redhat.com,
 jasowangio@gmail.com, xuanzhuo@linux.alibaba.com, eperezma@redhat.com,
 shuah@kernel.org, rdunlap@infradead.org, donald.hunter@gmail.com,
 edumazet@kernel.org, georgezhang@vmware.com, acking@vmware.com,
 dtor@vmware.com, willemb@google.com, virtualization@lists.linux.dev,
 netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
 linux-doc@vger.kernel.org, kvm@vger.kernel.org,
 linux-kselftest@vger.kernel.org, sargun@sargun.me, jlinbox@meta.com,
 bobbyeshleman@gmail.com
X-In-Reply-To: <20261130-vsock-guest-ns-v8-6-5fff852d325b@meta.com>
X-sashiko-severity: Low
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list