]> git.ipfire.org Git - thirdparty/systemd.git/commit
cryptsetup/cryptenroll: Iterate over TPM tokens when they don't match
authorKai Lüke <kai@amutable.com>
Mon, 20 Apr 2026 06:55:57 +0000 (15:55 +0900)
committerKai Lüke <pothos@users.noreply.github.com>
Fri, 10 Jul 2026 06:07:47 +0000 (08:07 +0200)
commit9213de2e067703debe34c91bedece359cc4cc95c
tree3da04a6a5cb17027472244a86ac345020aeb961e
parent58d38f6360e24b2ae974077c5610a84a80c32da3
cryptsetup/cryptenroll: Iterate over TPM tokens when they don't match

When we enroll two UKIs with different PCR pub keys into one LUKS slot/
token each, then we can encounter the wrong one and should not give up
but continue iterating instead of requiring the passphrase. Similarly,
a pcrlock token might be for another UKI and we should continue the
search. Same for a token that is meant for another TPM (e.g., external
storage). While this is mainly about cryptsetup's automatic unlocking
from the initrd, it also matters for usage in the system, e.g., for
other storage and when cryptenroll should unlock using the TPM.
There are two code paths, one is the libcryptsetup plugin and the other
is the fallback when that's not available.
To let the libcryptsetup loop continue to iterate, remap the above
error conditions to EPERM. For the fallback path check all of them (no
remapping) and continue iteration. For better log output, include the
token ID to be able understand which token fails.
src/cryptenroll/cryptenroll-tpm2.c
src/cryptsetup/cryptsetup-tokens/cryptsetup-token-systemd-tpm2.c
src/cryptsetup/cryptsetup.c
src/shared/tpm2-util.h