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 7/7] selftests/vsock: test the netns assign privilege checks
Date: Wed, 02 Dec 2026 19:07:19 +0000 [thread overview]
Message-ID: <179623843993.3146.5538433056705278892@kernel.org> (raw)
In-Reply-To: <20261130-vsock-guest-ns-v8-7-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 check_assign_g2h_eperm()
(tools/testing/selftests/vsock/vmtest.sh), if the assign unexpectedly…
- [Low] check_assign_g2h_eperm() counts a run as PASS if the substring
"Operation not permitted" appears anywhere in the combined stdout and…
--
selftests/vsock: test the netns assign privilege checks
This patch adds two vsock selftests. Both check that
VSOCK_CMD_DEV_NETNS_SET is refused in two cases: when CAP_NET_ADMIN has
been dropped from the bounding set, and when the caller holds
CAP_NET_ADMIN only in an unprivileged user namespace. It also enables
CONFIG_USER_NS in the selftest config and makes setpriv a dependency of
these two tests.
> diff --git a/tools/testing/selftests/vsock/vmtest.sh b/tools/testing/selftests/vsock/vmtest.sh
> index c771d0cb9268a..248a4c6900f1e 100755
> --- a/tools/testing/selftests/vsock/vmtest.sh
> +++ b/tools/testing/selftests/vsock/vmtest.sh
[ ... ]
> @@ -1951,6 +1970,44 @@ test_ns_guest_assign_g2h_netns_pins_ns_ok() {
> return "${KSFT_PASS}"
> }
>
> +check_assign_g2h_eperm() {
> + local wrapper=$1
> + local out
> +
> + if out=$(vm_ssh "init_ns" -- "${wrapper}" python3 /root/ynl/cli.py \
> + --no-schema --spec /root/ynl/vsock.yaml \
> + --do dev-netns-set 2>&1); then
> + log_host "assign unexpectedly succeeded under '${wrapper}'"
> + return "${KSFT_FAIL}"
[Severity: Low]
If the assign unexpectedly succeeds, should this path call vm_reset_g2h()
before returning?
The request has neither a netns-fd nor a netns-pid attribute. In that
case vsock_nl_dev_netns_set_doit() uses the caller's netns:
net/vmw_vsock/af_vsock.c:vsock_nl_dev_netns_set_doit() {
...
else
net = get_net(genl_info_net(info));
...
}
Under the "unshare -n ..." and "... unshare -Urn" wrappers, the caller's
netns is a temporary one. If the privilege check ever regresses, the
guest's g2h device would move into a namespace that goes away when the
wrapper exits. test_ns_guest_assign_g2h_netns_pins_ns_ok shows that the
device keeps such a namespace alive until it is reassigned.
Both new tests are in USE_SHARED_VM. Any later shared-VM test that
expects the device to be in init_net would then fail for an unrelated
reason.
The other ns_guest_assign_* tests call vm_reset_g2h on their failure
paths. Could this helper do the same?
> + fi
> +
> + if [[ "${out}" != *"Operation not permitted"* ]]; then
> + log_host "no EPERM under '${wrapper}': [${out}]"
> + return "${KSFT_FAIL}"
> + fi
[Severity: Low]
Can this match give a false pass? The output is the merged stdout and
stderr of the whole wrapper chain. If unshare or setpriv fails with
EPERM, it prints something like:
unshare: unshare failed: Operation not permitted
That text passes the substring check, even though cli.py never ran and
no VSOCK_CMD_DEV_NETNS_SET request reached the kernel.
test_ns_guest_assign_g2h_netns_unpriv_user_ns_fails guards against this
by running the wrapper with "true" first:
if ! vm_ssh "init_ns" -- "${unpriv} unshare -Urn true"; then
test_ns_guest_assign_g2h_netns_no_cap_net_admin_fails has no such probe.
If "unshare -n" or "setpriv --bounding-set=-net_admin" fails in the guest
(for example because of an LSM or seccomp policy), the test would
report a pass for the CAP_NET_ADMIN check.
When the kernel rejects the request, cli.py prints the NlError string,
which starts with "Netlink error: " (see NlError.__str__() in
tools/net/ynl/pyynl/lib/ynl.py). Would matching on that prefix, or adding
the same "true" probe, tie the check to the kernel's GENL_ADMIN_PERM
rejection?
> +
> + return "${KSFT_PASS}"
> +}
> +
> +test_ns_guest_assign_g2h_netns_no_cap_net_admin_fails() {
> + check_assign_g2h_eperm "unshare -n setpriv --bounding-set=-net_admin"
> +}
[ ... ]
--
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
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 [this message]
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=179623843993.3146.5538433056705278892@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