Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1532991rbb; Mon, 26 Feb 2024 12:21:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVXAdmK3LDCaSTLUEj3jvMj82JqeJ12/kR41BqfGDUo8IvWgRuRibHg1ZtMJK5e0Z1Gyc1LJRuHEkngmeapRSfNnuq4HU6QesBYUOhQmA== X-Google-Smtp-Source: AGHT+IG99iuK4v+ChxAArqiwPcffsFDen48bmVYSCTu378bro35H9yG7fLbBg9pudBK3Ib5jBeMQ X-Received: by 2002:a17:906:a1d3:b0:a3f:5104:dabb with SMTP id bx19-20020a170906a1d300b00a3f5104dabbmr5110660ejb.63.1708978901551; Mon, 26 Feb 2024 12:21:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708978901; cv=pass; d=google.com; s=arc-20160816; b=OGHwJcnSm4qV+2+OTolbI7Huesgre2MJ5zZ7EHBOqsrR8LQ1clX8Kx+YNqfl615YZy utIH53oVZ6TiZthGPUFdHt/D1z/wB8Fx8ScImwFXPikDX1kJbjKhVhACY2dp9n+/3/qM zZNbuAydtzBkU/TjNYWQ034uaELi39232FCriZxYmiGLyLSZkRFagzos47rgF68Y0JHy ER6BvMqTloe1M/ZKGxFPKQUp7u1lfifeG3HRoMEMSQEVRPo5Wppt8UPaAJYL47w5K7OU V7RJ3rUlgcexlWJdrTkSVW8csmMG7hUmJyjvQH7hEuDcAHcpck1RZqyInSYCzEyBumMb mGww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=NgUxoG4sSEfPKqBaU4NOeS6JENT2MKGvrEfoQSokH6Y=; fh=tutCcnKXmdZ1ARVt1jKdyR9ScCoNhKXcuRrPr8aIRYY=; b=N/VENWFki/kKLZOaLWfXg37m7N5XlQtUaLVa62fXJ9DSa1nvY7wvo37HI7Gjxr0qYZ +CyMG4156MSnAMLHcTkklXU7VG1l+5s1VJHSBmhSncxOoPgDfHY4w4jx0ES8+wiAlCXT 3k4G8uuWmpFqHK8//HhFxjgsSTjobX6/O6hNWLfdjxPXxFGgzcv+jXPPirByPYnRWbg6 qIQhQcI0z6yc9+8poTt3Xklu/igL42ZkSOFNmqkvF2ZPxs3P6HJ1c7F7C9XukLvOTsnx qbecoIcgrnADhKOZaZIBZU6aNf/PcFGUGfBMT9ByI3CXUfZWAlFqFFN7dIy9teW+mvLR FBqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=KJUhhXGf; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-82288-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82288-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id i11-20020a1709064ecb00b00a3e788d25f5si71415ejv.188.2024.02.26.12.21.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 12:21:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82288-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=KJUhhXGf; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-82288-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82288-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BE3771F21AF3 for ; Mon, 26 Feb 2024 20:21:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E36C9130E2A; Mon, 26 Feb 2024 20:21:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="KJUhhXGf" 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 8057E12FF69 for ; Mon, 26 Feb 2024 20:21:24 +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=1708978888; cv=none; b=R/FZOc19vWdYkN3tPY2ZVf6r2ncNivKTcQFE2GO8srSQQXd34h2EHSnkpHzfCP36zXOCkQOGAWdgPIRis0zGog8/0eLMhkXI2wsb50KWAspRunmzCAKIb1JWgiCq3YP24zcbsz0tjI58JCpDSneaW9wH8L2gH3Taokd2XfhxjSM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708978888; c=relaxed/simple; bh=V+U8mYk2PqPb7oIAg3nmSJcwO6wdq7wethQJpUrnYu8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OXw3hHynhYZlUz4yXWFnSVokvOKpi39xHHaue4no4bVBSAB0zqfMeMIHp5HHFezeFYiHyi/Z5GskBd8/f14TXwlz/MFRXvMonaeAg4Ab9hil5EaGomaM+7XQ4gGC7qGOv1YZA9cn+oRDab79Z/v+FCFq7e0DDfpc1zbD5erYSaY= 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=KJUhhXGf; 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 Received: from smtp-4-0001.mail.infomaniak.ch (smtp-4-0001.mail.infomaniak.ch [10.7.10.108]) by smtp-4-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4TkBpN1hWzz1BN; Mon, 26 Feb 2024 21:21:16 +0100 (CET) Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4TkBpM2YKfzNmm; Mon, 26 Feb 2024 21:21:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1708978876; bh=V+U8mYk2PqPb7oIAg3nmSJcwO6wdq7wethQJpUrnYu8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=KJUhhXGffQjx/Gy/vSu3BvRt5p6/m8qt0oVPUu0MiyipgKJ0hAYnuWpdQEYzPRq8z cz+Ds0eGefPzBwWXJyxxXfR+RvvLwgUbsLCKZtgDF8xd23cUIkqM/e3CtssPnYFbLs RORbAwEpx2+UG/bVEZIZStVfNGkJkOLwb1hZIzok= Date: Mon, 26 Feb 2024 21:21:06 +0100 From: =?utf-8?Q?Micka=C3=ABl_Sala=C3=BCn?= To: Kees Cook Cc: Jakub Kicinski , Shuah Khan , davem@davemloft.net, =?utf-8?Q?G=C3=BCnther?= Noack , Will Drewry , edumazet@google.com, jakub@cloudflare.com, pabeni@redhat.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-security-module@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH 2/2] selftests/harness: Merge TEST_F_FORK() into TEST_F() Message-ID: <20240226.NooJ5ahBip8A@digikod.net> References: <20240223160259.22c61d1e@kernel.org> <20240226162335.3532920-1-mic@digikod.net> <20240226162335.3532920-3-mic@digikod.net> <202402261102.3BE03F08DF@keescook> 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202402261102.3BE03F08DF@keescook> X-Infomaniak-Routing: alpha On Mon, Feb 26, 2024 at 11:04:12AM -0800, Kees Cook wrote: > On Mon, Feb 26, 2024 at 05:23:35PM +0100, Mickaël Salaün wrote: > > Remplace Landlock-specific TEST_F_FORK() with an improved TEST_F() which > > brings four related changes: > > > > Run TEST_F()'s tests in a grandchild process to make it possible to > > drop privileges and delegate teardown to the parent. > > > > Compared to TEST_F_FORK(), simplify handling of the test grandchild > > process thanks to vfork(2), and makes it generic (e.g. no explicit > > conversion between exit code and _metadata). > > > > Compared to TEST_F_FORK(), run teardown even when tests failed with an > > assert thanks to commit 63e6b2a42342 ("selftests/harness: Run TEARDOWN > > for ASSERT failures"). > > > > Simplify the test harness code by removing the no_print and step fields > > which are not used. I added this feature just after I made > > kselftest_harness.h more broadly available but this step counter > > remained even though it wasn't needed after all. See commit 369130b63178 > > ("selftests: Enhance kselftest_harness.h to print which assert failed"). > > I'm personally fine dropping the step counter. (I do wonder if that > removal should be split from the grandchild launching.) I thought about that but it was not worth it to add more lines to review. > > > Replace spaces with tabs in one line of __TEST_F_IMPL(). > > > > Cc: Günther Noack > > Cc: Jakub Kicinski > > Cc: Kees Cook > > Cc: Shuah Khan > > Cc: Will Drewry > > Signed-off-by: Mickaël Salaün > > One typo below, but otherwise seems good to me: > > Reviewed-by: Kees Cook > > > > [...] > > _metadata->setup_completed = true; \ > > - fixture_name##_##test_name(_metadata, &self, variant->data); \ > > + /* Use the same _metadata. */ \ > > + child = vfork(); \ > > + if (child == 0) { \ > > + fixture_name##_##test_name(_metadata, &self, variant->data); \ > > + _exit(0); \ > > + } \ > > + if (child < 0) { \ > > + ksft_print_msg("ERROR SPAWNING TEST GANDCHILD\n"); \ > > typo: GAND -> GRAND Good catch! Jakub, please fix this with the next combined+rebased series. Thanks! > > -- > Kees Cook >