From: netdev-bot+sashiko@kernel.org
To: bobbyeshleman@meta.com
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
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 [thread overview]
Message-ID: <179623843754.3146.16114719734929000830@kernel.org> (raw)
In-Reply-To: <20261130-vsock-guest-ns-v8-6-5fff852d325b@meta.com>
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
next prev parent reply other threads:[~2026-12-02 19:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 1:06 [PATCH net-next v8 0/7] vsock: assign the guest vsock device to a network namespace Bobby Eshleman
2026-12-01 1:06 ` [PATCH net-next v8 1/7] vsock: constify the transport in vsock_for_each_connected_socket() Bobby Eshleman
2026-12-01 1:06 ` [PATCH net-next v8 2/7] vsock: rename the vsock pernet operations Bobby Eshleman
2026-12-01 1:06 ` [PATCH net-next v8 3/7] vsock: pass the netns to ->has_remote_cid() Bobby Eshleman
2026-12-01 1:06 ` [PATCH net-next v8 4/7] vsock: add a netlink command to assign the g2h device to a netns Bobby Eshleman
2026-12-01 16:19 ` Michal Luczaj
2026-12-01 21:05 ` Bobby Eshleman
2026-12-02 19:26 ` Michal Luczaj
2026-12-02 19:07 ` netdev-bot+sashiko
2026-12-01 1:06 ` [PATCH net-next v8 5/7] vsock/virtio: support guest device network namespace Bobby Eshleman
2026-12-02 19:07 ` netdev-bot+sashiko
2026-12-01 1:06 ` [PATCH net-next v8 6/7] selftests/vsock: test the guest vsock " Bobby Eshleman
2026-12-02 19:07 ` netdev-bot+sashiko [this message]
2026-12-01 1:06 ` [PATCH net-next v8 7/7] selftests/vsock: test the netns assign privilege checks Bobby Eshleman
2026-12-02 19:07 ` netdev-bot+sashiko
2026-12-02 18:15 ` [PATCH net-next v8 0/7] vsock: assign the guest vsock device to a network namespace Stefano Garzarella
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=179623843754.3146.16114719734929000830@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=acking@vmware.com \
--cc=bobbyeshleman@gmail.com \
--cc=bobbyeshleman@meta.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=donald.hunter@gmail.com \
--cc=dtor@vmware.com \
--cc=edumazet@kernel.org \
--cc=eperezma@redhat.com \
--cc=georgezhang@vmware.com \
--cc=horms@kernel.org \
--cc=jasowangio@gmail.com \
--cc=jlinbox@meta.com \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rdunlap@infradead.org \
--cc=sargun@sargun.me \
--cc=sgarzare@redhat.com \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=willemb@google.com \
--cc=xuanzhuo@linux.alibaba.com \
/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