···11Tainted kernels22---------------3344-Some oops reports contain the string **'Tainted: '** after the program55-counter. This indicates that the kernel has been tainted by some66-mechanism. The string is followed by a series of position-sensitive77-characters, each representing a particular tainted value.44+The kernel will mark itself as 'tainted' when something occurs that might be55+relevant later when investigating problems. Don't worry too much about this,66+most of the time it's not a problem to run a tainted kernel; the information is77+mainly of interest once someone wants to investigate some problem, as its real88+cause might be the event that got the kernel tainted. That's why bug reports99+from tainted kernels will often be ignored by developers, hence try to reproduce1010+problems with an untainted kernel.81199- 1) ``G`` if all modules loaded have a GPL or compatible license, ``P`` if1212+Note the kernel will remain tainted even after you undo what caused the taint1313+(i.e. unload a proprietary kernel module), to indicate the kernel remains not1414+trustworthy. That's also why the kernel will print the tainted state when it1515+notices an internal problem (a 'kernel bug'), a recoverable error1616+('kernel oops') or a non-recoverable error ('kernel panic') and writes debug1717+information about this to the logs ``dmesg`` outputs. It's also possible to1818+check the tainted state at runtime through a file in ``/proc/``.1919+2020+2121+Tainted flag in bugs, oops or panics messages2222+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~2323+2424+You find the tainted state near the top in a line starting with 'CPU:'; if or2525+why the kernel was tainted is shown after the Process ID ('PID:') and a shortened2626+name of the command ('Comm:') that triggered the event::2727+2828+ BUG: unable to handle kernel NULL pointer dereference at 00000000000000002929+ Oops: 0002 [#1] SMP PTI3030+ CPU: 0 PID: 4424 Comm: insmod Tainted: P W O 4.20.0-0.rc6.fc30 #13131+ Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/20113232+ RIP: 0010:my_oops_init+0x13/0x1000 [kpanic]3333+ [...]3434+3535+You'll find a 'Not tainted: ' there if the kernel was not tainted at the3636+time of the event; if it was, then it will print 'Tainted: ' and characters3737+either letters or blanks. In above example it looks like this::3838+3939+ Tainted: P W O4040+4141+The meaning of those characters is explained in the table below. In tis case4242+the kernel got tainted earlier because a proprietary Module (``P``) was loaded,4343+a warning occurred (``W``), and an externally-built module was loaded (``O``).4444+To decode other letters use the table below.4545+4646+4747+Decoding tainted state at runtime4848+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~4949+5050+At runtime, you can query the tainted state by reading5151+``cat /proc/sys/kernel/tainted``. If that returns ``0``, the kernel is not5252+tainted; any other number indicates the reasons why it is. The easiest way to5353+decode that number is the script ``tools/debugging/kernel-chktaint``, which your5454+distribution might ship as part of a package called ``linux-tools`` or5555+``kernel-tools``; if it doesn't you can download the script from5656+`git.kernel.org <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/tools/debugging/kernel-chktaint>`_5757+and execute it with ``sh kernel-chktaint``, which would print something like5858+this on the machine that had the statements in the logs that were quoted earlier::5959+6060+ Kernel is Tainted for following reasons:6161+ * Proprietary module was loaded (#0)6262+ * Kernel issued warning (#9)6363+ * Externally-built ('out-of-tree') module was loaded (#12)6464+ See Documentation/admin-guide/tainted-kernels.rst in the the Linux kernel or6565+ https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html for6666+ a more details explanation of the various taint flags.6767+ Raw taint value as int/string: 4609/'P W O '6868+6969+You can try to decode the number yourself. That's easy if there was only one7070+reason that got your kernel tainted, as in this case you can find the number7171+with the table below. If there were multiple reasons you need to decode the7272+number, as it is a bitfield, where each bit indicates the absence or presence of7373+a particular type of taint. It's best to leave that to the aforementioned7474+script, but if you need something quick you can use this shell command to check7575+which bits are set::7676+7777+ $ for i in $(seq 18); do echo $(($i-1)) $(($(cat /proc/sys/kernel/tainted)>>($i-1)&1));done7878+7979+Table for decoding tainted state8080+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~8181+8282+=== === ====== ========================================================8383+Bit Log Number Reason that got the kernel tainted8484+=== === ====== ========================================================8585+ 0 G/P 1 proprietary module was loaded8686+ 1 _/F 2 module was force loaded8787+ 2 _/S 4 SMP kernel oops on an officially SMP incapable processor8888+ 3 _/R 8 module was force unloaded8989+ 4 _/M 16 processor reported a Machine Check Exception (MCE)9090+ 5 _/B 32 bad page referenced or some unexpected page flags9191+ 6 _/U 64 taint requested by userspace application9292+ 7 _/D 128 kernel died recently, i.e. there was an OOPS or BUG9393+ 8 _/A 256 ACPI table overridden by user9494+ 9 _/W 512 kernel issued warning9595+ 10 _/C 1024 staging driver was loaded9696+ 11 _/I 2048 workaround for bug in platform firmware applied9797+ 12 _/O 4096 externally-built ("out-of-tree") module was loaded9898+ 13 _/E 8192 unsigned module was loaded9999+ 14 _/L 16384 soft lockup occurred100100+ 15 _/K 32768 kernel has been live patched101101+ 16 _/X 65536 auxiliary taint, defined for and used by distros102102+ 17 _/T 131072 kernel was built with the struct randomization plugin103103+=== === ====== ========================================================104104+105105+Note: The character ``_`` is representing a blank in this table to make reading106106+easier.107107+108108+More detailed explanation for tainting109109+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~110110+111111+ 0) ``G`` if all modules loaded have a GPL or compatible license, ``P`` if10112 any proprietary module has been loaded. Modules without a11113 MODULE_LICENSE or with a MODULE_LICENSE that is not recognised by12114 insmod as GPL compatible are assumed to be proprietary.131151414- 2) ``F`` if any module was force loaded by ``insmod -f``, ``' '`` if all116116+ 1) ``F`` if any module was force loaded by ``insmod -f``, ``' '`` if all15117 modules were loaded normally.161181717- 3) ``S`` if the oops occurred on an SMP kernel running on hardware that119119+ 2) ``S`` if the oops occurred on an SMP kernel running on hardware that18120 hasn't been certified as safe to run multiprocessor.19121 Currently this occurs only on various Athlons that are not20122 SMP capable.211232222- 4) ``R`` if a module was force unloaded by ``rmmod -f``, ``' '`` if all124124+ 3) ``R`` if a module was force unloaded by ``rmmod -f``, ``' '`` if all23125 modules were unloaded normally.241262525- 5) ``M`` if any processor has reported a Machine Check Exception,127127+ 4) ``M`` if any processor has reported a Machine Check Exception,26128 ``' '`` if no Machine Check Exceptions have occurred.271292828- 6) ``B`` if a page-release function has found a bad page reference or2929- some unexpected page flags.130130+ 5) ``B`` If a page-release function has found a bad page reference or some131131+ unexpected page flags. This indicates a hardware problem or a kernel bug;132132+ there should be other information in the log indicating why this tainting133133+ occured.301343131- 7) ``U`` if a user or user application specifically requested that the135135+ 6) ``U`` if a user or user application specifically requested that the32136 Tainted flag be set, ``' '`` otherwise.331373434- 8) ``D`` if the kernel has died recently, i.e. there was an OOPS or BUG.138138+ 7) ``D`` if the kernel has died recently, i.e. there was an OOPS or BUG.351393636- 9) ``A`` if the ACPI table has been overridden.140140+ 8) ``A`` if an ACPI table has been overridden.371413838- 10) ``W`` if a warning has previously been issued by the kernel.142142+ 9) ``W`` if a warning has previously been issued by the kernel.39143 (Though some warnings may set more specific taint flags.)401444141- 11) ``C`` if a staging driver has been loaded.145145+ 10) ``C`` if a staging driver has been loaded.421464343- 12) ``I`` if the kernel is working around a severe bug in the platform147147+ 11) ``I`` if the kernel is working around a severe bug in the platform44148 firmware (BIOS or similar).451494646- 13) ``O`` if an externally-built ("out-of-tree") module has been loaded.150150+ 12) ``O`` if an externally-built ("out-of-tree") module has been loaded.471514848- 14) ``E`` if an unsigned module has been loaded in a kernel supporting152152+ 13) ``E`` if an unsigned module has been loaded in a kernel supporting49153 module signature.501545151- 15) ``L`` if a soft lockup has previously occurred on the system.155155+ 14) ``L`` if a soft lockup has previously occurred on the system.521565353- 16) ``K`` if the kernel has been live patched.157157+ 15) ``K`` if the kernel has been live patched.541585555-The primary reason for the **'Tainted: '** string is to tell kernel5656-debuggers if this is a clean kernel or if anything unusual has5757-occurred. Tainting is permanent: even if an offending module is5858-unloaded, the tainted value remains to indicate that the kernel is not5959-trustworthy.159159+ 16) ``X`` Auxiliary taint, defined for and used by Linux distributors.160160+161161+ 17) ``T`` Kernel was build with the randstruct plugin, which can intentionally162162+ produce extremely unusual kernel structure layouts (even performance163163+ pathological ones), which is important to know when debugging. Set at164164+ build time.
+22-28
Documentation/sysctl/kernel.txt
···9494- stop-a [ SPARC only ]9595- sysrq ==> Documentation/admin-guide/sysrq.rst9696- sysctl_writes_strict9797-- tainted9797+- tainted ==> Documentation/admin-guide/tainted-kernels.rst9898- threads-max9999- unknown_nmi_panic100100- watchdog···1019101910201020 1: kernel stack erasing is enabled (default), it is performed before10211021 returning to the userspace at the end of syscalls.10221022-10231022==============================================================1024102310251025-tainted:10241024+tainted1026102510271026Non-zero if the kernel has been tainted. Numeric values, which can be10281027ORed together. The letters are seen in "Tainted" line of Oops reports.1029102810301030- 1 (P): A module with a non-GPL license has been loaded, this10311031- includes modules with no license.10321032- Set by modutils >= 2.4.9 and module-init-tools.10331033- 2 (F): A module was force loaded by insmod -f.10341034- Set by modutils >= 2.4.9 and module-init-tools.10351035- 4 (S): Unsafe SMP processors: SMP with CPUs not designed for SMP.10361036- 8 (R): A module was forcibly unloaded from the system by rmmod -f.10371037- 16 (M): A hardware machine check error occurred on the system.10381038- 32 (B): A bad page was discovered on the system.10391039- 64 (U): The user has asked that the system be marked "tainted". This10401040- could be because they are running software that directly modifies10411041- the hardware, or for other reasons.10421042- 128 (D): The system has died.10431043- 256 (A): The ACPI DSDT has been overridden with one supplied by the user10441044- instead of using the one provided by the hardware.10451045- 512 (W): A kernel warning has occurred.10461046- 1024 (C): A module from drivers/staging was loaded.10471047- 2048 (I): The system is working around a severe firmware bug.10481048- 4096 (O): An out-of-tree module has been loaded.10491049- 8192 (E): An unsigned module has been loaded in a kernel supporting module10501050- signature.10511051- 16384 (L): A soft lockup has previously occurred on the system.10521052- 32768 (K): The kernel has been live patched.10531053- 65536 (X): Auxiliary taint, defined and used by for distros.10541054-131072 (T): The kernel was built with the struct randomization plugin.10291029+ 1 (P): proprietary module was loaded10301030+ 2 (F): module was force loaded10311031+ 4 (S): SMP kernel oops on an officially SMP incapable processor10321032+ 8 (R): module was force unloaded10331033+ 16 (M): processor reported a Machine Check Exception (MCE)10341034+ 32 (B): bad page referenced or some unexpected page flags10351035+ 64 (U): taint requested by userspace application10361036+ 128 (D): kernel died recently, i.e. there was an OOPS or BUG10371037+ 256 (A): an ACPI table was overridden by user10381038+ 512 (W): kernel issued warning10391039+ 1024 (C): staging driver was loaded10401040+ 2048 (I): workaround for bug in platform firmware applied10411041+ 4096 (O): externally-built ("out-of-tree") module was loaded10421042+ 8192 (E): unsigned module was loaded10431043+ 16384 (L): soft lockup occurred10441044+ 32768 (K): kernel has been live patched10451045+ 65536 (X): Auxiliary taint, defined and used by for distros10461046+131072 (T): The kernel was built with the struct randomization plugin10471047+10481048+See Documentation/admin-guide/tainted-kernels.rst for more information.1055104910561050==============================================================10571051