diff options
author | David Gow <davidgow@google.com> | 2022-07-08 07:48:47 +0300 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2022-07-12 01:58:11 +0300 |
commit | 8370b400f5abad168bcc541fa2574e7bd6b3bf2c (patch) | |
tree | bbdad05203afe0c7b2080343589e7a101480cf50 /Documentation/dev-tools/kselftest.rst | |
parent | 74829ddf5977567d77440150d72d4c0c5c427446 (diff) | |
download | linux-8370b400f5abad168bcc541fa2574e7bd6b3bf2c.tar.xz |
selftest: Taint kernel when test module loaded
Make any kselftest test module (using the kselftest_module framework)
taint the kernel with TAINT_TEST on module load.
Also mark the module as a test module using MODULE_INFO(test, "Y") so
that other tools can tell this is a test module. We can't rely solely
on this, though, as these test modules are also often built-in.
Finally, update the kselftest documentation to mention that the kernel
should be tainted, and how to do so manually (as below).
Note that several selftests use kernel modules which are not based on
the kselftest_module framework, and so will not automatically taint the
kernel.
This can be done in two ways:
- Moving the module to the tools/testing directory. All modules under
this directory will taint the kernel.
- Adding the 'test' module property with:
MODULE_INFO(test, "Y")
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.
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Acked-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'Documentation/dev-tools/kselftest.rst')
-rw-r--r-- | Documentation/dev-tools/kselftest.rst | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Documentation/dev-tools/kselftest.rst b/Documentation/dev-tools/kselftest.rst index a833ecf12fbc..1096a9833550 100644 --- a/Documentation/dev-tools/kselftest.rst +++ b/Documentation/dev-tools/kselftest.rst @@ -250,6 +250,14 @@ assist writing kernel modules that are for use with kselftest: - ``tools/testing/selftests/kselftest_module.h`` - ``tools/testing/selftests/kselftest/module.sh`` +Note that test modules should taint the kernel with TAINT_TEST. This will +happen automatically for modules which are in the ``tools/testing/`` +directory, or for modules which use the ``kselftest_module.h`` header above. +Otherwise, you'll need to add ``MODULE_INFO(test, "Y")`` to your module +source. selftests which do not load modules typically should not taint the +kernel, but in cases where a non-test module is loaded, TEST_TAINT can be +applied from userspace by writing to ``/proc/sys/kernel/tainted``. + How to use ---------- @@ -308,6 +316,7 @@ A bare bones test module might look like this: KSTM_MODULE_LOADERS(test_foo); MODULE_AUTHOR("John Developer <jd@fooman.org>"); MODULE_LICENSE("GPL"); + MODULE_INFO(test, "Y"); Example test script ------------------- |