Documentation/translations/zh_CN/mm/vmalloced-kernel-stacks.rst

Source file repositories/reference/linux-study-clean/Documentation/translations/zh_CN/mm/vmalloced-kernel-stacks.rst

File Facts

System
Linux kernel
Corpus path
Documentation/translations/zh_CN/mm/vmalloced-kernel-stacks.rst
Extension
.rst
Size
5175 bytes
Lines
134
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_CN.rst

:Original: Documentation/mm/vmalloced-kernel-stacks.rst

:翻译:

 司延腾 Yanteng Si <siyanteng@loongson.cn>

:校译:

====================
支持虚拟映射的内核栈
====================

:作者: Shuah Khan <skhan@linuxfoundation.org>

.. contents:: :local:

概览
----

这是介绍 `虚拟映射内核栈功能 <https://lwn.net/Articles/694348/>` 的代码
和原始补丁系列的信息汇总。

简介
----

内核堆栈溢出通常难以调试,并使内核容易被(恶意)利用。问题可能在稍后的时间出现,使其难以
隔离和究其根本原因。

带有保护页的虚拟映射内核堆栈如果溢出,会被立即捕获,而不会放任其导致难以诊断的损
坏。

HAVE_ARCH_VMAP_STACK和VMAP_STACK配置选项能够支持带有保护页的虚拟映射堆栈。
当堆栈溢出时,这个特性会引发可靠的异常。溢出后堆栈跟踪的可用性以及对溢出本身的
响应取决于架构。

.. note::
        截至本文撰写时, arm64, powerpc, riscv, s390, um, 和 x86 支持VMAP_STACK。

HAVE_ARCH_VMAP_STACK
--------------------

能够支持虚拟映射内核栈的架构应该启用这个bool配置选项。要求是:

- vmalloc空间必须大到足以容纳许多内核堆栈。这可能排除了许多32位架构。
- vmalloc空间的堆栈需要可靠地工作。例如,如果vmap页表是按需创建的,当堆栈指向
  具有未填充页表的虚拟地址时,这种机制需要工作,或者架构代码(switch_to()和
  switch_mm(),很可能)需要确保堆栈的页表项在可能未填充的堆栈上运行之前已经填
  充。
- 如果堆栈溢出到一个保护页,就应该发生一些合理的事情。“合理”的定义是灵活的,但
  在没有记录任何东西的情况下立即重启是不友好的。

VMAP_STACK
----------

VMAP_STACK bool配置选项在启用时分配虚拟映射的任务栈。这个选项依赖于
HAVE_ARCH_VMAP_STACK。

- 如果你想使用带有保护页的虚拟映射的内核堆栈,请启用该选项。这将导致内核栈溢出
  被立即捕获,而不是难以诊断的损坏。

.. note::

        使用KASAN的这个功能需要架构支持用真实的影子内存来支持虚拟映射,并且
        必须启用KASAN_VMALLOC。

.. note::

Annotation

Implementation Notes