Debian Codegraph @

tools/debugging/kernel-chktaint

raw symbols SCIP
1 #! /bin/shscip-shell filesystem . . `/bin/sh`.
2 # SPDX-License-Identifier: GPL-2.0
3 #
4 # Randy Dunlap <[email protected]>, 2018
5 # Thorsten Leemhuis <[email protected]>, 2018
6
7 usagescip-shell shell shell-project 0.0.0 usage().()
8 {
9 catscip-shell system . . cat. <<EOF
10 usage: ${0##*/}
11 ${0##*/} <int>
12
13 Call without parameters to decode /proc/sys/kernel/tainted.
14
15 Call with a positive integer as parameter to decode a value you
16 retrieved from /proc/sys/kernel/tainted on another system.
17
18 EOF
19 }
20
21 if [scip-shell system . . `[`. "$1"x != "x" ]; then
22 if [scip-shell system . . `[`. "$1"x == "--helpx" ] || [scip-shell system . . `[`. "$1"x == "-hx" ] ; then
23 usagescip-shell shell shell-project 0.0.0 usage().
24 exit 1
25 elif [scip-shell system . . `[`. $1 -ge 0 ] 2>/dev/nullscip-shell filesystem . . `/dev/null`. ; then
26 taint=$1
27 else
28 echoscip-shell system . . echo. "Error: Parameter '$1' not a positive integer. Aborting." >&2
29 exit 1
30 fi
31 else
32 TAINTFILE="/proc/sys/kernel/taintedscip-shell filesystem . . `/proc/sys/kernel/tainted`."
33 if [scip-shell system . . `[`. ! -r $TAINTFILE ]; then
34 echoscip-shell system . . echo. "No file: $TAINTFILE"
35 exit
36 fi
37
38 taint=`catscip-shell system . . cat. $TAINTFILE`
39 fi
40
41 if [scip-shell system . . `[`. $taint -eq 0 ]; then
42 echoscip-shell system . . echo. "Kernel not Tainted"
43 exit
44 else
45 echoscip-shell system . . echo. "Kernel is \"tainted\" for the following reasons:"
46 fi
47
48 T=$taint
49 out=
50
51 addoutscip-shell shell shell-project 0.0.0 addout().() {
52 out=$out$1
53 }
54
55 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
56 addoutscip-shell shell shell-project 0.0.0 addout(). "G"
57 else
58 addoutscip-shell shell shell-project 0.0.0 addout(). "P"
59 echoscip-shell system . . echo. " * proprietary module was loaded (#0)"
60 fi
61
62 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
63 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
64 addoutscip-shell shell shell-project 0.0.0 addout(). " "
65 else
66 addoutscip-shell shell shell-project 0.0.0 addout(). "F"
67 echoscip-shell system . . echo. " * module was force loaded (#1)"
68 fi
69
70 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
71 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
72 addoutscip-shell shell shell-project 0.0.0 addout(). " "
73 else
74 addoutscip-shell shell shell-project 0.0.0 addout(). "S"
75 echoscip-shell system . . echo. " * kernel running on an out of specification system (#2)"
76 fi
77
78 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
79 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
80 addoutscip-shell shell shell-project 0.0.0 addout(). " "
81 else
82 addoutscip-shell shell shell-project 0.0.0 addout(). "R"
83 echoscip-shell system . . echo. " * module was force unloaded (#3)"
84 fi
85
86 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
87 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
88 addoutscip-shell shell shell-project 0.0.0 addout(). " "
89 else
90 addoutscip-shell shell shell-project 0.0.0 addout(). "M"
91 echoscip-shell system . . echo. " * processor reported a Machine Check Exception (MCE) (#4)"
92 fi
93
94 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
95 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
96 addoutscip-shell shell shell-project 0.0.0 addout(). " "
97 else
98 addoutscip-shell shell shell-project 0.0.0 addout(). "B"
99 echoscip-shell system . . echo. " * bad page referenced or some unexpected page flags (#5)"
100 fi
101
102 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
103 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
104 addoutscip-shell shell shell-project 0.0.0 addout(). " "
105 else
106 addoutscip-shell shell shell-project 0.0.0 addout(). "U"
107 echoscip-shell system . . echo. " * taint requested by userspace application (#6)"
108 fi
109
110 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
111 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
112 addoutscip-shell shell shell-project 0.0.0 addout(). " "
113 else
114 addoutscip-shell shell shell-project 0.0.0 addout(). "D"
115 echoscip-shell system . . echo. " * kernel died recently, i.e. there was an OOPS or BUG (#7)"
116 fi
117
118 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
119 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
120 addoutscip-shell shell shell-project 0.0.0 addout(). " "
121 else
122 addoutscip-shell shell shell-project 0.0.0 addout(). "A"
123 echoscip-shell system . . echo. " * an ACPI table was overridden by user (#8)"
124 fi
125
126 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
127 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
128 addoutscip-shell shell shell-project 0.0.0 addout(). " "
129 else
130 addoutscip-shell shell shell-project 0.0.0 addout(). "W"
131 echoscip-shell system . . echo. " * kernel issued warning (#9)"
132 fi
133
134 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
135 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
136 addoutscip-shell shell shell-project 0.0.0 addout(). " "
137 else
138 addoutscip-shell shell shell-project 0.0.0 addout(). "C"
139 echoscip-shell system . . echo. " * staging driver was loaded (#10)"
140 fi
141
142 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
143 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
144 addoutscip-shell shell shell-project 0.0.0 addout(). " "
145 else
146 addoutscip-shell shell shell-project 0.0.0 addout(). "I"
147 echoscip-shell system . . echo. " * workaround for bug in platform firmware applied (#11)"
148 fi
149
150 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
151 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
152 addoutscip-shell shell shell-project 0.0.0 addout(). " "
153 else
154 addoutscip-shell shell shell-project 0.0.0 addout(). "O"
155 echoscip-shell system . . echo. " * externally-built ('out-of-tree') module was loaded (#12)"
156 fi
157
158 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
159 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
160 addoutscip-shell shell shell-project 0.0.0 addout(). " "
161 else
162 addoutscip-shell shell shell-project 0.0.0 addout(). "E"
163 echoscip-shell system . . echo. " * unsigned module was loaded (#13)"
164 fi
165
166 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
167 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
168 addoutscip-shell shell shell-project 0.0.0 addout(). " "
169 else
170 addoutscip-shell shell shell-project 0.0.0 addout(). "L"
171 echoscip-shell system . . echo. " * soft lockup occurred (#14)"
172 fi
173
174 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
175 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
176 addoutscip-shell shell shell-project 0.0.0 addout(). " "
177 else
178 addoutscip-shell shell shell-project 0.0.0 addout(). "K"
179 echoscip-shell system . . echo. " * kernel has been live patched (#15)"
180 fi
181
182 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
183 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
184 addoutscip-shell shell shell-project 0.0.0 addout(). " "
185 else
186 addoutscip-shell shell shell-project 0.0.0 addout(). "X"
187 echoscip-shell system . . echo. " * auxiliary taint, defined for and used by distros (#16)"
188
189 fi
190
191 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
192 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
193 addoutscip-shell shell shell-project 0.0.0 addout(). " "
194 else
195 addoutscip-shell shell shell-project 0.0.0 addout(). "T"
196 echoscip-shell system . . echo. " * kernel was built with the struct randomization plugin (#17)"
197 fi
198
199 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
200 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
201 addoutscip-shell shell shell-project 0.0.0 addout(). " "
202 else
203 addoutscip-shell shell shell-project 0.0.0 addout(). "N"
204 echoscip-shell system . . echo. " * an in-kernel test (such as a KUnit test) has been run (#18)"
205 fi
206
207 T=`exprscip-shell system . . expr. $T /scip-shell filesystem . . `/`. 2`
208 if [scip-shell system . . `[`. `exprscip-shell system . . expr. $T % 2` -eq 0 ]; then
209 addoutscip-shell shell shell-project 0.0.0 addout(). " "
210 else
211 addoutscip-shell shell shell-project 0.0.0 addout(). "J"
212 echoscip-shell system . . echo. " * fwctl's mutating debug interface was used (#19)"
213 fi
214 echoscip-shell system . . echo. "Raw taint value as int/string: $taint/'$out'"
215
216 # report on any tainted loadable modules
217 [scip-shell system . . `[`. "$1" = "" ] && [scip-shell system . . `[`. -r /sys/module/scip-shell filesystem . . `/sys/module/`. ] && \
218 cnt=`grscip-shell system . . grep.ep [A-Z] /sys/module/*/taint | scip-shell system . . wc.wc -l` || cnt=0
219
220 if [scip-shell system . . `[`. $cnt -ne 0 ]; then
221 echoscip-shell system . . echo.
222 echoscip-shell system . . echo. "Tainted modules:"
223 for dir in `lsscip-shell system . . ls. /sys/modulescip-shell filesystem . . `/sys/module`.` ; do
224 if [scip-shell system . . `[`. -r /sys/module/$dir/taint ]; then
225 modtnt=`catscip-shell system . . cat. /sys/module/$dir/taint`
226 [scip-shell system . . `[`. "$modtnt" = "" ] || echoscip-shell system . . echo. " * $dir ($modtnt)"
227 fi
228 done
229 fi
230
231 echoscip-shell system . . echo.
232 echoscip-shell system . . echo. "For a more detailed explanation of the various taint flags see"
233 echoscip-shell system . . echo. " Documentation/admin-guide/tainted-kernels.rst in the Linux kernel sources"
234 echoscip-shell system . . echo. " or https://kernel.org/doc/html/latest/admin-guide/tainted-kernels.html"
235 #EOF#