Documentation/translations/zh_TW/admin-guide/tainted-kernels.rst

Source file repositories/reference/linux-study-clean/Documentation/translations/zh_TW/admin-guide/tainted-kernels.rst

File Facts

System
Linux kernel
Corpus path
Documentation/translations/zh_TW/admin-guide/tainted-kernels.rst
Extension
.rst
Size
8012 bytes
Lines
162
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.

Dependency Surface

Detected Declarations

Annotated Snippet

.. SPDX-License-Identifier: GPL-2.0

.. include:: ../disclaimer-zh_TW.rst

:Original: :doc:`../../../admin-guide/tainted-kernels`

:譯者:

 吳想成 Wu XiangCheng <bobwxc@email.cn>
 胡皓文 Hu Haowen <2023002089@link.tyut.edu.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

Implementation Notes