lkml.org 
[lkml]   [2022]   [May]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    Subject[PATCH v3 3/3] selftest: Taint kernel when test module loaded
    From
    Make any kselftest test module (using the kselftest_module framework)
    taint the kernel with TAINT_TEST on module load.

    Note that several selftests use kernel modules which are not based on
    the kselftest_module framework, and so will not automatically taint the
    kernel. These modules will have to be manually modified if they should
    taint the kernel this way.

    Similarly, selftests which do not load modules into the kernel generally
    should not taint the kernel (or possibly should only do so on failure),
    as it's assumed that testing from user-space should be safe. Regardless,
    they can write to /proc/sys/kernel/tainted if required.

    Signed-off-by: David Gow <davidgow@google.com>
    ---
    tools/testing/selftests/kselftest_module.h | 2 ++
    1 file changed, 2 insertions(+)

    diff --git a/tools/testing/selftests/kselftest_module.h b/tools/testing/selftests/kselftest_module.h
    index e2ea41de3f35..226e616b82e0 100644
    --- a/tools/testing/selftests/kselftest_module.h
    +++ b/tools/testing/selftests/kselftest_module.h
    @@ -3,6 +3,7 @@
    #define __KSELFTEST_MODULE_H

    #include <linux/module.h>
    +#include <linux/panic.h>

    /*
    * Test framework for writing test modules to be loaded by kselftest.
    @@ -41,6 +42,7 @@ static inline int kstm_report(unsigned int total_tests, unsigned int failed_test
    static int __init __module##_init(void) \
    { \
    pr_info("loaded.\n"); \
    + add_taint(TAINT_KUNIT, LOCKDEP_STILL_OK); \
    selftest(); \
    return kstm_report(total_tests, failed_tests, skipped_tests); \
    } \
    --
    2.36.0.550.gb090851708-goog
    \
     
     \ /
      Last update: 2022-05-13 10:33    [W:3.799 / U:0.868 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site