cryptsetup: Give NV index missing its own error code

To be able to continue trying other tokens to unlock a disk the missing
NV index case was mapped to EREMOTE (foreign TPM) which was ok because
this mostly happens when trying to unlock on another system. Still it
might be useful to deal with NV index errors differently.
Give it its own EADDRNOTAVAIL error and handle it at all call sites.
This commit is contained in:
Kai Lüke
2026-07-10 08:07:47 +02:00
committed by Kai Lüke
parent 7fb6b9c2a2
commit e2b89bc3d5
7 changed files with 24 additions and 10 deletions
+4 -3
View File
@@ -4753,8 +4753,8 @@ int tpm2_policy_authorize_nv(
"Submitted policy does not match policy stored in PolicyAuthorizeNV.");
if ((rc & ~(TPM2_RC_N_MASK|TPM2_RC_P)) == TPM2_RC_HANDLE ||
rc == TPM2_RC_NV_UNINITIALIZED) /* NV index is missing, unwritten, or otherwise unusable for this policy (or: wrong authHandle/policySession). */
return log_debug_errno(SYNTHETIC_ERRNO(EREMOTE),
"NV index referenced by token is missing, unwritten, or unusable.");
return log_debug_errno(SYNTHETIC_ERRNO(EADDRNOTAVAIL),
"NV index referenced by token is missing, unwritten, or unusable, it could be for another system.");
if (rc != TSS2_RC_SUCCESS)
return log_debug_errno(SYNTHETIC_ERRNO(ENOTRECOVERABLE),
"Failed to add AuthorizeNV policy to TPM: %s",
@@ -6667,7 +6667,8 @@ int tpm2_unseal(Tpm2Context *c,
/* Returns the following errors:
*
* -EREMOTE → blob is from a different TPM, or NV index referenced by policy is unusable
* -EREMOTE → blob is from a different TPM
* -EADDRNOTAVAIL → NV index referenced by policy is missing, unwritten, or unusable
* -ENOSTR → signature JSON has no matching entry for the current PCR policy
* -EDEADLK → couldn't create primary key because authorization failure
* -ENOLCK → TPM is in dictionary lockout mode