Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1578038lqa; Mon, 29 Apr 2024 12:25:54 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXwzHEvZQshr36B1CwjA3XV+zrg0hOdZY+RYWqKzqZDpaoUvZGY9xMK8x2kWQTg+++wC6h+Y0BVEzuxklgNh6DXXEwXH+VfkOyEqZ6Kjw== X-Google-Smtp-Source: AGHT+IFFPezxpmurkiE8A9u6QUrj2lLxkRY19IwYQ8mm2+USTX18hbZrcE+4u0fqxSia0GHeQwXC X-Received: by 2002:ad4:5966:0:b0:6a0:7a3f:d290 with SMTP id eq6-20020ad45966000000b006a07a3fd290mr10829001qvb.51.1714418753869; Mon, 29 Apr 2024 12:25:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714418753; cv=pass; d=google.com; s=arc-20160816; b=N8PwC9W2Zsuw3SpPi8Bo7q91Cbl39YO9YmMMti4+l7SdYaUMKbNlm/Zl5sX3sPc9Cx X2As8pBjvo712k4G9s81F4WZs6llvQsPoOjfneB5dvUd23j5PnjN+WzZq2I9qERZS8WI g0uzI/DDxvsLBsLXEgWEdV8E4MbAlVCC+6/0ErLsMVvngH6biaQg+wuY0QOakACVKSiF CRUzNohtOnG9d7Jh+J8FPbdDhuqz4vTY5ViNw58NT/6p7E/uW2YbXakwmUECTsgCZjTv 5gpkiQPFAgEULyJiCLm1/Ism2OV3p1ZRoqufGDrlOS7Homfg/P1ZB3fILAoPothM2lrG CnMg== 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=K/pqnCZ9KA21hDxf3sInSuh52YfLrlRUJCrElGbaKpg=; fh=T/ngxZ/rchirObc+ozpAMGxUCKvTk1uHXxRS2gfk1OI=; b=MXlLA9Hg6VL4x/ceBC9DhQUr/vTXGQNBPGjRyKjqrFH5b/+Te2i/Jff/rDWnpNNz1p 1UMFdc4Vgk+fQX1a+nfE2unwbK6xBylU+31t4xKhR5X/XYPiGgmTsodyo5jHhgm6fCvd AA+csr83V5+QWRY2PJVwWdnuOlT3vxqnqIEnHz35HCyqpPvOJmQNQy2Chf4FJwy3Pvv4 /1KlSlUbsAjdxbdOm1m5ATCNiiGW7Bt1XsR5fdf6oIo7sfIMPu266O8Pq05uGeNxzXtZ ZmECUWqep9gwpxGkaEuMkCKz99v1UYNrKbGaKBP4clFMMGLZOPBiO4yG/nbD4yeIS2pZ s7UQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=M8CMfpj1; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-162911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162911-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id im2-20020a056214246200b006a0ce2c3c1csi3264739qvb.258.2024.04.29.12.25.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Apr 2024 12:25:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-162911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=M8CMfpj1; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-162911-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-162911-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 8350E1C204E8 for ; Mon, 29 Apr 2024 19:25:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 85A1E13AD38; Mon, 29 Apr 2024 19:25:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="M8CMfpj1" Received: from smtp-bc0f.mail.infomaniak.ch (smtp-bc0f.mail.infomaniak.ch [45.157.188.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 BB33B12B73 for ; Mon, 29 Apr 2024 19:25:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.157.188.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714418746; cv=none; b=Q5MFNlV4yWk5FzyQU0goD5qyoJ2J+0F2j/cIHDnAOpxf+5qMV1PKNXnFRjhj4JWG4DtiHqboR+Fg2/Iy2iQx/zh8813o9jwWCHcX/wdJC7zUT0InjUA18pUjGOybHg8N7Qt33I/edXzSDFjvd/wTOuupQEhjvkGsBhc4NthE6nU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714418746; c=relaxed/simple; bh=3PXhxV7iXwVfyBsouE+oC23MF65qM+eZR7kMA49Oe2w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HCHuIde0PQBvMH03n67+qkkJEKq0FiQyFGHsYBpFJH72CeL6At0m+klRoo410+s19caHcqSiS3ZUR1SRGSJXGcgL1YV+RuQoA/ZsiN50PUaeIqfWuhtNzXcEwnOEUlGLldWS//uk/R1XklYzUA+zOpAQpOTv9wJtiFFnEBr5RCg= 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=M8CMfpj1; arc=none smtp.client-ip=45.157.188.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 4VStRv0dmzzCTK; Mon, 29 Apr 2024 21:19:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1714418362; bh=3PXhxV7iXwVfyBsouE+oC23MF65qM+eZR7kMA49Oe2w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M8CMfpj1OT5bUx1X0iG6sJ409K/5jXoYP9l431ZQqVxYSgbIFO8GxqSowRMASLcmM /D+uQppb1BHgHFBtunS1XH/NvP/Dk+syLdQMsAu/3QH0FqT9pXMifVwvOHwmRiiH1U fsgm5Kwsys0ttBfdiunMjFerVtbMjxKUbP9Vgu4E= Received: from unknown by smtp-4-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4VStRt3TLWzXPb; Mon, 29 Apr 2024 21:19:22 +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 v3 8/9] selftests/harness: Share _metadata between forked processes Date: Mon, 29 Apr 2024 21:19:10 +0200 Message-ID: <20240429191911.2552580-9-mic@digikod.net> In-Reply-To: <20240429191911.2552580-1-mic@digikod.net> References: <20240429191911.2552580-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/20240429191911.2552580-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.44.0