惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

The GitHub Blog
The GitHub Blog
阮一峰的网络日志
阮一峰的网络日志
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Apple Machine Learning Research
Apple Machine Learning Research
小众软件
小众软件
博客园 - 司徒正美
Last Week in AI
Last Week in AI
爱范儿
爱范儿
罗磊的独立博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
The Cloudflare Blog
雷峰网
雷峰网
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
WordPress大学
WordPress大学
Jina AI
Jina AI
人人都是产品经理
人人都是产品经理
量子位
V
V2EX
博客园 - 叶小钗
宝玉的分享
宝玉的分享
T
Tailwind CSS Blog

Arch Linux Forums

Gnome desktop mouse cursor zoom issues / Newbie Corner Avidemux crashes without strace / Applications & Desktop Environments how to apply patches with non-linux linends / Newbie Corner Replicating CachyOS on vanilla Arch (or at least getting close) / Arch Discussion What's arch linux GUI package manager ? / Newbie Corner Hibernation failing due to insufficient memory / System Administration profiledef.sh editting question / Installation trying to script kde plasma wallpaper settings / Programming & Scripting Looking for new Audacious package maintainer / Creating & Modifying Packages issues installing arch with LUKS2 encryption / Newbie Corner QEMU PXE booting does not work with OVMF.4m.fd / Applications & Desktop Environments Wired lan regular disconnect / Newbie Corner Need Help setting up ARCH in my G16 G634JZR iwlwifi started failing consistently, trying to determine root cause Windows randomly jumping between monitors after GNOME 50 update No display via DP or HDMI after boot. / Kernel & Hardware how to change acpi platform_profile? / Newbie Corner Linux denied all kernel modules which not loaded right now Use iPhone as Webcam for Arch Linux Video Output Failure on nvidia-580xx-dkms on TTY --> Desktop switch (Page 2) / Kernel & Hardware I was going to rant ..WINE32 Sabotage compliments of Arvind Krishna / Arch Discussion Hibernate/suspend from X = dark panel; from TTY = works (ASUS G14, hyb (Page 2) / Laptop Issues Headphone jack noise/buzz / Newbie Corner segmentation fault in cc1plus when building CLK / AUR Issues, Discussion & PKGBUILD Requests Console alternative to meld / GNU/Linux Discussion Problem with paru git clone / Newbie Corner XKB questions / Applications & Desktop Environments gnome-keyring-daemon is not working correctly / Applications & Desktop Environments [SOLVED] Steam opens and immediately closes constantly / Newbie Corner Firefox rounded edges on Sway / Applications & Desktop Environments
[SOLVED] LUKS drive auto unlocked by TPM when expected no...
cryptearth · 2026-06-05 · via Arch Linux Forums

#1 2026-06-04 21:32:32

avi9526
Member
Registered: 2015-05-15
Posts: 125

[SOLVED] LUKS drive auto unlocked by TPM when expected not to

I had my auto unlocking being broken for a long time. Tried to fix it without success. TPM2 unlock just didn't work. After playing with BIOS settings (clearing secure boot keys and etc) it suddenly started working. Problem is - i'd expect it to fail.

cryptsetup luksDump header.img
…
Tokens:
  0: systemd-tpm2
        tpm2-hash-pcrs:   0+7
…

and while playing with BIOS secure boot settings I was monitoring PCR 7 with

each boot this value changed (because I've changed secure boot setting in BIOS), yet each time disk was auto unlocked. I've read wiki and articles and know that TPM and LUKS is problematic, but this look utterly unsafe. What is going on?

Last edited by avi9526 (2026-06-05 16:48:33)

#2 2026-06-04 22:28:11

cryptearth
Member
Registered: 2024-02-03
Posts: 2,181

Re: [SOLVED] LUKS drive auto unlocked by TPM when expected not to

TPM != secure boot

secureboot: regular x509 chain just to verify signature of the chain up to the kernel to the systems root key
TPM: a device to meassure and compare a systems state
they both usually work independent of eachother

enable secureboot without proper chain just causes the boot to fail - while the tpm isn't affected by this as it more or less just checks: "hey, is this still the hardware as last time - and is it unmodified?"
I don't know if "is secureboot enabled?" can even be meassured for tpm auto-unlock - but it likely isn't in any default

#3 2026-06-05 16:42:06

avi9526
Member
Registered: 2015-05-15
Posts: 125

Re: [SOLVED] LUKS drive auto unlocked by TPM when expected not to

I have identified the problem. It appears that I have created it myself. You can notice that I use a detached luks header, but since /boot is not properly available at the time of unlocking the copy of the header must be built into initramfs image. So any change to actual header require "mkinitcpio" afterwards.

sbctl status
…
    Setup Mode:     ✓ Disabled
    Secure Boot:    ✓ Enabled
…

systemd-cryptenroll --wipe-slot=tpm2 Header.img
systemd-cryptenroll --tpm2-device=auto --tpm2-pcrs=0+7 Header.img
mkinitcpio -p linux…
reboot
…
PROFIT

Now LUKS auto unlock works when secure boot enabled and not does not work when secure boot altered (disabled, keys changed, etc)

Header being built into initramfs means I cannot use PCR9 that hashes initrd image, because I need to store hash of initrd inside initrd, which is practically impossible. Shame.

Last edited by avi9526 (2026-06-05 16:48:24)

#4 Today 19:30:04

Strike0
Member
From: Germany
Registered: 2011-09-05
Posts: 1,490

Re: [SOLVED] LUKS drive auto unlocked by TPM when expected not to

You don't explain why you use a separate header, but have a look if the new pinning feature let's you use defaults.

#5 Today 19:42:41

avi9526
Member
Registered: 2015-05-15
Posts: 125

Re: [SOLVED] LUKS drive auto unlocked by TPM when expected not to

Strike0 wrote:

You don't explain why you use a separate header, but have a look if the new pinning feature let's you use defaults.

I will take a look, thnx

Separate header is somehow pleasant to me:
1) it is easy to backup and fallback, there is 3 backups of header lying in my /boot
2) it is unix-way - as it is file
3) it corresponds to idea that data must be separated from non-data
4) such encryption could be removed/enrolled in the raw way due to the fact that encrypted data is aligned to un-encrypted data [https://unix.stackexchange.com/a/130998/67899]
5) it could be argued that encrypted partition without header is no more than just random data, actual situation depends on how close the government soldering iron to your backdoor

Last edited by avi9526 (Today 20:03:37)