0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

SecureBoot対応記録(進行中)(失敗中)

Last updated at Posted at 2025-03-22

超絶わかりやすい資料

前提

Kali Linux (SecureBoot非対応Linux)
ベアメタル
PCはUEFI対応済み
shim 15.8
Secure Bootしないときは正常に起動する

SecureBootの流れ

  1. shimx64.efiの起動
  2. shimx64.efiがgrubx64.efiの署名を確認(shimがInsecure modeでないとき)
  3. grubx64.efiの起動
  4. カーネルの署名の確認(shimがInsecure modeでないとき)
  5. vmlinuz(カーネル)のロード
  6. カーネルモジュールの署名の確認(ロックダウンモード有効時)
  7. カーネルモジュールのロード

shimの用意

shim-signedパッケージをapt install。
インストール時にMicrosoftの署名付きのshimが/usr/lib/shim/shimx64.efi.signedにダウンロードされる。
このshimx64.efi.signed/boot/efi以下に移し、ブートエントリに登録。

sudo mv /usr/lib/shim/shimx64.efi.signed /boot/efi/EFI/kali/shimx64.efi
sudo mv /usr/lib/shim/mmx64.efi.signed /boot/efi/EFI/kali/mmx64.efi
sudo efibootmgr -c -d /dev/sda1 -L "Shim FIrst stage bootloader" -l "\EFI\kali\shimx64.efi"

shimにより検証されるGRUBとカーネルを署名し証明書をMOKに登録

署名に必要な秘密鍵と公開鍵の生成を行い、署名を行う。
そして、MOKへの公開鍵の登録を行う。
マシンの再起動でMOKへの登録を行う。

openssl req -newkey rsa:2048 -nodes -keyout MOK.key -new -x509 -sha256 -days 36500 -out MOK.crt
openssl x509 -outform DER -in MOK.crt -out MOK.cer
sudo sbsign --key MOK.key --cert MOK.crt --output /boot/vmlinuz-6.11.2-amd64 /boot/vmlinuz-6.11.2-amd64 
sudo sbsign --key MOK.key --cert MOK.crt --output /boot/efi/EFI/kali/grubx64.efi /boot/efi/EFI/kali/grubx64.efi
sudo mokutil --import MOK.cer
sudo mokutil --list-enrolled

トラブル(未解決)

1つめ

ここでUEFIでSecure Bootを有効化すればgrubとカーネルまで起動するはずだが、grubすら起動しない。
shimの読み込み後、以下の表示が出る。現在もこのトラブルは解決していない。
shim15.8のshim.cの1212行目、1274行目のエラー。

Failed to load image: Security Policy Violation
start_image() returned Security Policy Violation

Verification failed: (0x1A) Security Violation

image.png

MOKの画面から証明書を登録したり、grubのハッシュ値を登録したりするも、grubが起動しないため、shimかMOKに問題がありそう。

2つめ

mokutil --disable-validation(efi変数のMokSBに0を登録)後、GRUBは起動するがvmlinuzが読み込めない。
error: you need to load kernel firstとGRUBのエラーが出るが、grub.cfgを見る限り、vmlinuxの読み込み後にinitialが読み込まれている。かつ、セキュアブートしていないときはこのエラーは発生しない。

コメント

Ubuntu Linux MintはSecureBoot対応してた。UEFIでSecure Bootをオンにするだけ。

20250405追記

perror文しまくって、lib/variables.cのget_variable_attr関数の290行目付近のがNot Foundを返していることに端を発することが分かった。

RT->GetVariable((CHAR16 *)var, &owner, NULL, len, NULL);
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?