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:
@@ -31,7 +31,7 @@ static int log_debug_open_error(struct crypt_device *cd, int token, int r) {
|
||||
(void) crypt_log_debug_errno(cd, r, "Token %d: no matching TPM2 token data found.", token);
|
||||
return -EPERM;
|
||||
}
|
||||
if (IN_SET(r, -EREMCHG, -EREMOTE)) {
|
||||
if (IN_SET(r, -EREMCHG, -EREMOTE, -EADDRNOTAVAIL)) {
|
||||
/* Remap as above. Note: For now without -EUCLEAN because currently the only error it
|
||||
* reports won't be solved by moving to another token. */
|
||||
(void) crypt_log_debug_errno(cd, r, "Token %d: TPM policy does not match current system state, skipping.", token);
|
||||
|
||||
@@ -112,7 +112,9 @@ int acquire_luks2_key(
|
||||
srk,
|
||||
ret_decrypted_key);
|
||||
if (r == -EREMOTE)
|
||||
return log_warning_errno(r, "TPM key integrity check failed or NV index unusable. Key enrolled in superblock most likely does not belong to this TPM.");
|
||||
return log_warning_errno(r, "TPM key integrity check failed. Key enrolled in superblock most likely does not belong to this TPM.");
|
||||
if (r == -EADDRNOTAVAIL)
|
||||
return log_warning_errno(r, "NV index referenced by token is missing, unwritten, or unusable, it could be for another system.");
|
||||
if (r == -EILSEQ)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ENOANO), "Bad PIN."); /* cryptsetup docs say we should return ENOANO on bad PIN */
|
||||
if (r == -ENOLCK)
|
||||
|
||||
Reference in New Issue
Block a user