Skip to content

Commit 99d5e6f

Browse files
committed
lkdtm: basic description
1 parent 336fc28 commit 99d5e6f

File tree

1 file changed

+162
-0
lines changed

1 file changed

+162
-0
lines changed

kselftests/lkdtm/README.rst

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
About
2+
=====
3+
4+
LKDTM (Linux Kernel Dump Test Module) is used for crashing the kernel on
5+
demand and checking whether the kernel handled this properly.
6+
7+
Related files
8+
=============
9+
10+
``Documentation/fault-injection/provoke-crashes.rst``
11+
-----------------------------------------------------
12+
13+
Describes the ``lkdtm`` module allowing for provoked kernel crashes.
14+
15+
The collection's test names correspond to the ``cpoint_type`` ("crash
16+
point type") values mentioned in that document.
17+
18+
``tools/testing/selftests/lkdtm/tests.txt``
19+
-------------------------------------------
20+
21+
List of the actual tests contained in the collection, with some
22+
meta-data attached. The mapping:
23+
24+
::
25+
26+
#PANIC
27+
BUG kernel BUG at
28+
WARNING WARNING:
29+
WARNING_MESSAGE message trigger
30+
EXCEPTION
31+
#LOOP Hangs the system
32+
#EXHAUST_STACK Corrupts memory on failure
33+
#CORRUPT_STACK Crashes entire system on success
34+
#CORRUPT_STACK_STRONG Crashes entire system on success
35+
36+
37+
->
38+
39+
::
40+
41+
lkdtm:PANIC.sh
42+
lkdtm:BUG.sh
43+
lkdtm:WARNING.sh
44+
lkdtm:WARNING_MESSAGE.sh
45+
lkdtm:EXCEPTION.sh
46+
lkdtm:LOOP.sh
47+
lkdtm:EXHAUST_STACK.sh
48+
lkdtm:CORRUPT_STACK.sh
49+
lkdtm:CORRUPT_STACK_STRONG.sh
50+
51+
52+
#. The lines starting with ``#`` aren't really comments, in a sense that
53+
whatever follows the ``#`` isn't ignored - it does in fact specify a
54+
test, but it will be reported as skipped when executed. The
55+
"dangerous" tests are commented out by default.
56+
57+
#. When a line contains multiple words only the first one is used as the
58+
test's name.
59+
60+
::
61+
62+
BUDDY_INIT_ON_ALLOC Memory appears initialized
63+
64+
->
65+
66+
::
67+
68+
lkdtm:BUDDY_INIT_ON_ALLOC.sh
69+
70+
The rest is used as a short *note* about what is to be expected from
71+
this test, displayed upon the test execution. It's also what's being
72+
searched for in dmesg after provoking the failure, as a test's
73+
success criterion.
74+
75+
``tools/testing/selftests/lkdtm/run.sh``
76+
----------------------------------------
77+
78+
The template for each test in the collection. Although the test names
79+
like ``lkdtm:WARNING_MESSAGE.sh`` suggest there is a shell script for
80+
each of them there is in fact only one - the ``run.sh`` - which is
81+
copied multiple times inside the ``tools/testing/selftests/lkdtm/``
82+
directory with different names corresponding to different test names
83+
when the ``lkdtm`` collection is build. Each script then, when run,
84+
introspects its own name to know which test it should conduct and then
85+
just writes the test's name into the
86+
``/sys/kernel/debug/provoke-crash/DIRECT``, like
87+
88+
.. code:: shell
89+
90+
echo ‹test› > /sys/kernel/debug/provoke-crash/DIRECT
91+
92+
After that the newly shown dmesg lines are searched for the test's note,
93+
or for "call trace:" if it doesn't have any. If the text was found the
94+
test reports success, otherwise failure.
95+
96+
For example, the ``lkdtm:WARNING_MESSAGE.sh`` test is realized by
97+
``tools/testing/selftests/lkdtm/WARNING_MESSAGE.sh``, copied from
98+
``tools/testing/selftests/lkdtm/run.sh``, which writes
99+
100+
.. code:: shell
101+
102+
echo WARNING_MESSAGE > /sys/kernel/debug/provoke-crash/DIRECT
103+
104+
Then the dmesg is searched for "message trigger", as that is the
105+
``WARNING_MESSAGE``'s note defined in the
106+
`tools/testing/selftests/lkdtm/tests.txt`_
107+
108+
``tools/testing/selftests/lkdtm/stack-entropy.sh``
109+
--------------------------------------------------
110+
111+
Corresponds to the ``lkdtm:stack-entropy.sh`` test, the only one not
112+
realized by the ``run.sh`` script.
113+
114+
Requirements and applicability
115+
==============================
116+
117+
The ``lkdtm`` collection is not available in pre-``9.2`` versions. The
118+
tests don't have any compilation requirements, but to run them the
119+
``lkdtm`` module has to be available in the tested kernel, provided by
120+
the ``CONFIG_LKDTM`` option, which is disabled in all default
121+
configurations of LTS versions ``9.2``, ``9.4`` (other not checked)
122+
123+
.. code:: shell
124+
125+
grep CONFIG_LKDTM kernel-src-tree-{ciqlts9_2,ciqlts9_4}/configs/kernel*.config
126+
127+
::
128+
129+
kernel-src-tree-ciqlts9_2/configs/kernel-aarch64-64k-debug-rhel.config:# CONFIG_LKDTM is not set
130+
kernel-src-tree-ciqlts9_2/configs/kernel-aarch64-64k-rhel.config:# CONFIG_LKDTM is not set
131+
kernel-src-tree-ciqlts9_2/configs/kernel-aarch64-debug-rhel.config:# CONFIG_LKDTM is not set
132+
kernel-src-tree-ciqlts9_2/configs/kernel-aarch64-rhel.config:# CONFIG_LKDTM is not set
133+
kernel-src-tree-ciqlts9_2/configs/kernel-ppc64le-debug-rhel.config:# CONFIG_LKDTM is not set
134+
kernel-src-tree-ciqlts9_2/configs/kernel-ppc64le-rhel.config:# CONFIG_LKDTM is not set
135+
kernel-src-tree-ciqlts9_2/configs/kernel-s390x-debug-rhel.config:# CONFIG_LKDTM is not set
136+
kernel-src-tree-ciqlts9_2/configs/kernel-s390x-rhel.config:# CONFIG_LKDTM is not set
137+
kernel-src-tree-ciqlts9_2/configs/kernel-s390x-zfcpdump-rhel.config:# CONFIG_LKDTM is not set
138+
kernel-src-tree-ciqlts9_2/configs/kernel-x86_64-debug-rhel.config:# CONFIG_LKDTM is not set
139+
kernel-src-tree-ciqlts9_2/configs/kernel-x86_64-rhel.config:# CONFIG_LKDTM is not set
140+
kernel-src-tree-ciqlts9_4/configs/kernel-aarch64-64k-debug-rhel.config:# CONFIG_LKDTM is not set
141+
kernel-src-tree-ciqlts9_4/configs/kernel-aarch64-64k-rhel.config:# CONFIG_LKDTM is not set
142+
kernel-src-tree-ciqlts9_4/configs/kernel-aarch64-debug-rhel.config:# CONFIG_LKDTM is not set
143+
kernel-src-tree-ciqlts9_4/configs/kernel-aarch64-rhel.config:# CONFIG_LKDTM is not set
144+
kernel-src-tree-ciqlts9_4/configs/kernel-aarch64-rt-debug-rhel.config:# CONFIG_LKDTM is not set
145+
kernel-src-tree-ciqlts9_4/configs/kernel-aarch64-rt-rhel.config:# CONFIG_LKDTM is not set
146+
kernel-src-tree-ciqlts9_4/configs/kernel-ppc64le-debug-rhel.config:# CONFIG_LKDTM is not set
147+
kernel-src-tree-ciqlts9_4/configs/kernel-ppc64le-rhel.config:# CONFIG_LKDTM is not set
148+
kernel-src-tree-ciqlts9_4/configs/kernel-s390x-debug-rhel.config:# CONFIG_LKDTM is not set
149+
kernel-src-tree-ciqlts9_4/configs/kernel-s390x-rhel.config:# CONFIG_LKDTM is not set
150+
kernel-src-tree-ciqlts9_4/configs/kernel-s390x-zfcpdump-rhel.config:# CONFIG_LKDTM is not set
151+
kernel-src-tree-ciqlts9_4/configs/kernel-x86_64-debug-rhel.config:# CONFIG_LKDTM is not set
152+
kernel-src-tree-ciqlts9_4/configs/kernel-x86_64-rhel.config:# CONFIG_LKDTM is not set
153+
kernel-src-tree-ciqlts9_4/configs/kernel-x86_64-rt-debug-rhel.config:# CONFIG_LKDTM is not set
154+
kernel-src-tree-ciqlts9_4/configs/kernel-x86_64-rt-rhel.config:# CONFIG_LKDTM is not set
155+
156+
This does not mean that these tests don't apply to Rocky Linux in
157+
general (disabling ``CONFIG_LKDTM`` does not eliminate potentially
158+
malfunctioning code branches, only the way to expose them), but it
159+
certainly doesn't make sense to run them on the default builds.
160+
161+
Note that for full functionality also other options may need to be
162+
enabled - see the ``tools/testing/selftests/lkdtm/config`` file.

0 commit comments

Comments
 (0)