From nobody Sun Jun 14 20:00:20 2026 Received: from outbound.st.icloud.com (p-east2-cluster5-host11-snip4-8.eps.apple.com [57.103.79.71]) (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 E2DDA3128BE for ; Sun, 5 Apr 2026 16:54:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.79.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775408048; cv=none; b=YWzmkde5BNSB7wXNCEMpoik/4XhLDqWI530Ms5osb7dVRPCH9xqzGzgcxJR0fbNQH0BEnXBYPAPuH0S+jXOvwRv+0nXTi2o2Ly4Gc8fCjlYsOrEMC+0XAm4r0j4y+y57SDlct7bCiYHtHVGrwJ165yWpPv56tdpfBUOERqKa6zI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775408048; c=relaxed/simple; bh=V+f/p6QzvKhmCvnCML+j1mBxAkUk1payovBcQk4Scyc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hYmDGnFaHImKQ0MDLR4Pi0IG+61nazLOOkU4hWrlg3WrpcX4faDce2lCY0sVIU/PL8YBsouM++hhxc1KjbwrE9/TZJVLN1/r1mCRI1OMc/9shOiDg7Bwvrt4Vw5Zs0/Ad6uowHSav9mgvVLP8qLXO5zBm7URnDW/3ND5nmxpZQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=y-koj.net; spf=pass smtp.mailfrom=y-koj.net; dkim=fail (0-bit key) header.d=y-koj.net header.i=@y-koj.net header.b=BAVFrDxP reason="key not found in DNS"; arc=none smtp.client-ip=57.103.79.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=y-koj.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=y-koj.net Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=y-koj.net header.i=@y-koj.net header.b="BAVFrDxP" Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-6 (Postfix) with ESMTPS id 947F91800BB1; Sun, 05 Apr 2026 16:54:02 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=y-koj.net; s=sig1; t=1775408045; x=1778000045; bh=uOPj5kIodIgoKiM9QuSEnFQRR8ZiDFL2f0iafOmBcbY=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=BAVFrDxPZ+O77AclS7JjWCExcNYmchUYZp/Yes4pR+s3APt9sdqy2C4qJjT5s8TIJBBWgt+liOu9q6MbG7e6Et+57HP6gAdOm0Ych4MxfFW+KX17CNNCBzRbXVMqHi5YHT7oKTXhFZSTcu5XEiN9MMiNKWMEM8kfcqvbthBOe5NU+cJCaEZixoJko4F5fhacfalP/Fn2ZoYhHRZ7MnvTSlCcOnjE7KuMAt88W/9P/CmmqRncoyl/Fpg7AcSaIDqlG3UxqX/ZNzywcxjQD8UBfihFcUgUeZ53C70TrbSS5FiFhCsRMxUpUo0cLjnnvUX6zm2QgBMTUMDFV1L8D3wG4A== mail-alias-created-date: 1719758601013 Received: from desktop.y-koj.net (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-6 (Postfix) with ESMTPSA id A6AC71800D14; Sun, 05 Apr 2026 16:52:14 +0000 (UTC) From: Yohei Kojima To: Christian Brauner , Shuah Khan Cc: Yohei Kojima , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] selftests/namespace: fix selftest hang-up caused by zombie processes Date: Mon, 6 Apr 2026 01:50:37 +0900 Message-ID: <7b2c83e0fe0e17bd11a10135c9d9d169a97d0ea7.1775404451.git.yk@y-koj.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: NdXQLXhoE_vu8isxnIxUyjFSZDUeESPG X-Proofpoint-GUID: NdXQLXhoE_vu8isxnIxUyjFSZDUeESPG X-Authority-Info-Out: v=2.4 cv=BLG+bVQG c=1 sm=1 tr=0 ts=69d293ab cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jnl5ZKOAAAAA:8 a=AYMzduBVUvBKa7S8i9gA:9 a=RNrZ5ZR47oNZP8zBN2PD:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA1MDE3NiBTYWx0ZWRfX8lq0dhgpRtju +kn5K10xip19jo2IwHeTQDamkK0l1oeLdQGP9/tmiOoyXWcz6mmD3IwgKGYTL/yZtYFKaiU1J4z j1nV0E7lzaJw50DsUGDHwEQn/MqgeBtTTvqJOYoL4fshNgPczGohpTtFBRB+TY1cCdcDEPmqij4 YY3rNoyD61wPAAOs9C3aMB+AaQsqbFKAx7E4140nV9j/ENltKv+L8Tc1JOgtaSwjqlPVI1yCHwU snbbeC3cxe89Snd3VITCdmZZDMnmwQrRbWnNFUG7Sz5IGxD+wdWeR5Xlx8z33GV+ytESMjCoYP/ qrC0kskI+NxjEpS+51iIDcxpyLTjIT2gdu7pweo+ZAn5XJEpI5Fiw/KoNNfpXg= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-05_05,2026-04-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1030 mlxlogscore=838 lowpriorityscore=0 suspectscore=0 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604050176 Content-Type: text/plain; charset="utf-8" Fix zombie grandchild processes spawned by timens_separate and pidns_separate tests in nsid_test.c. This also prevents kselftest from hanging up after running these tests. Signed-off-by: Yohei Kojima --- tools/testing/selftests/namespaces/nsid_test.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/namespaces/nsid_test.c b/tools/testing= /selftests/namespaces/nsid_test.c index b4a14c6693a5..1e2669372b7b 100644 --- a/tools/testing/selftests/namespaces/nsid_test.c +++ b/tools/testing/selftests/namespaces/nsid_test.c @@ -25,10 +25,12 @@ /* Fixture for tests that create child processes */ FIXTURE(nsid) { pid_t child_pid; + pid_t grandchild_pid; }; =20 FIXTURE_SETUP(nsid) { self->child_pid =3D 0; + self->grandchild_pid =3D 0; } =20 FIXTURE_TEARDOWN(nsid) { @@ -37,6 +39,10 @@ FIXTURE_TEARDOWN(nsid) { kill(self->child_pid, SIGKILL); waitpid(self->child_pid, NULL, 0); } + if (self->grandchild_pid > 0) { + kill(self->grandchild_pid, SIGKILL); + waitpid(self->grandchild_pid, NULL, 0); + } } =20 TEST(nsid_mntns_basic) @@ -677,6 +683,7 @@ TEST_F(nsid, timens_separate) pid_t grandchild_pid; ASSERT_EQ(read(pipefd[0], &grandchild_pid, sizeof(grandchild_pid)), sizeo= f(grandchild_pid)); close(pipefd[0]); + self->grandchild_pid =3D grandchild_pid; =20 /* Open grandchild's time namespace */ char path[256]; @@ -798,6 +805,7 @@ TEST_F(nsid, pidns_separate) pid_t grandchild_pid; ASSERT_EQ(read(pipefd[0], &grandchild_pid, sizeof(grandchild_pid)), sizeo= f(grandchild_pid)); close(pipefd[0]); + self->grandchild_pid =3D grandchild_pid; =20 /* Open grandchild's PID namespace */ char path[256]; --=20 2.52.0 From nobody Sun Jun 14 20:00:20 2026 Received: from outbound.st.icloud.com (p-east2-cluster5-host1-snip4-4.eps.apple.com [57.103.79.7]) (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 16340318B9C for ; Sun, 5 Apr 2026 16:54:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.79.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775408050; cv=none; b=ZuROdCFw1zknSobSTsqV1znfPX0GbnCkQ08bUvte/+DTOGW3/PnybnzA+9AX4J+AyqHXDpiy3jIAHrwDRItKJDy7MfnQPObo/Wn00y6sNeVorPwH0pmGbH6evH/oTnwhqReVJ24FsdTVt4XUQAbbqvLwgoU1moCsQW6SLtoXJ2o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775408050; c=relaxed/simple; bh=qDDMBivbPcAFOPeT6eY3oxNcMchO1/ahOVBlqetBVQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MtPFxips8W+S2T4p/aN9Uk/oxLQzSNOZk5uTCQ34F51/RT0j6ZviUPYXVZks2yOOBHNKGn6i4bX2Ec6EpWdv1I4QXSYXwpLKUtK7stXStrFRh4qLzi5NFyNG/ShgzOnQrYTaFGcXhIovD2RQshFDtuuUG2eumFMYUWS4PD2LJBI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=y-koj.net; spf=pass smtp.mailfrom=y-koj.net; dkim=fail (0-bit key) header.d=y-koj.net header.i=@y-koj.net header.b=nIwAzNnK reason="key not found in DNS"; arc=none smtp.client-ip=57.103.79.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=y-koj.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=y-koj.net Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=y-koj.net header.i=@y-koj.net header.b="nIwAzNnK" Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-6 (Postfix) with ESMTPS id 6FE591800BBD; Sun, 05 Apr 2026 16:54:06 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=y-koj.net; s=sig1; t=1775408048; x=1778000048; bh=P++qanB99WVd4a1fk5cwJruX1uubGSks4JWteV9qK9E=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=nIwAzNnKbbcBZS2UAzfv04RaJtRMSx+3p6SQpKIMt4XuSNWS8+dBURwF5rSCkcmiriAbLxvwzeoS5nCvfI0aWy+2hly14g57CiqsN/mCGuqH4682uYZqXmxrlIOg0UCEbrkFpZkSxVtqVVFIgMYCHvLAszT2Yq/k0rBxKq4yhT6n9bO8cMDt3wyD03v9LQV9kl4UByFNQn3ZyOGLAUMolfUMSNu7XjydFukw9T6jmXb3uLvBa7XMuwQ6X++EVlPX6u4LWf7Z5jw0CQLpFion2cGw6VseJhKsin9o4RsOuKu1E4kiTFIDUeT30E3kspVfNSMiPEOFOQAGSmLBJJiJMA== mail-alias-created-date: 1719758601013 Received: from desktop.y-koj.net (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-6 (Postfix) with ESMTPSA id 5AAB21800D31; Sun, 05 Apr 2026 16:52:24 +0000 (UTC) From: Yohei Kojima To: Christian Brauner , Shuah Khan Cc: Yohei Kojima , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] selftests/namespace: fix unintentional skip in ns_active_ref_test.c Date: Mon, 6 Apr 2026 01:50:38 +0900 Message-ID: <0b2a5dba0b5ce5a4e144237b9f365fe8fa971871.1775404451.git.yk@y-koj.net> X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: TdN8Dc0ZLaoMmPwcZ_X839qEZ-FwmHnC X-Proofpoint-GUID: TdN8Dc0ZLaoMmPwcZ_X839qEZ-FwmHnC X-Authority-Info-Out: v=2.4 cv=BLG+bVQG c=1 sm=1 tr=0 ts=69d293ae cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jnl5ZKOAAAAA:8 a=jO6NblF5zQOfC-Z75CIA:9 a=RNrZ5ZR47oNZP8zBN2PD:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA1MDE3NiBTYWx0ZWRfX1AlbpBI6rXYA 9lKQ0kg5+ioNd8+4LkFCAJd+y/ZPn2UKt2ouJoxqr63fIj3f/G/BEKqHVrPlQqUvkDBG7a1qFjN OcRW9LWBjIqxyW3yWh3CxblKLufr+AIYdYXX265h2oDwVBfowt1LTcoDdMc4EDfydm+0eg57M6Q luaSQ1GCyikPV9beUC5mpQZ2zrGRAnADwen1kLs8rr56ZjCiloWaQG1MpB3pjaf55Hh7ugbpuK2 ToWnR3oF+KeCuLpoF0BMfk/jvxSzqOvzZ1LpzkqmHs6f3n3+gXecG5hCURbQwVfWHX2bk2KIhye hK5qMco0WXsBc/EnTH5y/s7tNwftwev/paZU/iYTxnHznAFIfh2u8K6o2EpAKE= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-05_05,2026-04-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1030 mlxlogscore=744 lowpriorityscore=0 suspectscore=0 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604050176 Content-Type: text/plain; charset="utf-8" Fix ESTALE from open_by_handle_at() in ns_multiple_children_same_parent when child processes exit before the parent run it. Signed-off-by: Yohei Kojima --- tools/testing/selftests/namespaces/ns_active_ref_test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/namespaces/ns_active_ref_test.c b/tool= s/testing/selftests/namespaces/ns_active_ref_test.c index 093268f0efaa..29d96a6e8100 100644 --- a/tools/testing/selftests/namespaces/ns_active_ref_test.c +++ b/tools/testing/selftests/namespaces/ns_active_ref_test.c @@ -1193,6 +1193,10 @@ TEST(ns_multiple_children_same_parent) write(pipefd[1], &c1_id, sizeof(c1_id)); write(pipefd[1], &c2_id, sizeof(c2_id)); close(pipefd[1]); + + /* give parent a time to run open_by_handle_at() */ + usleep(10000); + exit(0); } =20 --=20 2.52.0 From nobody Sun Jun 14 20:00:20 2026 Received: from outbound.st.icloud.com (p-east2-cluster5-host8-snip4-6.eps.apple.com [57.103.79.39]) (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 55B0B314B93 for ; Sun, 5 Apr 2026 16:54:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.79.39 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775408050; cv=none; b=pX8rNQB5l9kMf1hzpABrBoiyP4sIPFAaYjYCtbqbuenLPVGPhpcoi+bW0hpIPJhe9uXMMehJXQ0MsAbluymYP8UZ04RBkyo2clbLStC1sSY+G80ygxQjQzi/KOW5hJCyfEBu5zPvhUxbzpYH2O9XKlSpLvGSD65ciTDk8rxA9l0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775408050; c=relaxed/simple; bh=dpzep7CuJUyQ4oOXK2u+mXps1e2CVZNuzYgiGwnuiho=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JRmP1LodPFcGEnb7ckDhk8Phh4T1JEPZ80qw8TFFbhylcZPwckFhtIVHSdOPEvaWoxX8by4XFkTgI0ZAaLFl/56wpf+SHZfG48EBktgdVuE+Ws52h0R2XxMcPGBI60z9SQsvINZm37KqyTu+pgvwEHcJufzzXaZ9ceqtATCsnVg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=y-koj.net; spf=pass smtp.mailfrom=y-koj.net; dkim=fail (0-bit key) header.d=y-koj.net header.i=@y-koj.net header.b=WBB4N//0 reason="key not found in DNS"; arc=none smtp.client-ip=57.103.79.39 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=y-koj.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=y-koj.net Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=y-koj.net header.i=@y-koj.net header.b="WBB4N//0" Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-6 (Postfix) with ESMTPS id 3F1111800B86; Sun, 05 Apr 2026 16:54:08 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=y-koj.net; s=sig1; t=1775408048; x=1778000048; bh=mu9GPhEjV1sXVPEctTosQ4rZ0Uc8Riw++0yPOtB7lm4=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=WBB4N//0ZriRZdZNC4xj1q9yHYgr9FKpKgvMuoNxHGlnYVsOTPmE329VXA6ofvua9kI2pTj9hSCgY4Yrff6+g3Y5ckAolyK1kSTmzUEMba4zn0J/VSsK+AxYxssd+2z/ZYDXV29oVWx0kiKLRVfyPGL0/KmZCzdAp4u+9+jJKp80EwZa57pRI9Y3OwmeP25esyouUI5upuaAqCLboQZ1jbvJ4efOkzQj76ky3XdCXzuBOFzPqxB5Z/NndO9b90HaJ+5WiORG6Yj3YsHnQRQqik+px577cTzK4QV8vGFpstdo+AF03CufHXCs2DDbhFPktyZWzXwu5UxOEJxc/xs6Wg== mail-alias-created-date: 1719758601013 Received: from desktop.y-koj.net (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-6 (Postfix) with ESMTPSA id 8F7651800FFD; Sun, 05 Apr 2026 16:52:29 +0000 (UTC) From: Yohei Kojima To: Christian Brauner Cc: Yohei Kojima , linux-kernel@vger.kernel.org Subject: [PATCH 3/4] nstree: Fix spurious ENOENT in listns pagination during grace period Date: Mon, 6 Apr 2026 01:50:39 +0900 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: 1Y80KsAwImS3q7iiZxsVt5YtuOqW2o4G X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA1MDE3NiBTYWx0ZWRfX9flNpJOR3oel fs9Qs1x33AIuxOFwzcHaaQivvXXZNE2S6FW79Iop52bF2cNqvPICvErzdB8gbRSeBDpt0UbLdTD tyGnJcm5LxdbyjfB8DubLMYId0OBDQc+uxQrI3mqJ1C1UdAXunWfjfoJUcJL78sAAhadxTjcXSL QrqDvTIHocuQyo3P6rCQTXBxFHbejQ/Nbmocn1uIaLZdGTZV2gXngU0pgp5IbGwB/kovjsApgLL y6920hv4YfMSVHdi6ONB/Yb3fgtHcHJpG0SnZCw7jsdIYuh/Btjq8xxBAA4cV5BSZ7M0IGW2R5l MyY+Vfd4LjfldzaVTNf4A1d70gtMlG60L2PIhX7k8vPVxczFA5ni1HDmqFgTZg= X-Authority-Info-Out: v=2.4 cv=ArnjHe9P c=1 sm=1 tr=0 ts=69d293b0 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jnl5ZKOAAAAA:8 a=ilVEDnY-_uOBHNOHIFwA:9 a=RNrZ5ZR47oNZP8zBN2PD:22 X-Proofpoint-GUID: 1Y80KsAwImS3q7iiZxsVt5YtuOqW2o4G X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-05_05,2026-04-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 phishscore=0 clxscore=1030 malwarescore=0 lowpriorityscore=0 mlxlogscore=781 bulkscore=0 adultscore=0 mlxscore=0 spamscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604050176 Content-Type: text/plain; charset="utf-8" Fix false ENOENT returned from listns when (1) pagination is used (req.ns_id !=3D 0) and (2) listns tries to start enumeration from a destroyed or inactive namespace. The cause was that lookup_ns_id_at(kls->last_ns_id + 1, ...) returned NULL if the first namespace after ns_id was destroyed or inactivated like below: (Note that we can take nstree as a list as it is an rbtree sorted by ns id.) A: active namespace D: destroyed (or inactive) namespace +-----+-----+-----+-----+-----+-----+-----+-----+ state: | A | A | A | D | D | A | A | A | ns_id: | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | +-----+-----+-----+-----+-----+-----+-----+-----+ | | | +-- (kls->last_ns_id + 1) +-- req.ns_id =3D 3 In this case, lookup_ns_id_at() returns NULL, which results in -ENOENT returned from do_listns() although three namespaces remains in the nstree. The bug is fixed by iterating over the nstree's internal list until it reaches the first active namespace. Fixes: 76b6f5dfb3fd ("nstree: add listns()") Signed-off-by: Yohei Kojima --- kernel/nstree.c | 68 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 22 deletions(-) diff --git a/kernel/nstree.c b/kernel/nstree.c index 6d12e5900ac0..476d22203ee0 100644 --- a/kernel/nstree.c +++ b/kernel/nstree.c @@ -618,14 +618,32 @@ static ssize_t do_listns_userns(struct klistns *kls) return ret; } =20 +static inline struct ns_common *next_ns_common(struct ns_common *ns, + struct ns_tree_root *ns_tree) +{ + if (ns_tree) + return list_entry_rcu(ns->ns_tree_node.ns_list_entry.next, struct ns_com= mon, ns_tree_node.ns_list_entry); + return list_entry_rcu(ns->ns_unified_node.ns_list_entry.next, struct ns_c= ommon, ns_unified_node.ns_list_entry); +} + +static inline bool ns_common_is_head(struct ns_common *ns, + const struct list_head *head, + struct ns_tree_root *ns_tree) +{ + if (ns_tree) + return &ns->ns_tree_node.ns_list_entry =3D=3D head; + return &ns->ns_unified_node.ns_list_entry =3D=3D head; +} + /* * Lookup a namespace with id >=3D ns_id in either the unified tree or a t= ype-specific tree. * Returns the namespace with the smallest id that is >=3D ns_id. */ static struct ns_common *lookup_ns_id_at(u64 ns_id, int ns_type) { - struct ns_common *ret =3D NULL; + struct ns_common *min =3D NULL, *ret =3D NULL; struct ns_tree_root *ns_tree =3D NULL; + struct list_head *head; struct rb_node *node; =20 if (ns_type) { @@ -651,9 +669,9 @@ static struct ns_common *lookup_ns_id_at(u64 ns_id, int= ns_type) =20 if (ns_id <=3D ns->ns_id) { if (ns_type) - ret =3D node_to_ns(node); + min =3D node_to_ns(node); else - ret =3D node_to_ns_unified(node); + min =3D node_to_ns_unified(node); if (ns_id =3D=3D ns->ns_id) break; node =3D node->rb_left; @@ -662,8 +680,31 @@ static struct ns_common *lookup_ns_id_at(u64 ns_id, in= t ns_type) } } =20 - if (ret) - ret =3D ns_get_unless_inactive(ret); + if (!min) + return NULL; + /* + * Now min->ns_id is the minimum id where min->ns_id >=3D ns_id holds, + * but min could be inactive or destroyed here, therefore + * ns_get_unless_inactive(min) could return NULL. + * + * To handle this case, try acquiring the next ns until it reaches the + * first valid ns. + */ + if (ns_tree) + head =3D &ns_tree->ns_list_head; + else + head =3D &ns_unified_root.ns_list_head; + + while (!ns_common_is_head(min, head, ns_tree)) { + ret =3D ns_get_unless_inactive(min); + if (ret) + break; + + rcu_read_lock(); + min =3D next_ns_common(min, ns_tree); + rcu_read_unlock(); + } + return ret; } =20 @@ -675,23 +716,6 @@ static inline struct ns_common *first_ns_common(const = struct list_head *head, return list_entry_rcu(head->next, struct ns_common, ns_unified_node.ns_li= st_entry); } =20 -static inline struct ns_common *next_ns_common(struct ns_common *ns, - struct ns_tree_root *ns_tree) -{ - if (ns_tree) - return list_entry_rcu(ns->ns_tree_node.ns_list_entry.next, struct ns_com= mon, ns_tree_node.ns_list_entry); - return list_entry_rcu(ns->ns_unified_node.ns_list_entry.next, struct ns_c= ommon, ns_unified_node.ns_list_entry); -} - -static inline bool ns_common_is_head(struct ns_common *ns, - const struct list_head *head, - struct ns_tree_root *ns_tree) -{ - if (ns_tree) - return &ns->ns_tree_node.ns_list_entry =3D=3D head; - return &ns->ns_unified_node.ns_list_entry =3D=3D head; -} - static ssize_t do_listns(struct klistns *kls) { u64 __user *ns_ids =3D kls->uns_ids; --=20 2.52.0 From nobody Sun Jun 14 20:00:20 2026 Received: from outbound.st.icloud.com (p-east2-cluster5-host6-snip4-10.eps.apple.com [57.103.79.103]) (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 72848318EF0 for ; Sun, 5 Apr 2026 16:54:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.103.79.103 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775408058; cv=none; b=c4fPqIpxLuZbnVnNisHwBmk4x36AW1QZC/sYyFkH4UPYT+vzs+JVgB1NEvOQUabdfm8Z9GuF7j+oSvflBRUilZOwUwZVo6AUgx0L67T/nQwz/Xb8wH1ibJR1SSLLNSbUIJ9ofoGawMFeP93IYh/SzcewFrxp6RdqU0pA9IVdbn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775408058; c=relaxed/simple; bh=ikcCdo+WZM8RB3y5OCDr/km8u7w7Iz8WrIeo2sLnU+0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fjvlaVdLCHon7C0m7+OJ9+BsUMdyzlVv1z4AXEGZ0gCgKHLX4EmdxOhDibB9WAUeCs/bWJdtZ2tm1NhnX4s5EGu2oFAQ2LHyj/lmmjpq1HMNYqbJln9FG3DcSWLHtWQHdn7eUWVMExrUhbMWoICSevk+KKTJ0Lb+KXLxkZDq/x8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=y-koj.net; spf=pass smtp.mailfrom=y-koj.net; dkim=fail (0-bit key) header.d=y-koj.net header.i=@y-koj.net header.b=CcHyp63S reason="key not found in DNS"; arc=none smtp.client-ip=57.103.79.103 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=y-koj.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=y-koj.net Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=y-koj.net header.i=@y-koj.net header.b="CcHyp63S" Received: from outbound.st.icloud.com (unknown [127.0.0.2]) by p00-icloudmta-asmtp-us-east-1a-100-percent-6 (Postfix) with ESMTPS id A3C841800D11; Sun, 05 Apr 2026 16:54:10 +0000 (UTC) Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=y-koj.net; s=sig1; t=1775408052; x=1778000052; bh=Uw0z3wNlqUHZIJxWz0zqHyrheKABI/b7SXnMNZgabtk=; h=From:To:Subject:Date:Message-ID:MIME-Version:x-icloud-hme; b=CcHyp63Sn33A99RCrJkvqUekpg3bmuB7d21MDpLcU6QhOimpf4Ek0WfuOytxrDxggBHvZzt4mZTYwwn/C2bhzqeTXTEDlFrXXwObrWnmcKYvwdIHHYpdjzV2XE7QCpaSPJ0YgZNIShdN6Ifh0Cooifm0mJ+VXPwK6Vm2rNxUgguogcfy/Vudq7q4JBA2FhQgj9RWuyeg9eFZ/OZfcM/oQkmUmCvQvZ+CG9HBALiVGoPHfp93+1TpeglJnTKcGMIWmjcFIDVxYP7nG2KXJ5XBBsxvHX/RiQCr6bhDqXqD24eyXXGhNdGMu4iy6Xb4EXMXuE1b6L8Vjg23uz90NCpk7g== mail-alias-created-date: 1719758601013 Received: from desktop.y-koj.net (unknown [17.42.251.67]) by p00-icloudmta-asmtp-us-east-1a-100-percent-6 (Postfix) with ESMTPSA id 5DA1D18000AC; Sun, 05 Apr 2026 16:52:32 +0000 (UTC) From: Yohei Kojima To: Christian Brauner , Shuah Khan Cc: Yohei Kojima , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] selftests/namespace: test spurious ENOENT bug in listns pagination Date: Mon, 6 Apr 2026 01:50:40 +0900 Message-ID: X-Mailer: git-send-email 2.52.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: n4sppodIblwyg0Rj-85evoiZ1nyOrXa2 X-Proofpoint-GUID: n4sppodIblwyg0Rj-85evoiZ1nyOrXa2 X-Authority-Info-Out: v=2.4 cv=BLG+bVQG c=1 sm=1 tr=0 ts=69d293b3 cx=c_apl:c_pps:t_out a=YrL12D//S6tul8v/L+6tKg==:117 a=YrL12D//S6tul8v/L+6tKg==:17 a=A5OVakUREuEA:10 a=VkNPw1HP01LnGYTKEx00:22 a=jnl5ZKOAAAAA:8 a=GaRdEwhpBMmz7FhzV_AA:9 a=RNrZ5ZR47oNZP8zBN2PD:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA1MDE3NiBTYWx0ZWRfX009bN9fbaOZN dBR6t0oD/Xcbafua9qomnkyjL7yozM2A1Ye2a0Zpxw+GO57J8DcRSZHZEFiLsrUubTNMxujwfHB OBJuGde7hcUD2rRJOdXRAimubQgoQep+5Ny/ySFtB3oS+VmKSQEKYm4W/JAS60GdoReFo7xxNS8 M4W137tzmEMxHfT5H/JXeJIbmsHqBkVdOO23xwgaXIilIhpIcghCZy0KG8Fieh2bN8pwKlnKVGd HArqMJqDDF5FHefTzUbCTB3xylx8Y975g2X8DYm4OKy3SD8jhQgoJuAwPORFAdXTIWUnh+PtJkx ZO2CAtZrH2+Rh83j4MTvFKg48XE+zYC0NOvo6L1fBLUAwdygEkkf+GTCtym/Pk= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-04-05_05,2026-04-03_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 clxscore=1030 mlxlogscore=896 lowpriorityscore=0 suspectscore=0 malwarescore=0 mlxscore=0 spamscore=0 adultscore=0 phishscore=0 classifier=spam authscore=0 adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2604050176 Content-Type: text/plain; charset="utf-8" Test spurious ENOENT which occurs when it tried to start pagination from an inactivated or destroyed namespace. The new test is almost identical to pagination_with_type_filter, except that it calls run_noisy_children() which creates and lists namespaces to disturb nstree. As far as the author tested, this bug only reproduced on a baremetal environment, probably because the test relies on the RCU behavior and the kernel behaves differently on VM. Signed-off-by: Yohei Kojima --- .../namespaces/listns_pagination_bug.c | 200 ++++++++++++++++++ 1 file changed, 200 insertions(+) diff --git a/tools/testing/selftests/namespaces/listns_pagination_bug.c b/t= ools/testing/selftests/namespaces/listns_pagination_bug.c index da7d33f96397..f71d8f4d64bb 100644 --- a/tools/testing/selftests/namespaces/listns_pagination_bug.c +++ b/tools/testing/selftests/namespaces/listns_pagination_bug.c @@ -135,4 +135,204 @@ TEST(pagination_with_type_filter) } } =20 +static void run_noisy_children(int num_workers) +{ + struct ns_id_req req =3D { + .size =3D sizeof(req), + .spare =3D 0, + .ns_id =3D 0, + .ns_type =3D CLONE_NEWUSER, /* Filter by user namespace */ + .spare2 =3D 0, + .user_ns_id =3D 0, + }; + pid_t pids[num_workers]; + int num_forked =3D 0; + int i; + + /* + * Create worker processes that do concurrent operations; + * most of this part is borrowed from concurrent_namespace_operations + * test in stress_test.c + */ + for (i =3D 0; i < num_workers; i++) { + pids[i] =3D fork(); + if (pids[i] < 0) + goto failure; + if (pids[i] > 0) + num_forked++; + + if (pids[i] =3D=3D 0) { + /* Each worker: create namespaces, list them, repeat */ + int iterations; + + for (iterations =3D 0; iterations < 10; iterations++) { + int userns_fd; + __u64 temp_ns_ids[100]; + ssize_t ret; + + /* Create a user namespace */ + userns_fd =3D get_userns_fd(0, getuid(), 1); + if (userns_fd < 0) + continue; + + /* List namespaces */ + ret =3D sys_listns(&req, temp_ns_ids, ARRAY_SIZE(temp_ns_ids), 0); + (void)ret; + + close(userns_fd); + + /* Small delay */ + usleep(1000); + } + + exit(0); + } + } + + /* + * Return after waiting for children; this is enough for + * reproduction, and help keeping the test code simple. + */ + for (i =3D 0; i < num_forked; i++) + waitpid(pids[i], NULL, 0); + + return; + +failure: + for (i =3D 0; i < num_forked; i++) + kill(pids[i], SIGKILL); + for (i =3D 0; i < num_forked; i++) + waitpid(pids[i], NULL, 0); +} + +/* + * A test case to reproduce spurious ENOENT in listns pagination + * + * The bug occurs when the ns id to start pagination is inactivated or + * destroyed before listns is called (or during listns is processed). + * + * This test is almost identical to pagination_with_type_filter test + * except that this calls run_noisy_children(). + */ +TEST(pagination_during_grace_period) +{ + struct ns_id_req req =3D { + .size =3D sizeof(req), + .spare =3D 0, + .ns_id =3D 0, + .ns_type =3D CLONE_NEWUSER, /* Filter by user namespace */ + .spare2 =3D 0, + .user_ns_id =3D 0, + }; + pid_t pids[10]; + int num_children =3D 10; + const int num_noisy_children =3D 10; + int i; + int sv[2]; + __u64 first_batch[3]; + ssize_t ret; + + ASSERT_EQ(socketpair(AF_UNIX, SOCK_STREAM, 0, sv), 0); + + run_noisy_children(num_noisy_children); + + /* Create children with user namespaces */ + for (i =3D 0; i < num_children; i++) { + pids[i] =3D fork(); + ASSERT_GE(pids[i], 0); + + if (pids[i] =3D=3D 0) { + char c; + + close(sv[0]); + + if (setup_userns() < 0) { + close(sv[1]); + exit(1); + } + + /* Signal parent we're ready */ + if (write(sv[1], &c, 1) !=3D 1) { + close(sv[1]); + exit(1); + } + + /* Wait for parent signal to exit */ + if (read(sv[1], &c, 1) !=3D 1) { + close(sv[1]); + exit(1); + } + + close(sv[1]); + exit(0); + } + } + + close(sv[1]); + + /* Wait for all children to signal ready */ + for (i =3D 0; i < num_children; i++) { + char c; + + if (read(sv[0], &c, 1) !=3D 1) { + close(sv[0]); + for (int j =3D 0; j < num_children; j++) + kill(pids[j], SIGKILL); + for (int j =3D 0; j < num_children; j++) + waitpid(pids[j], NULL, 0); + ASSERT_TRUE(false); + } + } + + /* First batch - this should work */ + ret =3D sys_listns(&req, first_batch, 3, 0); + if (ret < 0) { + if (errno =3D=3D ENOSYS) { + close(sv[0]); + for (i =3D 0; i < num_children; i++) + kill(pids[i], SIGKILL); + for (i =3D 0; i < num_children; i++) + waitpid(pids[i], NULL, 0); + SKIP(return, "listns() not supported"); + } + ASSERT_GE(ret, 0); + } + + TH_LOG("First batch returned %zd entries", ret); + + if (ret =3D=3D 3) { + __u64 second_batch[3]; + + /* Second batch - pagination triggers the bug */ + req.ns_id =3D first_batch[2]; /* Continue from last ID */ + ret =3D sys_listns(&req, second_batch, 3, 0); + + TH_LOG("Second batch returned %zd entries", ret); + ASSERT_GE(ret, 0); + } + + /* Signal all children to exit */ + for (i =3D 0; i < num_children; i++) { + char c =3D 'X'; + + if (write(sv[0], &c, 1) !=3D 1) { + close(sv[0]); + for (int j =3D i; j < num_children; j++) + kill(pids[j], SIGKILL); + for (int j =3D 0; j < num_children; j++) + waitpid(pids[j], NULL, 0); + ASSERT_TRUE(false); + } + } + + close(sv[0]); + + /* Cleanup */ + for (i =3D 0; i < num_children; i++) { + int status; + + waitpid(pids[i], &status, 0); + } +} + TEST_HARNESS_MAIN --=20 2.52.0