From nobody Sat Feb 7 06:21:13 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B19F34BA52; Wed, 29 Oct 2025 12:24:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761740652; cv=none; b=Vzq77ssWxtqLmtsVGs7/NCoLujjltpUb7wXt+3X8hNuHw6Gwk4LRvafZh/ojRBMqHQwCUlRglh0OzkLDpkVq/odlUAg2M3pPzAkPnBJSGzrFCMgZgpJRjhaRgmB4tCILumsNL9YOOz/FhHDrXyyFsZ/hkttyJhBqJsoZEemWLWE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761740652; c=relaxed/simple; bh=UxNNzwwfXU08oQlPAvQ0Gj3cx0fWVzo9FwN6OUP3IWE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=khKvmfK0uSlo63L3gsALq35uhSmaujLGl7qSRuuap/F9loO6FOugIS/zjdyAz96X4lv50dXSjgM5S7OjRMpCGdR0kiTw4bBDDPTIDfaNTQAlsnj+opdpF6mF+vBpg8JHmivLl85TJHBcelN/bjEHeQVhKc63kNsKaNqhVqSadjQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ftoIVkHd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ftoIVkHd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7CF2C4CEF7; Wed, 29 Oct 2025 12:24:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1761740651; bh=UxNNzwwfXU08oQlPAvQ0Gj3cx0fWVzo9FwN6OUP3IWE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ftoIVkHdaHfvZvDFqD5bJCyr/vQKZVvfkxYmmXsO45DF7XhPQ9TspaV2/6Wrocxg3 Wb62lGG2CoAyPPpCUDbo1drl0TYoj1Lcc/mH5W01CNhP4CzJHTvkaytd40jas8ZQTQ 0DaxXSLBU5TmU3K3qEgJ2/PBubJh+gpZSn4nE1j9q5QAVDZgzadNg1f0vwOrj3WA/n e5lUNA8MKwPzdb0aEcaR501Pr0vb5rhc3NbDvhvI7/WESioLxNxJnDll3I80ie81ng 3U9XxnKm5xQQNc7L2SAg9e3Nr3Wt+Ux0hPXTkHwQhsH2wGLtcTOuEe/tiaV3GA5Opg RG33PJpsTZI/w== From: Christian Brauner Date: Wed, 29 Oct 2025 13:20:55 +0100 Subject: [PATCH v4 42/72] selftests/namespaces: fourth listns() test Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251029-work-namespace-nstree-listns-v4-42-2e6f823ebdc0@kernel.org> References: <20251029-work-namespace-nstree-listns-v4-0-2e6f823ebdc0@kernel.org> In-Reply-To: <20251029-work-namespace-nstree-listns-v4-0-2e6f823ebdc0@kernel.org> To: linux-fsdevel@vger.kernel.org, Josef Bacik , Jeff Layton Cc: Jann Horn , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Daan De Meyer , Aleksa Sarai , Amir Goldstein , Tejun Heo , Johannes Weiner , Thomas Gleixner , Alexander Viro , Jan Kara , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, bpf@vger.kernel.org, Eric Dumazet , Jakub Kicinski , netdev@vger.kernel.org, Arnd Bergmann , Christian Brauner X-Mailer: b4 0.15-dev-96507 X-Developer-Signature: v=1; a=openpgp-sha256; l=1513; i=brauner@kernel.org; h=from:subject:message-id; bh=UxNNzwwfXU08oQlPAvQ0Gj3cx0fWVzo9FwN6OUP3IWE=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWQysfWtj/Ll/T6XfW9MvsXJh290nPwb7wTcfz2Dd2tjx Z2Xp10OdZSyMIhxMciKKbI4tJuEyy3nqdhslKkBM4eVCWQIAxenAEyk5DXDXxmVaXeyV3Y/Mvmb sHHeB8O2wvKFV2y+20lUPrxmOy0w0Inhn0bbI8WeA1vPP99objXpYXyxzEuJlU39sS9Ws2294TN bgA8A X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Test listns() with LISTNS_CURRENT_USER. List namespaces owned by current user namespace. Signed-off-by: Christian Brauner --- tools/testing/selftests/namespaces/listns_test.c | 33 ++++++++++++++++++++= ++++ 1 file changed, 33 insertions(+) diff --git a/tools/testing/selftests/namespaces/listns_test.c b/tools/testi= ng/selftests/namespaces/listns_test.c index 7dff63a00263..457298cb4c64 100644 --- a/tools/testing/selftests/namespaces/listns_test.c +++ b/tools/testing/selftests/namespaces/listns_test.c @@ -168,4 +168,37 @@ TEST(listns_pagination) } } =20 +/* + * Test listns() with LISTNS_CURRENT_USER. + * List namespaces owned by current user namespace. + */ +TEST(listns_current_user) +{ + struct ns_id_req req =3D { + .size =3D sizeof(req), + .spare =3D 0, + .ns_id =3D 0, + .ns_type =3D 0, + .spare2 =3D 0, + .user_ns_id =3D LISTNS_CURRENT_USER, + }; + __u64 ns_ids[100]; + ssize_t ret; + + ret =3D sys_listns(&req, ns_ids, ARRAY_SIZE(ns_ids), 0); + if (ret < 0) { + if (errno =3D=3D ENOSYS) + SKIP(return, "listns() not supported"); + TH_LOG("listns failed: %s (errno=3D%d)", strerror(errno), errno); + ASSERT_TRUE(false); + } + ASSERT_GE(ret, 0); + + /* Should find at least the initial namespaces if we're in init_user_ns */ + TH_LOG("Found %zd namespaces owned by current user namespace", ret); + + for (ssize_t i =3D 0; i < ret; i++) + TH_LOG(" [%zd] ns_id: %llu", i, (unsigned long long)ns_ids[i]); +} + TEST_HARNESS_MAIN --=20 2.47.3