プロセッサ脆弱性SpectreとMeltdownのLinux用チェッカー

Meltdown and Spectre

話題のSpectreとMeltdownというプロセッサの脆弱性。俗に言う「PC」は軒並み脆弱性を抱えてると言って良いので早めの対処が必要だけどなかなか大変そう。
自分の端末でその脆弱性の有無を表示するLinux用のチェッカーがあるので試してみた。

https://github.com/speed47/spectre-meltdown-checker

ファイルはスクリプト1つだけ。インストールなどはなく、テンポラリディレクトリにでも置いて実行するだけ。不要になったら削除すれば良い。

$ cd /tmp
$ wget https://github.com/speed47/spectre-meltdown-checker/archive/master.zip
$ unzip master.zip
$ cd spectre-meltdown-checker-master
$ sudo ./spectre-meltdown-checker.sh
root's password: 管理者パスワード
Spectre and Meltdown mitigation detection tool v0.17

Checking for vulnerabilities against live running kernel Linux 4.4.49-16-default #1 SMP Sun Feb 19 17:40:35 UTC 2017 (70e9954) x86_64
Will use vmlinux image /boot/vmlinuz-4.4.49-16-default
Will use kconfig /tmp/config-0b1
Will use System.map file /boot/System.map-4.4.49-16-default

CVE-2017-5753 [bounds check bypass] aka 'Spectre Variant 1'
* Kernel compiled with LFENCE opcode inserted at the proper places:  NO  (only 40 opcodes found, should be >= 70)
> STATUS:  VULNERABLE 

CVE-2017-5715 [branch target injection] aka 'Spectre Variant 2'
* Mitigation 1
*   Hardware (CPU microcode) support for mitigation:  NO 
*   Kernel support for IBRS:  NO 
*   IBRS enabled for Kernel space:  NO 
*   IBRS enabled for User space:  NO 
* Mitigation 2
*   Kernel compiled with retpoline option:  NO 
*   Kernel compiled with a retpoline-aware compiler:  NO 
> STATUS:  VULNERABLE  (IBRS hardware + kernel support OR kernel with retpoline are needed to mitigate the vulnerability)

CVE-2017-5754 [rogue data cache load] aka 'Meltdown' aka 'Variant 3'
* Kernel supports Page Table Isolation (PTI):  NO 
* PTI enabled and active:  NO 
> STATUS:  VULNERABLE  (PTI is needed to mitigate the vulnerability)

$

赤字部分が入力するコマンド等。
Kernel compiled with LFENCE opcode inserted at the proper places: が表示されたところで暫く停まったように見えるのが何かの文字列入力待ちと勘違いしそうになるが入力しないでプロンプトが返るまで待つ。

基本的な調査項目3つ(Spectre Variant 1, Spectre Variant 2, Meltdown)の各項目のSTATUSが赤塗りのVULNERABLEなら脆弱性有り、緑塗りのNOT VULNERABLEなら(一応)対策済みとなる。対策済みといっても根治ではないので、本当の意味で「対応」するなら対策済のプロセッサに物を交換するしかないみたいだけど。 ちなみに、上の実行例は全くパッチを当てていない未対策機なので3項目とも脆弱性有り。
\(^o^)/