Received: by 2002:ab2:3b09:0:b0:1ed:14ea:9113 with SMTP id b9csp16127lqc; Thu, 29 Feb 2024 09:06:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVT0V7DDCSku6YkJXTaHGUvRZqfKtxb4XjGCN5fZnBJvRQsVy2l53bQwaU/ycA/jyGsfyz2T6bXsbJnVHce9PUXEfzxHEDUABlavgM6BQ== X-Google-Smtp-Source: AGHT+IEaQT9NO+oDttAjWd3p0wchAZx9UhutJQdxtixeS/lkM+ZKUQXOZNqWmpTPcmHmCp62Lghv X-Received: by 2002:a17:907:11cf:b0:a3e:6f98:c69d with SMTP id va15-20020a17090711cf00b00a3e6f98c69dmr1539982ejb.63.1709226360242; Thu, 29 Feb 2024 09:06:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709226360; cv=pass; d=google.com; s=arc-20160816; b=hvERt5jX3hoLLUzFgskzDKvWsZrZbvjUQEVWv5WXf2PK2V7WW2oPc6oSOeRg8QruQ2 BSyISHvwJmcS5gSrf7vnye8G8hwzP0gN4Ki5QH0Qfw9c/t7IH2lb6zQsYCZEmANTOtbR RdGp2vpxauh/AKhYpX0WYUR3XyEYWonn1blMpD7eo8xMYpVho6huEFzY905PM6qwd1Hj sHaekM8ljKi9v3o7jUEoxj+n+trGrmZ5dEnGW7U4GLCOUj8wYBJHyrtN78m2P0pd9H21 vBbnVpUsPGBWXPNzmp34BMGtyAA50qPRc61cpHqG2f6zby7t9uPOE7pVbVcSu/daPcOW 7mlQ== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=ZJ4iZR2qsWlZ4aapEky+vEYApfMYzxKzJ6l+O/T6keg=; fh=MR/wbEn34JHmT+rtzWNq5RVU/RKi8DhjSvb3ywiuLkE=; b=pHdICK8rDNFvFijPvq27dlZMs7lj9gWVIFfXgqfMYyj3MKVylGFJSyO1fk/2m7BXz6 ljC0+KzlC2+YQibY8EgkkzNt0UjIeELa8zyfab6N9nrXZpTH/SUViwKxIT+OHjY4yroI bzac95/C4vKN32rwmuD64cWaTPBphNu2JwuRca7y8i05XfogeIKSBkrXPEAUi4ECHRC0 CZdIWdXG5fwiQRpoH9tcuqEDKXxHpqlAl1n4ZUS2VG0Y3cPld8iEpG7oUkxSPL9E7SIs mr9vaYN5HuQ8CKnDfVKWp+4LHWQbzX8QvA4jA3TZ7kyCvGFZjEtXNURbD3YABbcTzjaQ jNyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=nlVkoodR; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-87139-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87139-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id vr6-20020a170906bfe600b00a3f85e6d5a1si671127ejb.786.2024.02.29.09.06.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Feb 2024 09:06:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-87139-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@digikod.net header.s=20191114 header.b=nlVkoodR; arc=pass (i=1 spf=pass spfdomain=digikod.net dkim=pass dkdomain=digikod.net); spf=pass (google.com: domain of linux-kernel+bounces-87139-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-87139-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 0012E1F25639 for ; Thu, 29 Feb 2024 17:06:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E24DC7827E; Thu, 29 Feb 2024 17:04:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=digikod.net header.i=@digikod.net header.b="nlVkoodR" Received: from smtp-42ad.mail.infomaniak.ch (smtp-42ad.mail.infomaniak.ch [84.16.66.173]) (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 5F52636B1C for ; Thu, 29 Feb 2024 17:04:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=84.16.66.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709226278; cv=none; b=HUChTzTwL+mt+6joPJN2SBHSpkqmoiEPuumXjb5kAV41EzbpdtHEjTAJvo5v6ChQfYQY0nGWAQLPX3NGtzyJ54CyjCEmxtSftfUqJ+ixclomkIW5sARV6WsF+1Ot2QQErdva2JpHZCCGytCIxgmSJJsJz6lHtJw/Cxqj7OyzZWw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709226278; c=relaxed/simple; bh=4wDdbt4I56G5n6LSUJ2u1jaEVBMsm/64WWZPbsYi9U0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=lo9Ubhsms1bau8PYOi4rrWQI/qmyEO6y1mLi/NT7LeCa3hfzlI/A++zfD9fLJ3jpExJ5ziGZdJlTyJ2mgEsFERRQ3jMcJ7VTJ7beJhN+NOZzNsM3CVvak7bxS1Zq7iYwh150G+5Qk8LSNDg+NBbbNbSM2hudHrQdzTlzcQILbRs= 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=nlVkoodR; arc=none smtp.client-ip=84.16.66.173 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 4TlyHp6JJMz5wk; Thu, 29 Feb 2024 18:04:22 +0100 (CET) Received: from unknown by smtp-4-0000.mail.infomaniak.ch (Postfix) with ESMTPA id 4TlyHm47S2zYBH; Thu, 29 Feb 2024 18:04:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=digikod.net; s=20191114; t=1709226262; bh=4wDdbt4I56G5n6LSUJ2u1jaEVBMsm/64WWZPbsYi9U0=; h=From:To:Cc:Subject:Date:From; b=nlVkoodRGG/+JH60co6QTYI+j/xS/kAvzRqTk/xdhkVfSSC5JtD7P7treNBKoqd0u U5gu49lO236cmDqZAiQi+oFIZbE1jszXjS2h0mslolmhNqIG4IKa/drMCKvMRTmYRX pKXV1VkrqQbG3nE+oEnjraDdG3Vrknapc8Mb93bc= From: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= To: Brendan Higgins , David Gow , Kees Cook , Rae Moar , Shuah Khan Cc: =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Alan Maguire , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Ingo Molnar , James Morris , Luis Chamberlain , "Madhavan T . Venkataraman" , Marco Pagani , Paolo Bonzini , Sean Christopherson , Stephen Boyd , Thara Gopinath , Thomas Gleixner , Vitaly Kuznetsov , Wanpeng Li , Zahra Tarkhani , kvm@vger.kernel.org, linux-hardening@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-um@lists.infradead.org, x86@kernel.org Subject: [PATCH v1 0/8] Run KUnit tests late and handle faults Date: Thu, 29 Feb 2024 18:04:01 +0100 Message-ID: <20240229170409.365386-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 Hi, This patch series moves KUnit test execution at the very end of kernel initialization, just before launching the init process. This opens the way to test any kernel code in its normal state (i.e. fully initialized). This patch series also teaches KUnit to handle kthread faults as errors, and it brings a few related fixes and improvements. New tests check NULL pointer dereference and read-only memory, which wasn't possible before. This is useful to test current kernel self-protection mechanisms or future ones such as Heki: https://github.com/heki-linux Regards, Mickaël Salaün (8): kunit: Run tests when the kernel is fully setup kunit: Handle thread creation error kunit: Fix kthread reference kunit: Fix timeout message kunit: Handle test faults kunit: Fix KUNIT_SUCCESS() calls in iov_iter tests kunit: Print last test location on fault kunit: Add tests for faults include/kunit/test.h | 24 +++++- include/kunit/try-catch.h | 3 - init/main.c | 4 +- lib/bitfield_kunit.c | 8 +- lib/checksum_kunit.c | 2 +- lib/kunit/executor.c | 81 ++++++++++++++------ lib/kunit/kunit-example-test.c | 6 +- lib/kunit/kunit-test.c | 115 +++++++++++++++++++++++++++- lib/kunit/try-catch.c | 33 +++++--- lib/kunit_iov_iter.c | 70 ++++++++--------- tools/testing/kunit/kunit_kernel.py | 6 +- 11 files changed, 261 insertions(+), 91 deletions(-) base-commit: d206a76d7d2726f3b096037f2079ce0bd3ba329b -- 2.44.0