From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 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== 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== 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 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) 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 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 673CB1F0089B; Wed, 2 Dec 2026 19:07:20 +0000 (UTC) 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== Subject: Re: [PATCH net-next v8 7/7] selftests/vsock: test the netns assign privilege checks 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 Date: Wed, 02 Dec 2026 19:07:19 +0000 Message-ID: <179623843993.3146.5538433056705278892@kernel.org> In-Reply-To: <20261130-vsock-guest-ns-v8-7-5fff852d325b@meta.com> References: <20261130-vsock-guest-ns-v8-7-5fff852d325b@meta.com> X-sashiko-severity: Low Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 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