🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #16522

Re: [PATCH net-next v6 8/8] selftests/vsock: test the netns assign privilege checks

#16522
From: netdev-bot+sashiko
Date: Sun, 15 Nov 2026 04:01
109 lines
12239 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,
  check_assign_g2h_eperm() returns KSFT_FAIL from the "assign…
- [Low] In tools/testing/selftests/vsock/vmtest.sh,
  check_assign_g2h_eperm() passes whenever the ssh command fails and the…

--

selftests/vsock: test the netns assign privilege checks

This adds two vsock selftests that check VSOCK_CMD_DEV_NETNS_SET is
refused without CAP_NET_ADMIN in the init user namespace. One test drops
net_admin from the bounding set, and the other runs as an unprivileged
user inside a new user ns. The patch also adds CONFIG_USER_NS to the
config and makes setpriv a dependency for these two tests.

> diff --git a/tools/testing/selftests/vsock/vmtest.sh b/tools/testing/selftests/vsock/vmtest.sh
> index a800b63dfbb11..9614532a56285 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}"
> +	fi

[Severity: Low]
If the GENL_ADMIN_PERM check ever regresses and dev-netns-set succeeds
here, where does the guest's G2H device end up?

The request carries no netns fd or pid attribute. In that case
vsock_nl_dev_netns_set_doit() assigns the device to the netns the
request came from, which here is the throwaway netns created by
unshare -n or unshare -Urn.

test_ns_guest_assign_g2h_netns_pins_ns_ok() notes that this kind of
assignment keeps the namespace pinned after its process exits:

	# Assigning it back is what releases the deleted namespace.
	vm_reset_g2h

Both new tests are in USE_SHARED_VM. That means run_shared_vm_tests()
keeps running tests on the same VM while the device is still stuck in
a dead netns. With the default order only the second new test is hit.
With a user-chosen order, more of the later shared-VM tests could fail
for unrelated reasons.

The other assign tests in this file call vm_reset_g2h on their failure
paths. Should this branch also call it before returning KSFT_FAIL?

> +
> +	if [[ "${out}" != *"Operation not permitted"* ]]; then
> +		log_host "no EPERM under '${wrapper}': [${out}]"
> +		return "${KSFT_FAIL}"
> +	fi
> +
> +	return "${KSFT_PASS}"
> +}

[Severity: Low]
Could this match an EPERM that never came from the netlink request?

The substring check runs against the combined stdout/stderr of the
whole wrapper chain. Suppose unshare -n or setpriv
--bounding-set=-net_admin fails with EPERM in the guest. The output
would then contain something like:

    unshare: unshare failed: Operation not permitted

and check_assign_g2h_eperm() would return KSFT_PASS even though cli.py
never sent VSOCK_CMD_DEV_NETNS_SET.

test_ns_guest_assign_g2h_netns_unpriv_user_ns_fails() probes its
wrapper with "unshare -Urn true" first and skips if that fails.
test_ns_guest_assign_g2h_netns_no_cap_net_admin_fails() below has no
such probe.

cli.py prints kernel errors through NlError.__str__() in
tools/net/ynl/pyynl/lib/ynl.py, which starts with the "Netlink error: "
prefix followed by the strerror. Would it be tighter to match on that
prefix, or to probe the wrapper in the no_cap test as well?

> +
> +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/20261113-vsock-guest-ns-v6-0-3737ce4673c0%40meta.com
Technical Details
Message-ID: <179471529588.2199510.6165788075802667955@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363551-linux-kernel-netdev=dewy.ru
References: <20261113-vsock-guest-ns-v6-8-3737ce4673c0@meta.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-363551-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v6 8/8] selftests/vsock: test the netns assign
 privilege checks
