Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1696754lqm; Fri, 3 May 2024 04:01:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+ZnyfKjjSJMs11ribpZ5Lip+PHc7NewJEWYg9hvRAT32TmI+35/FziinvT6jZuoBW0kocLUww2vlcULkJ7oI1Y75M3U+XWN4QxQEz7g== X-Google-Smtp-Source: AGHT+IGvM3UoLg2VHxydbdSkVLGESsuyFuqRYtnI/LYeOaHG5KpSP7uTLoAqaeX3azkAOYRLx276 X-Received: by 2002:a17:90a:c284:b0:2b1:8210:56bb with SMTP id f4-20020a17090ac28400b002b1821056bbmr2223812pjt.3.1714734110164; Fri, 03 May 2024 04:01:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714734110; cv=pass; d=google.com; s=arc-20160816; b=HHISM9hitvcSO+OCD59sc+nwXdXpQaB/Ir9JtOfhv9I+HogGOwqUD3Pz+fYs5nHD1F xQ6EDavYfrSokCFhtGWFemk6qV9y7KNXzGbaWLGL4mxImZ91Fg3bJeJy1nbXPxU9nF+p iZm7R2+8ruDMLkpypbor92yoiY26ijny5jLp7TidOK285yuehHDFnTcwtO8WU0AydHYN kqnw/FbG3fgNwJ8yBp7lhRaEtniIa6FIn78aunvJX/fQV5Cs4cT8YdNa6s2lKByXDjqQ Cte11a5pZ6ltGuchdOVRtl6Hnfha9kleCf4ONqcCkbnDGC1z8WYZnGQqShIsMy5m65Ol Ps6w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=9LTNsm/Z6yHuxN4q3ArWkwsy545kEdXd2S1a4V+A2Uw=; fh=pFOGWyS68KwrsEZD3Ll2e7y6RwSNe0VchkTs/n9iysY=; b=R1IK5uCXjmul8FJ5I5s4PdhH3o4NxGZo0T/UDpfr75mdlEcjOASdkJAr0l/eYNT6lK TpEgO0xh4jvmFeti8rbnlHlzrvFDCtrEC5HpwNhsoxZeNs3vdYIIzFj9zYB/j+N/ZjMV XE2msxzlapPNIo+6WJfMQdiB+Wgrk5b6YIx1odbXiqF8gBDrkSaa9Hj9FA+P0VG4EHq/ v4F9G1fGjyQoLo2sqVZ3Kf+A25b1Clo4tXrzBzgUTfAoM+kfjizcj/gbDQczmB9Z5G+W V+he3obyAa7e2VV1LYDCoC+go2cG4OIZnWq3WXLzyZNrOMBx5dr9++M3NIrMbYyMhUl+ OBdg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=RfmW2Yhl; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-167554-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167554-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id cp17-20020a17090afb9100b002b2880464efsi5158431pjb.107.2024.05.03.04.01.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 04:01:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-167554-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=RfmW2Yhl; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-167554-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-167554-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id A0486B20B73 for ; Fri, 3 May 2024 11:01:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EF2615533D; Fri, 3 May 2024 10:58:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="RfmW2Yhl" Received: from smtp-42ac.mail.infomaniak.ch (smtp-42ac.mail.infomaniak.ch [84.16.66.172]) (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 7C305153839 for ; Fri, 3 May 2024 10:58:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=84.16.66.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714733925; cv=none; b=u0FRu5xvCnuZg3yP0hagkDiKju+4xkvm7DB/qxAQHE6aOvX5Ej1bMWCZYTsMH5NfDJ0dWKyKNqmZVIHkjxU43Un1DJhaKGhC/DsanszzGDS4WXA5gVrXEOgutdsswiHKGuNXOdqAD1CG7fq0+k1AbJIiFxPV2m40NR2TVgQ5qvg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714733925; c=relaxed/simple; bh=2Y0nOVcRkIUq7/FBVt+wFbHUgDdz1Cx5Myja8BL91y4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=upGsZfkcTnEDDEwthVl/ZK/IwvUcVWnB3yueqUoDLgRFWOnJNfpV5JEP0l9M2457ze/3+U/GsorWkebn8p17S4Z7kg/+vPQtYw+AhOpUh3UTImAyhH7rHZzSam3KVerGIcZpQ4aRUTd7AY0rgIb3bqmyUNBBLs5mi5haU/StX0A= 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=RfmW2Yhl; arc=none smtp.client-ip=84.16.66.172 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-3-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4VW78H4xfMzNjH; Fri, 3 May 2024 12:58:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1714733919; bh=2Y0nOVcRkIUq7/FBVt+wFbHUgDdz1Cx5Myja8BL91y4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RfmW2YhlSvEvMhJ1eDX70f4rrmeBcgAdpNHcyq1KkAX4TpL7R0dTCy8vKfAw1nf2T 5RxGRCqOePu6j8kPEUc7KkiKnw6jjHSTXyIft9MaZM/ayY6Wdkjzs2zbt2WgDXFeiu 9XRKeMapi1lsAOmDHn1nVfnFGp4tee+jlmWl4+oU= Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4VW78H1XrYzcTF; Fri, 3 May 2024 12:58:39 +0200 (CEST) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: Christian Brauner , Jakub Kicinski , Kees Cook , Mark Brown , Sean Christopherson , 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 , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Shuah Khan Subject: [PATCH v5 08/10] selftests/harness: Share _metadata between forked processes Date: Fri, 3 May 2024 12:58:18 +0200 Message-ID: <20240503105820.300927-9-mic@digikod.net> In-Reply-To: <20240503105820.300927-1-mic@digikod.net> References: <20240503105820.300927-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: 8bit X-Infomaniak-Routing: alpha Unconditionally share _metadata between all forked processes, which enables to actually catch errors which were previously ignored. This is required for a following commit replacing vfork() with clone3() and CLONE_VFORK (i.e. not sharing the full memory) . It should also be useful to share _metadata to extend expectations to test process's forks. For instance, this change identified a wrong expectation in pidfd_setns_test. Cc: Jakub Kicinski Cc: Shuah Khan Cc: Will Drewry Reviewed-by: Kees Cook Signed-off-by: Mickaël Salaün Link: https://lore.kernel.org/r/20240503105820.300927-9-mic@digikod.net --- Changes since v4: * Reset _metadata's aborted and setup_completed fields. Changes since v1: * Extract change from a bigger patch (suggested by Kees). --- tools/testing/selftests/kselftest_harness.h | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h index 201040207c85..ea78bec5856f 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -430,19 +430,17 @@ static inline pid_t clone3_vfork(void) kill(getpid(), WTERMSIG(status)); \ __test_check_assert(_metadata); \ } \ - static struct __test_metadata \ - _##fixture_name##_##test_name##_object = { \ - .name = #test_name, \ - .fn = &wrapper_##fixture_name##_##test_name, \ - .fixture = &_##fixture_name##_fixture_object, \ - .termsig = signal, \ - .timeout = tmout, \ - .teardown_parent = false, \ - }; \ static void __attribute__((constructor)) \ _register_##fixture_name##_##test_name(void) \ { \ - __register_test(&_##fixture_name##_##test_name##_object); \ + struct __test_metadata *object = mmap(NULL, sizeof(*object), \ + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, -1, 0); \ + object->name = #test_name; \ + object->fn = &wrapper_##fixture_name##_##test_name; \ + object->fixture = &_##fixture_name##_fixture_object; \ + object->termsig = signal; \ + object->timeout = tmout; \ + __register_test(object); \ } \ static void fixture_name##_##test_name( \ struct __test_metadata __attribute__((unused)) *_metadata, \ @@ -1181,6 +1179,9 @@ void __run_test(struct __fixture_metadata *f, /* reset test struct */ t->exit_code = KSFT_PASS; t->trigger = 0; + t->aborted = false; + t->setup_completed = false; + memset(t->env, 0, sizeof(t->env)); memset(t->results->reason, 0, sizeof(t->results->reason)); if (asprintf(&test_name, "%s%s%s.%s", f->name, -- 2.45.0