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

From: netdev-bot+sashiko

Date: Wed Dec 02 2026 - 14:07:50 EST


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