Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1414827lqm; Thu, 2 May 2024 14:14:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV0FSFUk5BQeK5I0FQq3PBU+0lDFzR5x7SsJ47ZDPgk6WGcv83yUL3JccD+E+CBBWTHyAvjDcGy/+K6t8jM8QNuDq8IuL9OSWUQQjowSA== X-Google-Smtp-Source: AGHT+IFVF3OA/smZWjjhfOx9OxgHxMva1UvlrmcWGzj9k6cf+xm5vw6czhL1Ig/ySgfe3jOI/dsL X-Received: by 2002:a05:6a21:279a:b0:1af:66a9:d104 with SMTP id rn26-20020a056a21279a00b001af66a9d104mr1042468pzb.1.1714684460321; Thu, 02 May 2024 14:14:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714684460; cv=pass; d=google.com; s=arc-20160816; b=S2xCHgq4LzQ3IeOtZJA1jO/oSm/3aTLrwNmV1fXAUPd9JmoOQYK8Jbl5NLuqSjZHFi T8XrfCmnXheNJKn/VNmKt106kjP2eQtNI8Q5KBa6lC3nBxK/T6aA1Ivx+WM4OMrCnlhz cm9XQXAcf+PCcJGPx8IM1OzQHt+LZv01F9Z+IFrUxKaCEtLS9huMQ+Uc9AXcTftrdulx FYK5AfqcMEjNra6fFi4pCfMp7tvxlrAPwyJOvo9n+qELU93DIECB82q+amjBVHR2BKK2 2LVXukb4wlF12B3W5fRkLyExzScb+8F3KcUf/wKFEL38y44F+V/VaGWfpRgkP47t6dZ2 zbgA== 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=v0C4g/wchbO9TN6o4EJ9wl8n0UaCdACeauzusyuLmDA=; fh=DyJwEPHty4QZ77xuwgmyonrTSVvlIRI2bkR/2kTqG9Q=; b=hILBzp6+Z9T4JEiUa42toHdYBkvPIucrypdePut2pAUhc6pMpmqGQs+vP2ZS+nTwrl LXSszxFqkR1pM/uQN7eT3rWJA+htmQ4iZ2z569BBtFU0MCcPS4tx4Y0/Nbj6HK0H9gHw zyl8M5Ocyj01ibP/+9/0zNkHGdhtkJWXnAT+JCgB33WseIEQUE3iIpJzf2kXez6hBhUO qVNSogn8z4goNfBW0TljvMDmka1TXymtBPfaEB+2/nc+K+O7EZQBAA1WGbJtz09cWAds wkX/+EG1GHp+MDFmwkPMWv0vXfeGMdiOvvORSpXxaCn6lzA+BTzbgIFpHABXB4OUtrZp P5Dw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b="me/zohhA"; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-166921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166921-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 ck16-20020a056a02091000b005f0bc6f9563si1830993pgb.339.2024.05.02.14.14.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 14:14:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166921-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="me/zohhA"; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-166921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166921-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 EACE0B23076 for ; Thu, 2 May 2024 21:12:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 132C01C68BA; Thu, 2 May 2024 21:10:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="me/zohhA" Received: from smtp-8faa.mail.infomaniak.ch (smtp-8faa.mail.infomaniak.ch [83.166.143.170]) (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 9ADF21C65E0; Thu, 2 May 2024 21:09:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=83.166.143.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714684199; cv=none; b=IJCH+ITFATLrIvcb52MQsNgrvuGwKX/ZHZHkk6SIP9q50QKNHPQ5iju/Glc6CUTQSoFnFwZZKV/OjfoYPWLeBZ6epijzZBu9IlViqdHyNfTBgBm72BMhY0BixeQ7pzRz5sKwnHLLP/38MVXsrsFO6QRh6FtveNLkkUSMlCji6Lk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714684199; c=relaxed/simple; bh=15Py21Y0wiTWxGYN8/FXrHgQsVA/abvkNE37zFQYec8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=nOpXglCatZ9QmTxoNih1M75lmv6RtgXoO7KS+84wU9SVHeG1SMZefFpvMG0Dy3dwmCObyQRz46ahHlMTbxIj83HKtm2pZ49+nZGKraWnFq0s0ZkIsXjfPTbPuDPV+Q9EF2qPgzxNMSBP/6i+NoB1KdjTCLwTS9qcpRdLlveKtAM= 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=me/zohhA; arc=none smtp.client-ip=83.166.143.170 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-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 4VVmlw6pyKzMV6; Thu, 2 May 2024 23:09:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1714684188; bh=15Py21Y0wiTWxGYN8/FXrHgQsVA/abvkNE37zFQYec8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=me/zohhAObZfSouj8HYKxLVfoDGVy4fwktvPiW/nUVS9aJMw3G1n6T81dfmH8G5rw FKzDsnhS5BUV50Lc7E/5JM75UTVhqHokaSNa9tVcmeTJK2lZ8qAmmY0XOBqiDpltn7 I2WlZqKMKOXOQVYWA05QSYyI+dSCmMx4vk7DXDNg= Received: from unknown by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4VVmlw3F5rzqpc; Thu, 2 May 2024 23:09:48 +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, Shuah Khan Subject: [PATCH v4 08/10] selftests/harness: Share _metadata between forked processes Date: Thu, 2 May 2024 23:09:24 +0200 Message-ID: <20240502210926.145539-9-mic@digikod.net> In-Reply-To: <20240502210926.145539-1-mic@digikod.net> References: <20240502210926.145539-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/20240502210926.145539-9-mic@digikod.net --- Changes since v1: * Extract change from a bigger patch (suggested by Kees). --- tools/testing/selftests/kselftest_harness.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h index 201040207c85..abf2ffd2094f 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, \ -- 2.45.0