Documentation/translations/zh_CN/admin-guide/tainted-kernels.rst
Source file repositories/reference/linux-study-clean/Documentation/translations/zh_CN/admin-guide/tainted-kernels.rst
File Facts
- System
- Linux kernel
- Corpus path
Documentation/translations/zh_CN/admin-guide/tainted-kernels.rst- Extension
.rst- Size
- 7923 bytes
- Lines
- 158
- Domain
- Support Tooling And Documentation
- Bucket
- Documentation
- Inferred role
- Support Tooling And Documentation: documentation
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
.. include:: ../disclaimer-zh_CN.rst
:Original: :doc:`../../../admin-guide/tainted-kernels`
:译者:
吴想成 Wu XiangCheng <bobwxc@email.cn>
受污染的内核
-------------
当发生一些在稍后调查问题时可能相关的事件时,内核会将自己标记为“受污染
(tainted)”的。不用太过担心,大多数情况下运行受污染的内核没有问题;这些信息
主要在有人想调查某个问题时才有意义的,因为问题的真正原因可能是导致内核受污染
的事件。这就是为什么来自受污染内核的缺陷报告常常被开发人员忽略,因此请尝试用
未受污染的内核重现问题。
请注意,即使在您消除导致污染的原因(亦即卸载专有内核模块)之后,内核仍将保持
污染状态,以表示内核仍然不可信。这也是为什么内核在注意到内部问题(“kernel
bug”)、可恢复错误(“kernel oops”)或不可恢复错误(“kernel panic”)时会打印
受污染状态,并将有关此的调试信息写入日志 ``dmesg`` 输出。也可以通过
``/proc/`` 中的文件在运行时检查受污染的状态。
BUG、Oops或Panics消息中的污染标志
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
在顶部以“CPU:”开头的一行中可以找到受污染的状态;内核是否受到污染和原因会显示
在进程ID(“PID:”)和触发事件命令的缩写名称(“Comm:”)之后::
BUG: unable to handle kernel NULL pointer dereference at 0000000000000000
Oops: 0002 [#1] SMP PTI
CPU: 0 PID: 4424 Comm: insmod Tainted: P W O 4.20.0-0.rc6.fc30 #1
Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
RIP: 0010:my_oops_init+0x13/0x1000 [kpanic]
[...]
如果内核在事件发生时没有被污染,您将在那里看到“Not-tainted:”;如果被污染,那
么它将是“Tainted:”以及字母或空格。在上面的例子中,它看起来是这样的::
Tainted: P W O
下表解释了这些字符的含义。在本例中,由于加载了专有模块( ``P`` ),出现了
警告( ``W`` ),并且加载了外部构建的模块( ``O`` ),所以内核早些时候受到
了污染。要解码其他字符,请使用下表。
解码运行时的污染状态
~~~~~~~~~~~~~~~~~~~~~
在运行时,您可以通过读取 ``cat /proc/sys/kernel/tainted`` 来查询受污染状态。
如果返回 ``0`` ,则内核没有受到污染;任何其他数字都表示受到污染的原因。解码
这个数字的最简单方法是使用脚本 ``tools/debugging/kernel-chktaint`` ,您的
发行版可能会将其作为名为 ``linux-tools`` 或 ``kernel-tools`` 的包的一部分提
供;如果没有,您可以从
`git.kernel.org <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/tools/debugging/kernel-chktaint>`_
网站下载此脚本并用 ``sh kernel-chktaint`` 执行,它会在上面引用的日志中有类似
语句的机器上打印这样的内容::
Kernel is Tainted for following reasons:
* Proprietary module was loaded (#0)
* Kernel issued warning (#9)
* Externally-built ('out-of-tree') module was loaded (#12)
See Documentation/admin-guide/tainted-kernels.rst in the Linux kernel or
https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html for
a more details explanation of the various taint flags.
Raw taint value as int/string: 4609/'P W O '
你也可以试着自己解码这个数字。如果内核被污染的原因只有一个,那么这很简单,
在本例中您可以通过下表找到数字。如果你需要解码有多个原因的数字,因为它是一
Annotation
- Atlas domain: Support Tooling And Documentation / Documentation.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.