From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CA9126FA6F for ; Tue, 7 Apr 2026 14:35:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572561; cv=none; b=GfQhNfUks+eofszBOC7ThSbjOFdw26ZXfAZ9uTYKnvww0fHCnzbYhaIvrw5ifMbyE/3CCaJ03nq/nWPFpiaT5dvzVVqP9sOXkiJTFtPfHsYHmjei5NNVrHwO0jOe6cl4lrYyBSGpGKCS/hJ+AMBaZUUxuOMJXMGjtEpeYObR0JM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775572561; c=relaxed/simple; bh=ruJfw0yxki9i49bwWKgVXg9RYwXel0TmFTpZwK8U93A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iLu8FB8xRQSSuVLUqw4YLWLUUk8s+1sdiclt5Tb7EtmnpoQyqjFUoZyWDAmM3z5zMmTca+OURrkaMG+S1vMeXEwVzmWQC59tTBE0Jlc1/LcSELc/rilNGXxqShGbohMLDFKDas2AmzBeTxB8JWgazBM09wM4GC3TCS7GA8Lg78A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=S8dkUqVx; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="S8dkUqVx" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-488aa77a06eso38127295e9.0 for ; Tue, 07 Apr 2026 07:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1775572558; x=1776177358; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=LwQXi5Tu0OP3YXIfJ0yEywBxARJgRMYgFrQgcpLPUL0=; b=S8dkUqVxysSSKE5iR8LdKcCzLZMdX3Vs42CqLgSJOubLtWtL1KfAFGZPsnLUJvbkh+ D19yaW39ts/TLCdclmNqCZucEh3OsMwQceoHfDiWuHPCsxGm6a+pYKXwQIBjlzBVaJs3 GAGrLyOnvCe+PFsITAbQpG3hqZMjZanhYiCKmgptw1teNP450zSrqGqE8exqG0cC0qdw 48X5TjlK8lGtpFBY+5T1Vq6TxlftnErDbUDPjYEnZZgx2Gg+lx1qtC5ey/VApvrhICZZ s6+3Y7qheyVtD16W4/nqlYErGQq3DY3xjp42QfuoqYtq1WZ2B7laKwgw6HCI3kddM2h5 x0ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775572558; x=1776177358; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=LwQXi5Tu0OP3YXIfJ0yEywBxARJgRMYgFrQgcpLPUL0=; b=bQiFoML6lhb4K1aMOFOETfIWtSf2E2FBhILt8wPBl3D4+pfA6dAJNMelf+F2yocaWo QSqmzY/NtIaseph3ucvVigHOCtvS0vEDY//dLYweCFTCPNRGXlMhZGhWKlJrxhFQZAlc 0umn2ov5wD1B7PDR13jYCtHsch5teStKT4V7vSvo9ZKdG5aRzAv5lz96L6+gFAAChGp0 2TO7bFLGIVRqJVkoz5kZR3ima/I9T2rrwwK9UJH88VKVYCNCcyta/kq15GcSbjDUtt6d pH2MpkWlogUPZFwq8d+wkZVeMBb8EzyucDOxBrHUWh2wmq/OarcMrCRmv2k7KlXbMJQ9 qhqw== X-Forwarded-Encrypted: i=1; AJvYcCXb7BYQmHzEw4Log8ygqzdHCHZxV5fTgFYb+Z+tYfuCMrcmk59UM5X7CWF9VY4ASdNPvbxpMO4MAey3MsU=@vger.kernel.org X-Gm-Message-State: AOJu0Yyy2VIbMjiAjxz+NdAc7BoF1914OY2m4ZInoLVJh7tAtNXVZNcl c9FVnoN4Ahwygrn6aoUy6mj8TjKgjNAkEHn5O7+YAdAu9DGSZLvUZ8kXGULT/eHqad8= X-Gm-Gg: AeBDieuqJxpWYbTaz24CwH6O3FLgRy7wQjpVnfhSdVKNRy1NO3n1g01YlabNcwW1tr2 JhZK3GXJpDRVSXQlFXRsxeeFhzyLuIXZxsH5XbBf6/wiit/mThMMAPif9KZS7bEhrzYSwC+BG61 wxg/ZTxDUXhRRphaLNZXAbGGy8n46k8N2vkjb5fBqS67q6cv+2hpOviRdCXrYR9P5xZJxo7V2NL BQlNenoG/bfnuQ/CCN0jzbQVzLEqBuIrBLBY41a5ozyhxnItU8/MHWeet0+3uSJT/JBc7iAWrfM ZNbuujkIa/6mORU8rxD89mBjGTg13ND1cEnXQlSj0CLtEn79Cu2zUiBqncb0EFGLQv3iMAN5kCW /pltSlKn8+7Xd7v/8tw8vm7v7InUgX6CvDviE4J0rwlw+d5oNBBOA6kxlrvOJlgcWQpJFBozVjY WjrhdpJZpWUgXN X-Received: by 2002:a05:600c:a404:b0:488:b749:8478 with SMTP id 5b1f17b1804b1-488b74988e4mr67381975e9.6.1775572557735; Tue, 07 Apr 2026 07:35:57 -0700 (PDT) Received: from localhost ([2804:7f0:b767:120d:a4df:3777:2c55:2b95]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2ca78df5ed3sm16357686eec.6.2026.04.07.07.35.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Apr 2026 07:35:56 -0700 (PDT) From: =?utf-8?q?Ricardo_B=2E_Marli=C3=A8re?= Date: Tue, 07 Apr 2026 11:35:46 -0300 Subject: [PATCH 2/3] selftests/namespaces: Fix waitpid race in listns_efault_test cleanup 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: 8bit Message-Id: <20260407-selftests-namespaces_fixes-v1-2-59109909d88b@suse.com> References: <20260407-selftests-namespaces_fixes-v1-0-59109909d88b@suse.com> In-Reply-To: <20260407-selftests-namespaces_fixes-v1-0-59109909d88b@suse.com> To: Shuah Khan , Christian Brauner Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, "Ricardo B. Marliere" X-Mailer: b4 0.15.1 X-Developer-Signature: v=1; a=openssh-sha256; t=1775572546; l=3317; i=rbm@suse.com; h=from:subject:message-id; bh=ruJfw0yxki9i49bwWKgVXg9RYwXel0TmFTpZwK8U93A=; b=U1NIU0lHAAAAAQAAADMAAAALc3NoLWVkMjU1MTkAAAAgguRCc5X8/UX9M40lkMnr//aFGOhce x5ezt8MFNUFlqYAAAAGcGF0YXR0AAAAAAAAAAZzaGE1MTIAAABTAAAAC3NzaC1lZDI1NTE5AAAA QF0cRacwgjbTV7M69qSX6/IpJxZn3/A2k77vLqxIKuj/B9Azjr5TbQSFO0/nkgeniJ+RUWGmaEy r+dMejsrdawo= X-Developer-Key: i=rbm@suse.com; a=openssh; fpr=SHA256:pzhe0fJpYLz+3cZ33FFPhIfaUElk9CXPFFXmalIH+1g The efault tests spawn two categories of child processes: namespace children (each in its own mount namespace, for concurrent destruction) and an iterator child that calls listns() in a tight loop. The cleanup loop used waitpid(-1), which reaps any child in any order. If the iterator child exits early (e.g. because listns() returned ENOSYS) before all namespace children have been reaped, waitpid(-1) may consume it instead. The subsequent targeted waitpid(iter_pid) would then block indefinitely. Track the PIDs of the namespace children explicitly and use targeted waitpid() calls in the cleanup loop so the iterator child cannot be inadvertently reaped during namespace cleanup. Signed-off-by: Ricardo B. Marlière --- tools/testing/selftests/namespaces/listns_efault_test.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tools/testing/selftests/namespaces/listns_efault_test.c b/tools/testing/selftests/namespaces/listns_efault_test.c index c7ed4023d7a8..ac3b208264f5 100644 --- a/tools/testing/selftests/namespaces/listns_efault_test.c +++ b/tools/testing/selftests/namespaces/listns_efault_test.c @@ -39,7 +39,7 @@ TEST(listns_partial_fault_with_ns_cleanup) __u64 *ns_ids; ssize_t ret; long page_size; - pid_t pid, iter_pid; + pid_t pid, iter_pid, ns_pids[5]; int pidfds[5]; int sv[5][2]; int iter_pidfd; @@ -115,6 +115,7 @@ TEST(listns_partial_fault_with_ns_cleanup) pid = create_child(&pidfds[i], CLONE_NEWNS); ASSERT_NE(pid, -1); + ns_pids[i] = pid; if (pid == 0) { close(sv[i][0]); /* Close parent end */ @@ -165,7 +166,7 @@ TEST(listns_partial_fault_with_ns_cleanup) /* Wait for all mount namespace children to exit and cleanup */ for (i = 0; i < 5; i++) { - waitpid(-1, NULL, 0); + waitpid(ns_pids[i], NULL, 0); close(sv[i][0]); close(pidfds[i]); } @@ -251,7 +252,7 @@ TEST(listns_late_fault_with_ns_cleanup) __u64 *ns_ids; ssize_t ret; long page_size; - pid_t pid, iter_pid; + pid_t pid, iter_pid, ns_pids[10]; int pidfds[10]; int sv[10][2]; int iter_pidfd; @@ -321,6 +322,7 @@ TEST(listns_late_fault_with_ns_cleanup) pid = create_child(&pidfds[i], CLONE_NEWNS); ASSERT_NE(pid, -1); + ns_pids[i] = pid; if (pid == 0) { close(sv[i][0]); /* Close parent end */ @@ -374,7 +376,7 @@ TEST(listns_late_fault_with_ns_cleanup) /* Wait for all children and cleanup */ for (i = 0; i < 10; i++) { - waitpid(-1, NULL, 0); + waitpid(ns_pids[i], NULL, 0); close(sv[i][0]); close(pidfds[i]); } @@ -403,7 +405,7 @@ TEST(listns_mnt_ns_cleanup_on_fault) __u64 *ns_ids; ssize_t ret; long page_size; - pid_t pid, iter_pid; + pid_t pid, iter_pid, ns_pids[8]; int pidfds[8]; int sv[8][2]; int iter_pidfd; @@ -463,6 +465,7 @@ TEST(listns_mnt_ns_cleanup_on_fault) pid = create_child(&pidfds[i], CLONE_NEWNS); ASSERT_NE(pid, -1); + ns_pids[i] = pid; if (pid == 0) { close(sv[i][0]); /* Close parent end */ @@ -509,7 +512,7 @@ TEST(listns_mnt_ns_cleanup_on_fault) /* Wait for children and cleanup */ for (i = 0; i < 8; i++) { - waitpid(-1, NULL, 0); + waitpid(ns_pids[i], NULL, 0); close(sv[i][0]); close(pidfds[i]); } -- 2.53.0