Date: Sun, 15 Nov 2026 04:01:35 +0000
Organization: Usenet Network
Message-ID: <179471529588.2199510.6165788075802667955@kernel.org>
References: <20261113-vsock-guest-ns-v6-8-3737ce4673c0@meta.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="1725033"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:IQkrnkKpX0zAKjNGuIh9OyAvJVM= sha256:LyXpqUEBk8O6CHXFHHbr4oK4tFsk6Tw0GIh675Pr+QA=
	sha1:9ezv2c4YDr6XXnoeLHZcWpiZA/4= sha256:p/vBvlWuGPrHsdKefWXXOpz/PDZrJ5s0WB4WEMJQPNQ=
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 4804C125D3D; Sun, 15 Nov 2026 07:02:57 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 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] 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 o8QEWNFY1LcA;
	Sun, 15 Nov 2026 07:02:53 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-363551-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 3CF59125D3C; Sun, 15 Nov 2026 07:02:44 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 8B81B2F477; Sun, 15 Nov 2026 04:02:13 +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=1794715304;
	b=3n21TT01ONYnJmssr7n5iTx3q+9+lhg0qIf/gHURaKcZ1Ph04HtDqrP6z+gkEY3ZYlnd
	 B1d8Ndn3/pLHz7Wso937GMSwSlMevt+faWw25gSIH2sTZzwuBpDLofOfqmHeuLiRTkZmO
	 9K9s0x9I+SVzWFGO+Ypp6KqDzAXIur7bEVasOuBSL2JHPsNIvnPvuEB5MsBacv0INrMUp
	 vfk1mlk8aCSY8d2eMad0KxLDWkU/52plGBJYVrlp2gO+uCrYyl7ShjF8br4nvGToXCgOc
	 MgvtZWrjB5eHpcQ1/XnaWwMFDVDCn0nxTC+UbtKOzh105W5fq3ZHIDq00uYxaKd0Lnw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794715304;
	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=ekNkURalsL5MHlKPQd8PSLVr4r63qFXeHmS9Q5qJzWc=;
	b=ASg9GxAVoD0WisgdtS05ci8/WWfD6K6h776nF3y5Bz7KZqU4j+qY9ObK6jNiHJJVvo0H
	 PfrAdQYIlf3tf5NX+CAf0LUpxvH90OxJwyTviWSmqiUzAiIg6FIAe+JdrF1bGN3ggFNzz
	 5k3gm0Cznj1be01iI02mjspI7rdxi7veu5JIJSUsp6Z3So6xb13dovjSvNCx6N2yzxo8+
	 pWdV081kgag0lNfU7POkingAGQbK9L2hcUxM/mCqLc7R0/Eqz15E2qpEHelNpCNoU+ZA1
	 muQ+r4aNyzTqOxmh2+OowilqQPbpKFtrpYYLgAML3LYOAyL9SSdIVtTSr/YnJ5JXNWA==
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=ESfALudJ;
	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 EE63A60A380F;
	Sun, 15 Nov 2026 04:01:43 +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=ESfALudJ
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=1794715298;
	b=shw6l2JzdnaVoeGZuKgUklvWut0NpF1/oETr6tQ4eIo+TY5S6QkuZts/sJCl3fMi1X/F
	 Bnoc5tfvibsZrZ+AbuqLDWmykDY8hmNatk8yy4Yxs2PGYTZ4lmDt6vDtiVKAEvfkHftDU
	 Rd3Kl3m6IVMzkyaw1BZlg6B43FG47dANFlpX1msvyOJK02lfiy2DZbaHMIyobO7Y65RdI
	 fEYDT5DUXvldlXhy26Ih14cjK1HpNVMfmgyCj6cboi9g1zVRFQF9M6XOPTTmTeAVrBUkq
	 Al3mqqqO5mIw9u/ne4k7nh5I2ct+Rq4OUXmpLtZ0KxLL31cmkloUZo4dGMpWLCo7X3A==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794715298;
	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=ekNkURalsL5MHlKPQd8PSLVr4r63qFXeHmS9Q5qJzWc=;
	b=wi6JTxj1aEjxMO6g79VNfLwv7ZA6BCYsgXaoCQH3nIAWOqUNg7vDxZ+8IzoIf3hkaN7s
	 dHPvcpx7pUWTk/V4mNuleRIZR3u/RXwhH2MKEJVoxEgpAzXmPMmHePR6IPfVG8nmZLGbT
	 HDqkcbW0ewRF2iSiJsmu5V8muLu8K+updwVLoXUYyKVvZxna0XlvqD1qPEgj5Busb+cW9
	 UymuLsn7jzrc0PsUIzGUD+LKRkrdyywwXP72l/Tzw4yEycrteUkFymgMNOPJbl3L2PZ+S
	 V5CmmY2sCS4nKkjPkRyDZWerYXKQnGg1cKzq+ARBLblHQrnUqzJbjEmcFc09bhzQe8A==
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=ESfALudJ;
	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 18A8060A263A;
	Sun, 15 Nov 2026 04:01:37 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A65B1F0089E;
	Sun, 15 Nov 2026 04:01:36 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794715297;
	bh=ekNkURalsL5MHlKPQd8PSLVr4r63qFXeHmS9Q5qJzWc=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=ESfALudJy8ftNw12uUwTT+1vSTxumbbmBxmqHmGUBKsCIHNWDJ0bugt4k4xK1yC+7
	 R0ABn1p6C+oJTmT9MvC2sngyDKZYitJyqsCt6xIcp80uFT99BsBs4/8PFdjwzqEQUE
	 +pG1Y878LTmdQGS1L8A3RgzwIMLUN6jqoEtfoO0UUPELYPMUtL/QQpQ0yTQevewvJf
	 YXmdLsC2ZtiN32GVuIuKu1V9hBThAKHXMNnXWbGAGKcfSYL/Vt/SmlSXt/oLD9P1wg
	 jLNekQI7MRo7YO24e5Eq80oE9BGk0bld/g2Mv4i0W7FfC/9+P+tTCs0dpEfNtYq0Hm
	 aQSNmKv1TxjYg==
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, 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: <20261113-vsock-guest-ns-v6-8-3737ce4673c0@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