Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1349011lqa; Mon, 29 Apr 2024 06:18:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWbZ6B10C+VID1pEP03pP8sGV1TG1gAHgCSmyMIsCn+gSFHdLIbuO3tSZBkt+yNKtYKpogDpZaFncZJP8I8cZJ+ITreTPYxJFkkns/cvQ== X-Google-Smtp-Source: AGHT+IGh9P8nP1dmZPUbu20pYWlKH/k1OfFa0mRjYjVlJCBZGUGQwuyXs0zgujnvNoJZ0HgZQpXx X-Received: by 2002:a05:6e02:12eb:b0:368:a724:f757 with SMTP id l11-20020a056e0212eb00b00368a724f757mr13225831iln.6.1714396686078; Mon, 29 Apr 2024 06:18:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714396686; cv=pass; d=google.com; s=arc-20160816; b=Zrk5lGRLPRn/F7UxnotIvNJ0iZJARiKODVH4AQxxAjXE/ZTdq1L/prCLZQJlie+lCn NbTIxdrJOJBghc4QezMFaFiEB1WaXkcpCt3kafPPPWcCdls4KOnu40jG1REiXRSj6K45 h1HzaVfGDVNX6PjCSTk6lHi+/khkkUEOnCt9SQRo2o0Wdmwiw+aXA4TjMJ75SnseNQth PqECGOUxaYNcLJ8jRyZkRtO73G0377qMoB/r1Jaw1VfIC3hseSE4+rb7Ey1Bpq020ldl HDNP+6+Ick612BFRarIhCgwcPJKm2uha3hleoASv+4j7wZsjlpfdzqWcy6Ng7D6Uf7gY AicA== 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=qCrqJDQmeV0/tdqgTTJZ5pB5SuY0YLKswHye/u5e2Cc=; fh=T/ngxZ/rchirObc+ozpAMGxUCKvTk1uHXxRS2gfk1OI=; b=gUIEFLLSztOMBxA8RNecTxIwotWKTubltZG1ECL8by2WFNGtHKfi++u0uRNvPe+vbN jNzuwiZ3rFdTBrz64zHhLjTFHfn14nvAR8A+j8of5rzXoT19RPgTPsz4zZ+6X9wXLqOf aUYay1xNd2AaQ6N/yFxpF5L12g5Fk3j92g6uexjSnovszwF/fwAkM+nWPvthXvKsikO0 4Debr/VxQAH4OU4iGNEjd1uSxKePso7cIVEpeH1UOTpVSPiYkATp+gGhIjY13oDOT6m0 AOa/uH4mN4ZlY08LOSqGr24xuFYUq/3W0xRSDScsAL8nrFamNMnlUztBIe+caX1UKjOC 6K2w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b="aOhHn/Lv"; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-162334-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162334-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id x127-20020a636385000000b0060f1998de94si545354pgb.604.2024.04.29.06.18.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 06:18:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162334-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b="aOhHn/Lv"; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-162334-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162334-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6D36328CFA0 for ; Mon, 29 Apr 2024 13:11:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B18E7BAE5; Mon, 29 Apr 2024 13:09:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="aOhHn/Lv" Received: from smtp-bc0c.mail.infomaniak.ch (smtp-bc0c.mail.infomaniak.ch [45.157.188.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 282E856B69 for ; Mon, 29 Apr 2024 13:09:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.157.188.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714396191; cv=none; b=o7yug0V6Nri/Jm70ej64WCsAMdFZAeQC+8mejdHx2WCX0PPr4degzLNHJ6430rmQamfgCmfS5ahEAaLpO4dfHvuNCRWUUNbW8C007jmLo29wHnIFV1wcXl89o76uPjJqoRbRfkHhXduS+Ew04CJZ/tXz3JRzkWuQt2Uex4jRQfI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714396191; c=relaxed/simple; bh=RCiNRuWpxOb6geUb1GUxmDRpb83Z9T2991NBzbYwDBQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dAO0ISMjpGz53U2iaRkTQKgyJJQoqkOj82Lf4Zd1EUvGsYRFfdp5PXuARc6QL5hBpB5WWdkSdnHZJhW7O+iDIXQ0MBoc3l5Y9+RvDXNkDvaFMLkaru/Lz7K1zvMBWkbxc2M0CIsKTyphYB735P2s3W/P4yO1ftL4TSGTC55apcQ= 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=aOhHn/Lv; arc=none smtp.client-ip=45.157.188.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 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 4VSkFR25dfzMqT; Mon, 29 Apr 2024 15:09:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1714396187; bh=RCiNRuWpxOb6geUb1GUxmDRpb83Z9T2991NBzbYwDBQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aOhHn/LvG3K8c1XSO+dpYk/u2lCEMktg1NjG/N7Zfc399eHWLAQEUzw6ijutuxbVJ 7MEzTGNJz/EZxI5+gzgaM6jeqvtMbdawgClPO7KdXoj+nKHYAvCQoYby4iZ0PrQd3F HgcH5A2VD6s7ABQ1YA87T73dk9YnYDaVfcCH6TD0= Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4VSkFQ5Bqdzf7d; Mon, 29 Apr 2024 15:09:46 +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 v2 8/9] selftests/harness: Share _metadata between forked processes Date: Mon, 29 Apr 2024 15:09:30 +0200 Message-ID: <20240429130931.2394118-9-mic@digikod.net> In-Reply-To: <20240429130931.2394118-1-mic@digikod.net> References: <20240429130931.2394118-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: Kees Cook Cc: Shuah Khan Cc: Will Drewry Signed-off-by: Mickaël Salaün Link: https://lore.kernel.org/r/20240429130931.2394118-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 8a7d899a75e0..eceedb0a3586 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -430,19 +430,17 @@ static pid_t __attribute__((__unused__)) 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.44.0