Article View: linux.kernel.netdev
Article #25941Re: [PATCH net-next v8 7/7] selftests/vsock: test the netns assign privilege checks
From: netdev-bot+sashiko
Date: Wed, 02 Dec 2026 19:07
Date: Wed, 02 Dec 2026 19:07
116 lines
12475 bytes
12475 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 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
Technical Details
Message-ID:
<179623843993.3146.5538433056705278892@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-376017-linux-kernel-netdev=dewy.ruReferences:
<20261130-vsock-guest-ns-v8-7-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-376017-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <179623843993.3146.5538433056705278892@kernel.org> References: <20261130-vsock-guest-ns-v8-7-5fff852d325b@meta.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2037520"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:EkIRAn7G85eqBkB2yz3Wvousur8= sha256:pWYnZmWKSYBBvDO5wEqoK5UzSdw1bcIFZwLVGSPbx1s= sha1:ogIARcY/9/sAiiyKYdCWMuBr0hE= sha256:fOhuvRL+l7NWVuZPen8JQr9oT78nSxOIfAW+54lRP3s= 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 9815A117704; Wed, 2 Dec 2026 22:07:57 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, 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 PiD-w-LoLOab; Wed, 2 Dec 2026 22:07:54 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376017-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id CF9B81176F7; Wed, 2 Dec 2026 22:07:43 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 3B51730ED5; Wed, 2 Dec 2026 19:07:26 +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=1796238443; b=xSP+Mj58d8TKh2LWHXvQ9R4SCafLytmW3XyMBUS9zJUzqNUtGoEAllPQfSylcnQUTYgd HJxH5Sa2+NsxMyyuPCzEOaHMk/iLAoGn/F+DdC54eMZiTTUWRzcZm9aaOg0qUmplmgIMh vJnkuNWuE/7FRmKZdjwZsIEGEVcmguCSKFDuyeM78QZ6FZZ0qclQIiyFbQ0rRG0cLnwRl RolI2IPMDRSKDn6pGQwUp7ZOGDreWIi6iKsmH2Nmf9aj5Yu3R7jK9NPSAKLllgkIwTxXz BblkCJyC04g6DzmMiykRGKHrBlW7iKgKyAfuVLqi0MmIuyNqSJXysRxBxi/5lWN17nA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796238443; 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=gZRqbPUyS18oW8+0ObklEzk1BMsfMF4Riv7odNKgQNc=; b=koQHX4HpxFIgxm+fs7TfuWFgSkCudWg5jIfvXom9lgFhV1b4umKC6TkxbycI3eijSRIt E9JZ7oqWfPgZJFcfqAsVb1iHbTjnVfS9UfCyRrusMSGT6Y2HH2flFOp9rAeU/uot/zwJo gWJnJXZi6c1ZVXU1pI+C5L1MPVVcj0LTrhObA8IHmp4ZeSme4lNjlxcLHjujLH8gyEHbn SqsdNsScJuZFavbx0XxHthYlhRGo0NjYoAf8Tr5O6QOJ/yhnz0GRaPokl7t3e6aEPgI4a 79kJNeF1QN3kpKmsURYg1NNrFuykwz7ukaQtBfSNStq4dPsXpymjBiOS/5/zyI1H+GQ== 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=KrBS5mpP; 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 5E4B6606A339; Wed, 2 Dec 2026 19:07:23 +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=KrBS5mpP 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=1796238442; b=wnr4criOVQgXIB/lH3ChhUch1XBe1Icj1vtNhBtVWLsmbKrNPZQ/9ZRal1fo2nl001kA MSNnSBqgg9ZbGXI+dzGGelrFOzk7qD56hVzF4DeUbpJUGbjmhqFEv2DzPZ+PCye7Y7VmV R8xyBKbbwVtWZrb/FdAeCMkHmWy8FiLI2Rvrb8LMYiWKxb+ybEfJDglYB/L3ixIMW2fKh rzi0A9ozA7DLfiZxgqHWivC6em8o0bIErvwby0iH6jcYRm8QR2kYV6Ae6QOtFnDxWY7eZ omxoK3juFhCur6/DbqRKb1qzvI6N+ZnV+HYZIojkWPo7Q3WsoCE2HJ1GMfdQLrKSB9g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796238442; 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=gZRqbPUyS18oW8+0ObklEzk1BMsfMF4Riv7odNKgQNc=; b=KztQU30k6isEdXTqSNB676xe1bghRiwEr5NNzJCFrpQzIbMBhw03BGp1Qzd1zO/8wHNt JtReyUYr7zoBfuE5vLVgvm8sjIbAuDCY22l+7K4Px0hcZocdbcUCJ0LLbYvzaqs1H9HTD n8hyHMMLxjGsNi1D6GxHXrknSd3DJUFiSR9iYe6sgJuknMRJ8PfM3Sq2Qpl86lrrAiMRT j8BEsziVFbstJJ3a/CAOZCDwL7gpt7l1tthNwOkxDjJt1+3itu+JUYYDYK4IHcHzJ1gU0 d5tm+REJ2yu7wspY8+dkTnRy7CCp9rS7rZRfupor4Jqnt/pa6Yr7pulJ2eXio3ntZvg== 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=KrBS5mpP; 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 7F705606A33C; Wed, 2 Dec 2026 19:07:22 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 673CB1F0089B; Wed, 2 Dec 2026 19:07:20 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796238442; bh=gZRqbPUyS18oW8+0ObklEzk1BMsfMF4Riv7odNKgQNc=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=KrBS5mpPhUTr1GhRDB6j1oQT+3DEbtnOZurPSSkYzowDflwJ8ZCan1DkLnXJi4X8r 2U436Vm+ZG/yQVnMCL9DuRRSLsErI7ds7/LrC1f/L76HfH6oZW1gKkVyKNtzn6216F bD7r1SgNAs56cuz/Z6gKHaQ1NWiiuR8s9FOj82pIC3QexBRcOvW1BdUkBy4vNxB1A7 6HSLdD44q1MP622tUp3raaApLpT0i9fj6jqvq3FDI4E6gfg0SDRA/BnlI5OOEHl+8x FUPW7lqugBwp8PWSjLGznA1Le5jTqv/lNTWQnMBtRYOB/FjfW+ZxFY29tqQoK5MB7P 1jt5DEpPhDYmg== 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-7-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