如何检查 Linux 内核是否启用了“Retpoline”?

Wei*_*ang 20 linux kernel linux-kernel

对于“Spectre”安全漏洞,引入了“Retpoline”作为降低风险的解决方案。但是,我读过一篇文章提到:

如果你在没有 . 的情况下构建内核CONFIG_RETPOLINE,则无法使用 retpoline 构建模块,然后期望它们加载 - 因为不会导出 thunk 符号。

如果您使用 retpoline 构建内核,则可以成功加载不是使用 retpoline 构建的模块。(来源

是否有一种简单且通用/通用/统一的方法来检查内核是否启用了“Retpoline”?我想这样做,以便我的安装程序可以使用要安装的正确构建的内核模块。

Ste*_*itt 24

如果您正在使用主线内核或大多数主要发行版的内核,检查完整 retpoline 支持(内核配置为CONFIG_RETPOLINE,并使用支持 retpoline 的编译器构建)的最佳方法是查找“Full generic retpoline ”中/sys/devices/system/cpu/vulnerabilities/spectre_v2。在我的系统上:

$ cat /sys/devices/system/cpu/vulnerabilities/spectre_v2
Mitigation: Full generic retpoline, IBPB, IBRS_FW
Run Code Online (Sandbox Code Playgroud)

如果您想要更全面的测试,要在没有spectre_v2systree 文件的情况下检测内核上的retpolines,请查看spectre-meltdown-checker事情的进展情况。

  • 要检查其他与崩溃/幽灵相关的漏洞,请运行 `$ grep 。/sys/devices/system/cpu/vulnerabilities/*`,在 [Greg Kroah-Hartman 的博客](http://www.kroah.com/log/blog/2018/01/19/meltdown-status- 2/)。 (2认同)