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