#! /bin/sh # SPDX-License-Identifier: GPL-2.0 # # Randy Dunlap , 2018 # Thorsten Leemhuis , 2018 usage() { cat < Call without parameters to decode /proc/sys/kernel/tainted. Call with a positive integer as parameter to decode a value you retrieved from /proc/sys/kernel/tainted on another system. EOF } if [ "$1"x != "x" ]; then if [ "$1"x == "--helpx" ] || [ "$1"x == "-hx" ] ; then usage exit 1 elif [ $1 -ge 0 ] 2>/dev/null ; then taint=$1 else echo "Error: Parameter '$1' not a positive interger. Aborting." >&2 exit 1 fi else TAINTFILE="/proc/sys/kernel/tainted" if [ ! -r $TAINTFILE ]; then echo "No file: $TAINTFILE" exit fi taint=`cat $TAINTFILE` fi if [ $taint -eq 0 ]; then echo "Kernel not Tainted" exit else echo "Kernel is Tainted for follwing reasons:" fi T=$taint out= addout() { out=$out$1 } if [ `expr $T % 2` -eq 0 ]; then addout "G" else addout "P" echo " * Proprietary module was loaded." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "F" echo " * Module was force loaded." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "S" echo " * SMP kernel oops on an officially SMP incapable processor." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "R" echo " * Module was force unloaded." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "M" echo " * Processor reported a Machine Check Exception (MCE)." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "B" echo " * Bad page referenced or some unexpected page flags." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "U" echo " * Taint requested by userspace application." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "D" echo " * Kernel died recently, i.e. there was an OOPS or BUG" fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "A" echo " * ACPI table overridden by user." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "W" echo " * Kernel issued warning." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "C" echo " * Staging driver was loaded." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "I" echo " * Workaround for bug in platform firmware applied." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "O" echo " * Externally-built ('out-of-tree') module was loaded" fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "E" echo " * Unsigned module was loaded." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "L" echo " * Soft lockup occurred." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "K" echo " * Kernel live patched." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "X" echo " * Auxiliary taint, defined for and used by distros." fi T=`expr $T / 2` if [ `expr $T % 2` -eq 0 ]; then addout " " else addout "T" echo " * Kernel was built with the struct randomization plugin." fi echo "Raw taint value as int/string: $taint/'$out'" #EOF#