From nobody Sun May 19 13:14:43 2024 Received: from smtp-190f.mail.infomaniak.ch (smtp-190f.mail.infomaniak.ch [185.125.25.15]) (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 CC1E114B093 for ; Fri, 26 Apr 2024 17:30:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.25.15 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714152646; cv=none; b=P1a1fmrmV+XbOTNoXtJIf0kPA40pFz1JXjJ80OqF1LGWWFoDgXyyvj54lRyjJb4B6Hor1rkhJ+uxeo9GaNd8o5WQDzRJVZtuH2fMWt434O0D/Azd/1LKV8Rb5JnPf8lFCXvzzbWF3zzQ3vhEbD0szrcvHrbhxJSvpwTGpw+LnpA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714152646; c=relaxed/simple; bh=XmyroCOnmviDu4Ck4ZtK15VVLAuJClkARAyXC4T8ES0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=LSW/2iCU40YC09isgUjZVqLJnO9PwT83S+EtAtCvGaj8aAtgX1baXyCWAyObWKhcDAj/VmllDNw7Jm8+DpXYEJ9V1aBQVF6460Tjr5QNdG82H70U/OizuCkL5qNTyDMTvhyiD92cwRJkaiiMmn3p8lKYQq0y+oHYlmTHwtWmWRw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=ybaW9O92; arc=none smtp.client-ip=185.125.25.15 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="ybaW9O92" Received: from smtp-4-0000.mail.infomaniak.ch (smtp-4-0000.mail.infomaniak.ch [10.7.10.107]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4VR0150jMtz8QN; Fri, 26 Apr 2024 19:23:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1714152184; bh=XmyroCOnmviDu4Ck4ZtK15VVLAuJClkARAyXC4T8ES0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ybaW9O92jMrO9fZeWdXMslpug+ijbruA5Vzjynavgy5KJICYZsnZePbTVT9ZXpech GUKr96JbQGfadFMuaKTNbNaOlMfD7ZyGpzSElvOCPIj0vzVkJ7TrEihC02+aLSRphb u+SweEFJO0UnezdX/vTvUbf+Zn+cszBf3O2i4Nl4= Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4VR0141kwvzdNd; Fri, 26 Apr 2024 19:23:04 +0200 (CEST) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: Christian Brauner , Jakub Kicinski , Kees Cook , Mark Brown , Shengyu Li , Shuah Khan Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , "David S . Miller" , =?UTF-8?q?G=C3=BCnther=20Noack?= , Will Drewry , kernel test robot , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan Subject: [PATCH v1 1/5] selftests/pidfd: Fix config for pidfd_setns_test Date: Fri, 26 Apr 2024 19:22:48 +0200 Message-ID: <20240426172252.1862930-2-mic@digikod.net> In-Reply-To: <20240426172252.1862930-1-mic@digikod.net> References: <20240426172252.1862930-1-mic@digikod.net> 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 X-Infomaniak-Routing: alpha Required by switch_timens() to open /proc/self/ns/time_for_children. CONFIG_GENERIC_VDSO_TIME_NS is not available on UML, so pidfd_setns_test cannot be run successfully on this architecture. Cc: Christian Brauner Cc: Shuah Khan Fixes: 2b40c5db73e2 ("selftests/pidfd: add pidfd setns tests") Signed-off-by: Micka=C3=ABl Sala=C3=BCn Link: https://lore.kernel.org/r/20240426172252.1862930-2-mic@digikod.net Reviewed-by: Kees Cook --- tools/testing/selftests/pidfd/config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/testing/selftests/pidfd/config b/tools/testing/selftests= /pidfd/config index f6f2965e17af..6133524710f7 100644 --- a/tools/testing/selftests/pidfd/config +++ b/tools/testing/selftests/pidfd/config @@ -3,5 +3,7 @@ CONFIG_IPC_NS=3Dy CONFIG_USER_NS=3Dy CONFIG_PID_NS=3Dy CONFIG_NET_NS=3Dy +CONFIG_TIME_NS=3Dy +CONFIG_GENERIC_VDSO_TIME_NS=3Dy CONFIG_CGROUPS=3Dy CONFIG_CHECKPOINT_RESTORE=3Dy --=20 2.44.0 From nobody Sun May 19 13:14:43 2024 Received: from smtp-190c.mail.infomaniak.ch (smtp-190c.mail.infomaniak.ch [185.125.25.12]) (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 CD40915B579 for ; Fri, 26 Apr 2024 17:23:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.25.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714152198; cv=none; b=CUx7FHcWM8L6flsXSxpMLrl+wuK4E5aOJrglNZgo55O+jAv1FeTaJotwF8updVYEhtwvBnPc2fciSbhqWvkesE/faesifn3vQPjIhAjxuJK3r1JYm9tF8KFm/ldgOjm4lfi1I2hnF8tq/1JS5yBdzzi23zFlYO5eLKkDARsqZBo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714152198; c=relaxed/simple; bh=6kRuOtJ4a93MXDCwtzvP1VdtvY2kl4/ucaoZA2ZyQwA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lc0MLLyTNe4h8NeDCFZ8MC+4ZWHPhzc9KIhEF8oDLLltZJlBFYDidZ0nUBb7MbzvStDDOYNBqhE1h+ZCBCAM4IFI+z6zQ5DYWFfXI3V4M3NaF3j3WkG5KblZhqssQbfQuNVCK7g9jGJMP3r70RieTCjNBx42yUrIRfUlHHApBS8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=b5brXSr/; arc=none smtp.client-ip=185.125.25.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="b5brXSr/" Received: from smtp-3-0001.mail.infomaniak.ch (smtp-3-0001.mail.infomaniak.ch [10.4.36.108]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4VR01625gfzVFG; Fri, 26 Apr 2024 19:23:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1714152186; bh=6kRuOtJ4a93MXDCwtzvP1VdtvY2kl4/ucaoZA2ZyQwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b5brXSr/ayXj1jxkxMnO/ban2apbqGPXZGnhyjDGWltc9xixX/hbl2lO891HwPkLS ccZSTRqsUl4IDTS8VMnIpn9sdePz/T7iJ0V2bwHMBEsfimRZLrZ492bWldGsXOa5gw k18BGvGa1prg06wt4moxAesuZk7X4nne4B3LlAbA= Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4VR0155F9lz4b8; Fri, 26 Apr 2024 19:23:05 +0200 (CEST) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: Christian Brauner , Jakub Kicinski , Kees Cook , Mark Brown , Shengyu Li , Shuah Khan Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , "David S . Miller" , =?UTF-8?q?G=C3=BCnther=20Noack?= , Will Drewry , kernel test robot , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 2/5] selftests/landlock: Fix FS tests when run on a private mount point Date: Fri, 26 Apr 2024 19:22:49 +0200 Message-ID: <20240426172252.1862930-3-mic@digikod.net> In-Reply-To: <20240426172252.1862930-1-mic@digikod.net> References: <20240426172252.1862930-1-mic@digikod.net> 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 X-Infomaniak-Routing: alpha According to the test environment, the mount point of the test's working directory may be shared or not, which changes the visibility of the nested "tmp" mount point for the test's parent process calling umount("tmp"). This was spotted while running tests on different Linux distributions, with different mount point configurations. Cc: G=C3=BCnther Noack Fixes: 41cca0542d7c ("selftests/harness: Fix TEST_F()'s vfork handling") Signed-off-by: Micka=C3=ABl Sala=C3=BCn Link: https://lore.kernel.org/r/20240426172252.1862930-3-mic@digikod.net Reviewed-by: Kees Cook --- tools/testing/selftests/landlock/fs_test.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/sel= ftests/landlock/fs_test.c index 9a6036fbf289..46b9effd53e4 100644 --- a/tools/testing/selftests/landlock/fs_test.c +++ b/tools/testing/selftests/landlock/fs_test.c @@ -293,7 +293,15 @@ static void prepare_layout(struct __test_metadata *con= st _metadata) static void cleanup_layout(struct __test_metadata *const _metadata) { set_cap(_metadata, CAP_SYS_ADMIN); - EXPECT_EQ(0, umount(TMP_DIR)); + if (umount(TMP_DIR)) { + /* + * According to the test environment, the mount point of the + * current directory may be shared or not, which changes the + * visibility of the nested TMP_DIR mount point for the test's + * parent process doing this cleanup. + */ + ASSERT_EQ(EINVAL, errno); + } clear_cap(_metadata, CAP_SYS_ADMIN); EXPECT_EQ(0, remove_path(TMP_DIR)); } --=20 2.44.0 From nobody Sun May 19 13:14:43 2024 Received: from smtp-42a9.mail.infomaniak.ch (smtp-42a9.mail.infomaniak.ch [84.16.66.169]) (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 BA22D17107F for ; Fri, 26 Apr 2024 17:23:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=84.16.66.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714152199; cv=none; b=IROvhZmn+Knx5ed6H0Gt43iFgJASpmOc+OpMGRmv1j09DlcI97VOQRPjPURIAnWHLLrZSrzqQhCb6SGfFiLHypc2GVnbJLAcsLHdcaBmVUQeS5XbvGADFz4+nXp9DlKhdxA4C6H0enzMh7qqkTdlinphBSAFb01xHtNLRoLF1xk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714152199; c=relaxed/simple; bh=gwbWMnpY1+lUZlBeZaHSY89u6ODnUz6pnZkGqVpTNCo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=e/PayhQ1jOaWIVPU9Zxl0vrQKMFMspK25RsccITXhmojlz9JKqYeCVTsWwo7n42v3sSI68L2gyy2QmqcQKuRlRcDAy2DQVQi/sXrr158xgWPKR2AuFuYcv2cP7J6J4thfPekJSF49LF9qgp9W7sLfweVPBzYeXQrgrPG8V9Zh3A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=pbmiykND; arc=none smtp.client-ip=84.16.66.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="pbmiykND" Received: from smtp-3-0000.mail.infomaniak.ch (smtp-3-0000.mail.infomaniak.ch [10.4.36.107]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4VR0172sVxz18Db; Fri, 26 Apr 2024 19:23:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1714152187; bh=gwbWMnpY1+lUZlBeZaHSY89u6ODnUz6pnZkGqVpTNCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pbmiykND1AXRM5ZnVIIoaeUJ3Y14bvSN/SpP9EDXo5SCljXDDre058h2CAigBkjzV nWHU9jZuZDz/DvGthgLXzE16Wr267NN2Nzc0uN8zynUeFZa7rcTzQHTO0AtRlfMycf niblLrY9T1avT16y4yT0PlcIy4K/aUyrlLxMnx3I= Received: from unknown by smtp-3-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4VR0166Ygpzgq1; Fri, 26 Apr 2024 19:23:06 +0200 (CEST) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: Christian Brauner , Jakub Kicinski , Kees Cook , Mark Brown , Shengyu Li , Shuah Khan Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , "David S . Miller" , =?UTF-8?q?G=C3=BCnther=20Noack?= , Will Drewry , kernel test robot , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan Subject: [PATCH v1 3/5] selftests/harness: Fix fixture teardown Date: Fri, 26 Apr 2024 19:22:50 +0200 Message-ID: <20240426172252.1862930-4-mic@digikod.net> In-Reply-To: <20240426172252.1862930-1-mic@digikod.net> References: <20240426172252.1862930-1-mic@digikod.net> 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 X-Infomaniak-Routing: alpha Make sure fixture teardowns are run when test cases failed, including when _metadata->teardown_parent is set to true. Make sure only one fixture teardown is run per test case, handling the case where the test child forks. Cc: Shuah Khan Cc: Shengyu Li Fixes: 72d7cb5c190b ("selftests/harness: Prevent infinite loop due to Asser= t in FIXTURE_TEARDOWN") Fixes: 0710a1a73fb4 ("selftests/harness: Merge TEST_F_FORK() into TEST_F()") Signed-off-by: Micka=C3=ABl Sala=C3=BCn Link: https://lore.kernel.org/r/20240426172252.1862930-4-mic@digikod.net Reviewed-by: Kees Cook --- tools/testing/selftests/kselftest_harness.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/se= lftests/kselftest_harness.h index ba3ddeda24bf..73491efbae9e 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -383,7 +383,10 @@ FIXTURE_DATA(fixture_name) self; \ pid_t child =3D 1; \ int status =3D 0; \ - bool jmp =3D false; \ + /* Makes sure there is only one teardown, even when child forks again. *= / \ + bool *teardown =3D mmap(NULL, sizeof(*teardown), \ + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); \ + *teardown =3D false; \ memset(&self, 0, sizeof(FIXTURE_DATA(fixture_name))); \ if (setjmp(_metadata->env) =3D=3D 0) { \ /* Use the same _metadata. */ \ @@ -400,15 +403,16 @@ _metadata->exit_code =3D KSFT_FAIL; \ } \ } \ - else \ - jmp =3D true; \ if (child =3D=3D 0) { \ - if (_metadata->setup_completed && !_metadata->teardown_parent && !jmp) \ + if (_metadata->setup_completed && !_metadata->teardown_parent && \ + __sync_bool_compare_and_swap(teardown, false, true)) \ fixture_name##_teardown(_metadata, &self, variant->data); \ _exit(0); \ } \ - if (_metadata->setup_completed && _metadata->teardown_parent) \ + if (_metadata->setup_completed && _metadata->teardown_parent && \ + __sync_bool_compare_and_swap(teardown, false, true)) \ fixture_name##_teardown(_metadata, &self, variant->data); \ + munmap(teardown, sizeof(*teardown)); \ if (!WIFEXITED(status) && WIFSIGNALED(status)) \ /* Forward signal to __wait_for_test(). */ \ kill(getpid(), WTERMSIG(status)); \ --=20 2.44.0 From nobody Sun May 19 13:14:43 2024 Received: from smtp-8fa8.mail.infomaniak.ch (smtp-8fa8.mail.infomaniak.ch [83.166.143.168]) (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 F29C01DDF8 for ; Fri, 26 Apr 2024 17:40:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.166.143.168 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714153248; cv=none; b=uxP954Ux7PeIUmhu/695WScww4yBGIn5cP++5pNUENfv9XoYcrSRKfss1xIhCoMRuAtemK9yPSHJ92xu07OFh6NoCz7mKiY/WbwWIaihuVrWfVFJ9POFq6rtNoPQ3XfOIpRobT86uVFzgPHZL/jv3UXvxEnUI7nnZBvZuMCtOjw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714153248; c=relaxed/simple; bh=CQBiIeVTKBpDd91iYuqIIzq3XnC8Q4yWuXaprTtqOFQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IhRLQdS2beLrgx6Mw9YGAPbrRJGWORMPy1tjIi14gDp3ErwSVpr8z8bUnIP9VoN09LKrKLfLEBPFka0z1BeRZwqronJjZWm7O1qHMzJjga1CI0X2Cev8oXwdH7r4IasmFEJMk/w1pAFAoq1Q+9/+SDYz7h/u9G46I+EaXcCawTY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=Alc/Ff+z; arc=none smtp.client-ip=83.166.143.168 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="Alc/Ff+z" Received: from smtp-3-0000.mail.infomaniak.ch (smtp-3-0000.mail.infomaniak.ch [10.4.36.107]) by smtp-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4VR0184XrKzXZt; Fri, 26 Apr 2024 19:23:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1714152188; bh=CQBiIeVTKBpDd91iYuqIIzq3XnC8Q4yWuXaprTtqOFQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Alc/Ff+zUYtVfEFUxhg2vFb0uqi/XpKcMtiYKj4YgB1ib4V5/Gn7UNS6e2YElnRB6 E6OHfBsMEwtyMjvV3Skj5ZboRIibBCXgaF7IAA6PRVLnnUbGANaSXTa18se2aVVlL1 r1F5gksDlqVRyUnqobnTpbMn9RPIu/B8E8B5BVRg= Received: from unknown by smtp-3-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4VR0180Yq0zgR1; Fri, 26 Apr 2024 19:23:08 +0200 (CEST) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: Christian Brauner , Jakub Kicinski , Kees Cook , Mark Brown , Shengyu Li , Shuah Khan Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , "David S . Miller" , =?UTF-8?q?G=C3=BCnther=20Noack?= , Will Drewry , kernel test robot , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 4/5] selftests/harness: Fix interleaved scheduling leading to race conditions Date: Fri, 26 Apr 2024 19:22:51 +0200 Message-ID: <20240426172252.1862930-5-mic@digikod.net> In-Reply-To: <20240426172252.1862930-1-mic@digikod.net> References: <20240426172252.1862930-1-mic@digikod.net> 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 X-Infomaniak-Routing: alpha Fix a race condition when running several FIXTURE_TEARDOWN() managing the same resource. This fixes a race condition in the Landlock file system tests when creating or unmounting the same directory. Using clone3() with CLONE_VFORK guarantees that the child and grandchild test processes are sequentially scheduled. This is implemented with a new clone3_vfork() helper replacing the fork() call. This avoids triggering this error in __wait_for_test(): Test ended in some other way [127] Cc: Christian Brauner Cc: David S. Miller Cc: G=C3=BCnther Noack Cc: Jakub Kicinski Cc: Kees Cook Cc: Mark Brown Cc: Shuah Khan Cc: Will Drewry Fixes: 41cca0542d7c ("selftests/harness: Fix TEST_F()'s vfork handling") Signed-off-by: Micka=C3=ABl Sala=C3=BCn Link: https://lore.kernel.org/r/20240426172252.1862930-5-mic@digikod.net --- tools/testing/selftests/kselftest_harness.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/se= lftests/kselftest_harness.h index 73491efbae9e..d2dd246a3843 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -67,6 +67,8 @@ #include #include #include +#include +#include =20 #include "kselftest.h" =20 @@ -81,6 +83,17 @@ # define TH_LOG_ENABLED 1 #endif =20 +/* Wait for the child process to end but without sharing memory mapping. */ +static pid_t __attribute__((__unused__)) clone3_vfork(void) +{ + struct clone_args args =3D { + .flags =3D CLONE_VFORK, + .exit_signal =3D SIGCHLD, + }; + + return syscall(__NR_clone3, &args, sizeof(args)); +} + /** * TH_LOG() * @@ -1180,7 +1193,7 @@ void __run_test(struct __fixture_metadata *f, fflush(stdout); fflush(stderr); =20 - t->pid =3D fork(); + t->pid =3D clone3_vfork(); if (t->pid < 0) { ksft_print_msg("ERROR SPAWNING TEST CHILD\n"); t->exit_code =3D KSFT_FAIL; --=20 2.44.0 From nobody Sun May 19 13:14:43 2024 Received: from smtp-42ad.mail.infomaniak.ch (smtp-42ad.mail.infomaniak.ch [84.16.66.173]) (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 9C3391802B7 for ; Fri, 26 Apr 2024 17:23:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=84.16.66.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714152200; cv=none; b=EiDQDN+a1ZXaNpQwJ4tnkKj20Ln3HAi9HFtrLIQ9p+5R8QcislFD+8OD2vBpof0c37BAHH69Ml2zkAiNVAfrvT5cWwitPKvfkKYl/dvkXLEnaBV5wyLPGk9ChAVfoFJ9E8hrs6lLnEliLqeS/jWT16FtFgBcXk9qdBkvz2lQkl4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714152200; c=relaxed/simple; bh=icd/9WYADaIB5bqkNPL4JaVeVI1//MJbUmKjVXrBetQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lrz4pA+tHzq1NyhA3VFKMOdu8ck4r1GLDSvVMITHY1qMBWWGi/ajk4II4ZCcpZpXclXGfeT3NFjW0bj/CH+O/3MjJos5FlanDbfp/c5U2Hhkg/liv/k4dHcxodBpHY6BW8PJjlirMlqzF3KM9wqmSJnRbf3T3UyBnOuVHYEoxF0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net; spf=pass smtp.mailfrom=digikod.net; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b=oaVWqdWw; arc=none smtp.client-ip=84.16.66.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=digikod.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=digikod.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="oaVWqdWw" Received: from smtp-3-0001.mail.infomaniak.ch (smtp-3-0001.mail.infomaniak.ch [10.4.36.108]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4VR0194xDTz5ZW; Fri, 26 Apr 2024 19:23:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1714152189; bh=icd/9WYADaIB5bqkNPL4JaVeVI1//MJbUmKjVXrBetQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oaVWqdWw6cdcdpmQ4BO8WaKuLw7me82IcOznjDscCYLaxkWck0D7WqyvG8xr3JTvT k7MWqoSJhdHIPbFn3pTVLFSka48eSI9gjf33NQhXVlAtMNPAyOiCuL3sgqkJwDg9xx 1s81aR2AY9QUxyjga6/eEl2eHzey3awWQWvf1vZo= Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4VR0191Qg0z4G8; Fri, 26 Apr 2024 19:23:09 +0200 (CEST) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: Christian Brauner , Jakub Kicinski , Kees Cook , Mark Brown , Shengyu Li , Shuah Khan Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , "David S . Miller" , =?UTF-8?q?G=C3=BCnther=20Noack?= , Will Drewry , kernel test robot , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH v1 5/5] selftests/harness: Fix vfork() side effects and uncaught errors Date: Fri, 26 Apr 2024 19:22:52 +0200 Message-ID: <20240426172252.1862930-6-mic@digikod.net> In-Reply-To: <20240426172252.1862930-1-mic@digikod.net> References: <20240426172252.1862930-1-mic@digikod.net> 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 X-Infomaniak-Routing: alpha Setting the time namespace with CLONE_NEWTIME returns -EUSERS if the calling thread shares memory with another thread (because of the shared vDSO), which is the case when it is created with vfork(). Fix pidfd_setns_test by replacing test harness's vfork() call with a clone3() call with CLONE_VFORK, and an explicit sharing of the __test_metadata and self objects. Replace _metadata->teardown_parent with a new FIXTURE_TEARDOWN_PARENT() helper that can replace FIXTURE_TEARDOWN(). This is a cleaner approach and it enables to selectively share the fixture data between the child process running tests and the parent process running the fixture teardown. This also avoids updating several tests to not rely on the self object's copy-on-write property (e.g. storing the returned value of a fork() call). In the Landlock filesystem tests, don't allocate self->dir_path in the test process because this would not be visible in the FIXTURE_TEARDOWN_PARENT() process when not sharing the memory mapping. Unconditionally share _metadata between all forked processes, which enables to actually catch errors (which were previously ignored). Replace a wrong EXPECT_GT(self->child_pid_exited, 0) with EXPECT_GE(), which is now actually tested on the parent and child sides. FIXTURE_VARIANT_ADD() doesn't need to be MAP_SHARED because it should not be modified: it is already passed as const pointers to FIXTURE_TEARDOWN(). Make that explicit by constifying the variants declarations. Cc: Christian Brauner Cc: David S. Miller Cc: G=C3=BCnther Noack Cc: Jakub Kicinski Cc: Kees Cook Cc: Mark Brown Cc: Shuah Khan Cc: Will Drewry Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202403291015.1fcfa957-oliver.sang@in= tel.com Fixes: 0710a1a73fb4 ("selftests/harness: Merge TEST_F_FORK() into TEST_F()") Signed-off-by: Micka=C3=ABl Sala=C3=BCn Link: https://lore.kernel.org/r/20240426172252.1862930-6-mic@digikod.net --- tools/testing/selftests/kselftest_harness.h | 88 +++++++++++++------ tools/testing/selftests/landlock/fs_test.c | 73 ++++++++------- .../selftests/pidfd/pidfd_setns_test.c | 2 +- 3 files changed, 103 insertions(+), 60 deletions(-) diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/se= lftests/kselftest_harness.h index d2dd246a3843..a19d01c0b7a7 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -295,6 +295,32 @@ static pid_t __attribute__((__unused__)) clone3_vfork(= void) * A bare "return;" statement may be used to return early. */ #define FIXTURE_TEARDOWN(fixture_name) \ + static const bool fixture_name##_teardown_parent =3D false; \ + __FIXTURE_TEARDOWN(fixture_name) + +/** + * FIXTURE_TEARDOWN_PARENT() + * *_metadata* is included so that EXPECT_*, ASSERT_* etc. work correctly. + * + * @fixture_name: fixture name + * + * .. code-block:: c + * + * FIXTURE_TEARDOWN_PARENT(fixture_name) { implementation } + * + * Same as FIXTURE_TEARDOWN() but run this code in a parent process. This + * enables the test process to drop its privileges without impacting the + * related FIXTURE_TEARDOWN_PARENT() (e.g. to remove files from a directory + * where write access was dropped). + * + * To make it possible for the parent process to use *self*, share (MAP_SH= ARED) + * the fixture data between all forked processes. + */ +#define FIXTURE_TEARDOWN_PARENT(fixture_name) \ + static const bool fixture_name##_teardown_parent =3D true; \ + __FIXTURE_TEARDOWN(fixture_name) + +#define __FIXTURE_TEARDOWN(fixture_name) \ void fixture_name##_teardown( \ struct __test_metadata __attribute__((unused)) *_metadata, \ FIXTURE_DATA(fixture_name) __attribute__((unused)) *self, \ @@ -339,7 +365,7 @@ static pid_t __attribute__((__unused__)) clone3_vfork(v= oid) * variant. */ #define FIXTURE_VARIANT_ADD(fixture_name, variant_name) \ - extern FIXTURE_VARIANT(fixture_name) \ + extern const FIXTURE_VARIANT(fixture_name) \ _##fixture_name##_##variant_name##_variant; \ static struct __fixture_variant_metadata \ _##fixture_name##_##variant_name##_object =3D \ @@ -351,7 +377,7 @@ static pid_t __attribute__((__unused__)) clone3_vfork(v= oid) __register_fixture_variant(&_##fixture_name##_fixture_object, \ &_##fixture_name##_##variant_name##_object); \ } \ - FIXTURE_VARIANT(fixture_name) \ + const FIXTURE_VARIANT(fixture_name) \ _##fixture_name##_##variant_name##_variant =3D =20 /** @@ -369,10 +395,11 @@ static pid_t __attribute__((__unused__)) clone3_vfork= (void) * Very similar to TEST() except that *self* is the setup instance of fixt= ure's * datatype exposed for use by the implementation. * - * The @test_name code is run in a separate process sharing the same memory - * (i.e. vfork), which means that the test process can update its privileg= es - * without impacting the related FIXTURE_TEARDOWN() (e.g. to remove files = from - * a directory where write access was dropped). + * The __test_metadata object is shared (MAP_SHARED) with all the potential + * forked processes, which enables them to use EXCEPT_*() and ASSERT_*(). + * + * The *self* object is only shared with the potential forked processes if + * FIXTURE_TEARDOWN_PARENT() is used instead of FIXTURE_TEARDOWN(). */ #define TEST_F(fixture_name, test_name) \ __TEST_F_IMPL(fixture_name, test_name, -1, TEST_TIMEOUT_DEFAULT) @@ -393,57 +420,65 @@ static pid_t __attribute__((__unused__)) clone3_vfork= (void) struct __fixture_variant_metadata *variant) \ { \ /* fixture data is alloced, setup, and torn down per call. */ \ - FIXTURE_DATA(fixture_name) self; \ + FIXTURE_DATA(fixture_name) self_private, *self =3D NULL; \ pid_t child =3D 1; \ int status =3D 0; \ /* Makes sure there is only one teardown, even when child forks again. *= / \ bool *teardown =3D mmap(NULL, sizeof(*teardown), \ PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); \ *teardown =3D false; \ - memset(&self, 0, sizeof(FIXTURE_DATA(fixture_name))); \ + if (sizeof(*self) > 0) { \ + if (fixture_name##_teardown_parent) { \ + self =3D mmap(NULL, sizeof(*self), PROT_READ | PROT_WRITE, \ + MAP_SHARED | MAP_ANONYMOUS, -1, 0); \ + } else { \ + memset(&self_private, 0, sizeof(self_private)); \ + self =3D &self_private; \ + } \ + } \ if (setjmp(_metadata->env) =3D=3D 0) { \ - /* Use the same _metadata. */ \ - child =3D vfork(); \ + /* _metadata and potentially self are shared with all forks. */ \ + child =3D clone3_vfork(); \ if (child =3D=3D 0) { \ - fixture_name##_setup(_metadata, &self, variant->data); \ + fixture_name##_setup(_metadata, self, variant->data); \ /* Let setup failure terminate early. */ \ if (_metadata->exit_code) \ _exit(0); \ _metadata->setup_completed =3D true; \ - fixture_name##_##test_name(_metadata, &self, variant->data); \ + fixture_name##_##test_name(_metadata, self, variant->data); \ } else if (child < 0 || child !=3D waitpid(child, &status, 0)) { \ ksft_print_msg("ERROR SPAWNING TEST GRANDCHILD\n"); \ _metadata->exit_code =3D KSFT_FAIL; \ } \ } \ if (child =3D=3D 0) { \ - if (_metadata->setup_completed && !_metadata->teardown_parent && \ + if (_metadata->setup_completed && !fixture_name##_teardown_parent && \ __sync_bool_compare_and_swap(teardown, false, true)) \ - fixture_name##_teardown(_metadata, &self, variant->data); \ + fixture_name##_teardown(_metadata, self, variant->data); \ _exit(0); \ } \ - if (_metadata->setup_completed && _metadata->teardown_parent && \ + if (_metadata->setup_completed && fixture_name##_teardown_parent && \ __sync_bool_compare_and_swap(teardown, false, true)) \ - fixture_name##_teardown(_metadata, &self, variant->data); \ + fixture_name##_teardown(_metadata, self, variant->data); \ munmap(teardown, sizeof(*teardown)); \ + if (self && fixture_name##_teardown_parent) \ + munmap(self, sizeof(*self)); \ if (!WIFEXITED(status) && WIFSIGNALED(status)) \ /* Forward signal to __wait_for_test(). */ \ kill(getpid(), WTERMSIG(status)); \ __test_check_assert(_metadata); \ } \ - static struct __test_metadata \ - _##fixture_name##_##test_name##_object =3D { \ - .name =3D #test_name, \ - .fn =3D &wrapper_##fixture_name##_##test_name, \ - .fixture =3D &_##fixture_name##_fixture_object, \ - .termsig =3D signal, \ - .timeout =3D tmout, \ - .teardown_parent =3D false, \ - }; \ static void __attribute__((constructor)) \ _register_##fixture_name##_##test_name(void) \ { \ - __register_test(&_##fixture_name##_##test_name##_object); \ + struct __test_metadata *object =3D mmap(NULL, sizeof(*object), \ + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); \ + object->name =3D #test_name; \ + object->fn =3D &wrapper_##fixture_name##_##test_name; \ + object->fixture =3D &_##fixture_name##_fixture_object; \ + object->termsig =3D signal; \ + object->timeout =3D tmout; \ + __register_test(object); \ } \ static void fixture_name##_##test_name( \ struct __test_metadata __attribute__((unused)) *_metadata, \ @@ -898,7 +933,6 @@ struct __test_metadata { bool timed_out; /* did this test timeout instead of exiting? */ bool aborted; /* stopped test due to failed ASSERT */ bool setup_completed; /* did setup finish? */ - bool teardown_parent; /* run teardown in a parent process */ jmp_buf env; /* for exiting out of test early */ struct __test_results *results; struct __test_metadata *prev, *next; diff --git a/tools/testing/selftests/landlock/fs_test.c b/tools/testing/sel= ftests/landlock/fs_test.c index 46b9effd53e4..27744524df51 100644 --- a/tools/testing/selftests/landlock/fs_test.c +++ b/tools/testing/selftests/landlock/fs_test.c @@ -9,6 +9,7 @@ =20 #define _GNU_SOURCE #include +#include #include #include #include @@ -285,8 +286,6 @@ static void prepare_layout_opt(struct __test_metadata *= const _metadata, =20 static void prepare_layout(struct __test_metadata *const _metadata) { - _metadata->teardown_parent =3D true; - prepare_layout_opt(_metadata, &mnt_tmp); } =20 @@ -315,7 +314,7 @@ FIXTURE_SETUP(layout0) prepare_layout(_metadata); } =20 -FIXTURE_TEARDOWN(layout0) +FIXTURE_TEARDOWN_PARENT(layout0) { cleanup_layout(_metadata); } @@ -378,7 +377,7 @@ FIXTURE_SETUP(layout1) create_layout1(_metadata); } =20 -FIXTURE_TEARDOWN(layout1) +FIXTURE_TEARDOWN_PARENT(layout1) { remove_layout1(_metadata); =20 @@ -3691,7 +3690,7 @@ FIXTURE_SETUP(ftruncate) create_file(_metadata, file1_s1d1); } =20 -FIXTURE_TEARDOWN(ftruncate) +FIXTURE_TEARDOWN_PARENT(ftruncate) { EXPECT_EQ(0, remove_path(file1_s1d1)); cleanup_layout(_metadata); @@ -3869,7 +3868,7 @@ FIXTURE_SETUP(layout1_bind) clear_cap(_metadata, CAP_SYS_ADMIN); } =20 -FIXTURE_TEARDOWN(layout1_bind) +FIXTURE_TEARDOWN_PARENT(layout1_bind) { /* umount(dir_s2d2)) is handled by namespace lifetime. */ =20 @@ -4274,7 +4273,7 @@ FIXTURE_SETUP(layout2_overlay) clear_cap(_metadata, CAP_SYS_ADMIN); } =20 -FIXTURE_TEARDOWN(layout2_overlay) +FIXTURE_TEARDOWN_PARENT(layout2_overlay) { if (self->skip_test) SKIP(return, "overlayfs is not supported (teardown)"); @@ -4624,7 +4623,6 @@ FIXTURE(layout3_fs) { bool has_created_dir; bool has_created_file; - char *dir_path; bool skip_test; }; =20 @@ -4683,11 +4681,24 @@ FIXTURE_VARIANT_ADD(layout3_fs, hostfs) { .cwd_fs_magic =3D HOSTFS_SUPER_MAGIC, }; =20 +static char *dirname_alloc(const char *path) +{ + char *dup; + + if (!path) + return NULL; + + dup =3D strdup(path); + if (!dup) + return NULL; + + return dirname(dup); +} + FIXTURE_SETUP(layout3_fs) { struct stat statbuf; - const char *slash; - size_t dir_len; + char *dir_path =3D dirname_alloc(variant->file_path); =20 if (!supports_filesystem(variant->mnt.type) || !cwd_matches_fs(variant->cwd_fs_magic)) { @@ -4695,27 +4706,15 @@ FIXTURE_SETUP(layout3_fs) SKIP(return, "this filesystem is not supported (setup)"); } =20 - _metadata->teardown_parent =3D true; - - slash =3D strrchr(variant->file_path, '/'); - ASSERT_NE(slash, NULL); - dir_len =3D (size_t)slash - (size_t)variant->file_path; - ASSERT_LT(0, dir_len); - self->dir_path =3D malloc(dir_len + 1); - self->dir_path[dir_len] =3D '\0'; - strncpy(self->dir_path, variant->file_path, dir_len); - prepare_layout_opt(_metadata, &variant->mnt); =20 /* Creates directory when required. */ - if (stat(self->dir_path, &statbuf)) { + if (stat(dir_path, &statbuf)) { set_cap(_metadata, CAP_DAC_OVERRIDE); - EXPECT_EQ(0, mkdir(self->dir_path, 0700)) + EXPECT_EQ(0, mkdir(dir_path, 0700)) { TH_LOG("Failed to create directory \"%s\": %s", - self->dir_path, strerror(errno)); - free(self->dir_path); - self->dir_path =3D NULL; + dir_path, strerror(errno)); } self->has_created_dir =3D true; clear_cap(_metadata, CAP_DAC_OVERRIDE); @@ -4736,9 +4735,11 @@ FIXTURE_SETUP(layout3_fs) self->has_created_file =3D true; clear_cap(_metadata, CAP_DAC_OVERRIDE); } + + free(dir_path); } =20 -FIXTURE_TEARDOWN(layout3_fs) +FIXTURE_TEARDOWN_PARENT(layout3_fs) { if (self->skip_test) SKIP(return, "this filesystem is not supported (teardown)"); @@ -4754,16 +4755,17 @@ FIXTURE_TEARDOWN(layout3_fs) } =20 if (self->has_created_dir) { + char *dir_path =3D dirname_alloc(variant->file_path); + set_cap(_metadata, CAP_DAC_OVERRIDE); /* * Don't check for error because the directory might already * have been removed (cf. release_inode test). */ - rmdir(self->dir_path); + rmdir(dir_path); clear_cap(_metadata, CAP_DAC_OVERRIDE); + free(dir_path); } - free(self->dir_path); - self->dir_path =3D NULL; =20 cleanup_layout(_metadata); } @@ -4830,7 +4832,10 @@ TEST_F_FORK(layout3_fs, tag_inode_dir_mnt) =20 TEST_F_FORK(layout3_fs, tag_inode_dir_child) { - layer3_fs_tag_inode(_metadata, self, variant, self->dir_path); + char *dir_path =3D dirname_alloc(variant->file_path); + + layer3_fs_tag_inode(_metadata, self, variant, dir_path); + free(dir_path); } =20 TEST_F_FORK(layout3_fs, tag_inode_file) @@ -4857,9 +4862,13 @@ TEST_F_FORK(layout3_fs, release_inodes) if (self->has_created_file) EXPECT_EQ(0, remove_path(variant->file_path)); =20 - if (self->has_created_dir) + if (self->has_created_dir) { + char *dir_path =3D dirname_alloc(variant->file_path); + /* Don't check for error because of cgroup specificities. */ - remove_path(self->dir_path); + remove_path(dir_path); + free(dir_path); + } =20 ruleset_fd =3D create_ruleset(_metadata, LANDLOCK_ACCESS_FS_READ_DIR, layer1); diff --git a/tools/testing/selftests/pidfd/pidfd_setns_test.c b/tools/testi= ng/selftests/pidfd/pidfd_setns_test.c index 6e2f2cd400ca..47746b0c6acd 100644 --- a/tools/testing/selftests/pidfd/pidfd_setns_test.c +++ b/tools/testing/selftests/pidfd/pidfd_setns_test.c @@ -158,7 +158,7 @@ FIXTURE_SETUP(current_nsset) /* Create task that exits right away. */ self->child_pid_exited =3D create_child(&self->child_pidfd_exited, CLONE_NEWUSER | CLONE_NEWNET); - EXPECT_GT(self->child_pid_exited, 0); + EXPECT_GE(self->child_pid_exited, 0); =20 if (self->child_pid_exited =3D=3D 0) _exit(EXIT_SUCCESS); --=20 2.44.0