Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp20319lqh; Mon, 6 May 2024 09:58:46 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWN/ajBHYbcDGDfFkysX8KY1JybC6dtjouQR9QE8kyvsmGF73M0AYRcOiYz1jzA/OzlC2rL7V1K7sdhg2yBgivefcq59FAM4B8SnPhq7Q== X-Google-Smtp-Source: AGHT+IE8/nluLNEOPKikWzGJTAayy68qqGXmCkp+L/Sncz+jVEEFwmrxGozL0n5QSu6565HY9UNh X-Received: by 2002:a17:907:3f07:b0:a59:c9ad:bd28 with SMTP id hq7-20020a1709073f0700b00a59c9adbd28mr2847280ejc.13.1715014725918; Mon, 06 May 2024 09:58:45 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715014725; cv=pass; d=google.com; s=arc-20160816; b=sSYADA9S+Bz33ZRQeQTQDy/2+xZAO1t1rKxRZmgxDyuLzpqmO+XHzqxb64pQ3aevEt ME0owxzu4PEbBGDxwepazDIIQTjf1oSVF1Q8R1BvLcfV6Hu1kkCqaVFJ9c3AnnKOYChs IlsRiErhUwGGMZUz2WzWT8HkrFXjQmnQptfXKZJLlJh0Mmtn7Q/ecLoQc24R+IQ81BZ7 Ath+steyVwQ3APYHU0vz4WlNy5fYkoR1B+Pl4SMHuP5hO30D1ahLl43rDGuqh0PCD4Qp 1pgCjNDtglCsXiM439DccJk8droJqtPBvQCDU0qMH6IJREdC+66JvxbQMBbudcUr8w33 YNMw== 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=0UxJ5Vh1BU1y/JZwS8vLpc/Zya2TJdFWwml55yGiJsg=; fh=h2xHIZSGiUwuZyladnT9pE6uX086qy42ByZk41PjzSs=; b=ugmV1J6B0zUecTl8QRwgGTxoF2LGzvYT3lR8rtWBroKRhJoqmQ473tEcsl6156J2Ru yfjRtzTh/1C/QHA+VbZHbGfg++udZ+2NGr36VOfyr3jGLbEQx5yLT7wHWbFa5/D2iO3K Dw0NdRfJ54x+3d7DDBCSTz+kPOoCDfq/t2Zs8emti+T4cM5SexO/DKckOP0m0pt2ezed t8DA0Ibp8NrNM4F8yyhQ8Yo6U3KAw0xV44SC7Sp7HMH1Y8+nh0eFC9nSAI9nWodczlA+ WWkfvXf/041nfFcjhWLpbTHxIkbWFqEiC5d7XwReXNY+FvGyHV47kks4AMksP1qtm4eX X4pw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=GgZMq+yo; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-170205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170205-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 s20-20020a170906bc5400b00a59a1398137si3460025ejv.312.2024.05.06.09.58.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 09:58:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170205-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=GgZMq+yo; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-170205-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170205-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 A4E6D1F2177D for ; Mon, 6 May 2024 16:58:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40BC815AAC0; Mon, 6 May 2024 16:55:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="GgZMq+yo" Received: from smtp-190b.mail.infomaniak.ch (smtp-190b.mail.infomaniak.ch [185.125.25.11]) (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 BC5D5159904 for ; Mon, 6 May 2024 16:55:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.25.11 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715014543; cv=none; b=s2E7QLJkrL8Y0lmpDbwUrb+OwgR/W85nBdFTYHYLuaiZxWKtD5ZQzPW9IX4B1bQF0Lky+ynuNZo9aFZSdRz5ZadoJXySjHwn95mxTD22h6YsuPxuxn6zBk7FiIjPsskY0CKw1AHZb4xOkPhVwRMnHPR13hvd/JQke48Ujj7Uj5s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715014543; c=relaxed/simple; bh=bX9I1ibW0C+6EYQnikkxNXNDSRcbJnaxyC+EsmTnLbM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tzgROtlHteCpOskw6iQ+nfzik7lTF1Hv46YzYrgosjUfauP3kJBCf9UuIYtzjfHYrk1zrS3Fn2p9VQoWO7c2emuL9X0Qbkwmo3DNSkSAllvG0/KhcyRmZxYTAcJS13c9LfxyZbLKTV5EPyrAFnIOo+XzALO60NJ7K3KXsB9jCZ8= 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=GgZMq+yo; arc=none smtp.client-ip=185.125.25.11 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-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 4VY6wj0j4Pz3Z6; Mon, 6 May 2024 18:55:33 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1715014532; bh=bX9I1ibW0C+6EYQnikkxNXNDSRcbJnaxyC+EsmTnLbM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GgZMq+you18f3OijPouZ8Kb9i0I5C0sjg2brWBqEk4YAZOKX18dXhzstmE6JmN0RF uPxkrKWErq3spxuBQy3W9iq6KbRJyv1H5oQfjfY7rrEBMt55Lw1CWCy4BP8RhCC6cg wed2FQPCzm+aUz+rOgNmiPmy2Mrnwq99gWMCOlys= Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4VY6wh29ZNzQFb; Mon, 6 May 2024 18:55:32 +0200 (CEST) From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: Christian Brauner , Greg Kroah-Hartman , Jakub Kicinski , Kees Cook , Linus Torvalds , Mark Brown , Sasha Levin , Sean Christopherson , Shengyu Li , Shuah Khan , Shuah Khan Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Bagas Sanjaya , Brendan Higgins , David Gow , "David S . Miller" , Florian Fainelli , =?UTF-8?q?G=C3=BCnther=20Noack?= , Jon Hunter , Ron Economos , Ronald Warsow , Stephen Rothwell , Will Drewry , kernel test robot , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v6 08/10] selftests/harness: Share _metadata between forked processes Date: Mon, 6 May 2024 18:55:16 +0200 Message-ID: <20240506165518.474504-9-mic@digikod.net> In-Reply-To: <20240506165518.474504-1-mic@digikod.net> References: <20240506165518.474504-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/20240506165518.474504-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