|
|
Log in / Subscribe / Register

Run KUnit tests late and handle faults

From:  Mickaël Salaün <mic-AT-digikod.net>
To:  Brendan Higgins <brendanhiggins-AT-google.com>, David Gow <davidgow-AT-google.com>, Kees Cook <keescook-AT-chromium.org>, Rae Moar <rmoar-AT-google.com>, Shuah Khan <skhan-AT-linuxfoundation.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>
Cc:  Mickaël Salaün <mic-AT-digikod.net>, Alan Maguire <alan.maguire-AT-oracle.com>, Borislav Petkov <bp-AT-alien8.de>, Dave Hansen <dave.hansen-AT-linux.intel.com>, "H . Peter Anvin" <hpa-AT-zytor.com>, Ingo Molnar <mingo-AT-redhat.com>, James Morris <jamorris-AT-linux.microsoft.com>, Luis Chamberlain <mcgrof-AT-kernel.org>, "Madhavan T . Venkataraman" <madvenka-AT-linux.microsoft.com>, Marco Pagani <marpagan-AT-redhat.com>, Paolo Bonzini <pbonzini-AT-redhat.com>, Sean Christopherson <seanjc-AT-google.com>, Stephen Boyd <sboyd-AT-kernel.org>, Thara Gopinath <tgopinath-AT-microsoft.com>, Thomas Gleixner <tglx-AT-linutronix.de>, Vitaly Kuznetsov <vkuznets-AT-redhat.com>, Wanpeng Li <wanpengli-AT-tencent.com>, Zahra Tarkhani <ztarkhani-AT-microsoft.com>, kvm-AT-vger.kernel.org, linux-hardening-AT-vger.kernel.org, linux-hyperv-AT-vger.kernel.org, linux-kernel-AT-vger.kernel.org, linux-security-module-AT-vger.kernel.org, linux-um-AT-lists.infradead.org, x86-AT-kernel.org
Archive-link:  Article

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




Copyright © 2024, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds