diff options
author | Lennart Poettering <lennart@poettering.net> | 2021-09-28 12:11:53 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2021-09-28 16:47:08 +0200 |
commit | 1641c2b1123617f7be249bb7f2b2c408defb3b96 (patch) | |
tree | ad86570a38da6ad0c3e821798d657da6e5ca6e68 /src/cryptenroll | |
parent | core: implement RuntimeMaxDeltaSec directive (diff) | |
download | systemd-1641c2b1123617f7be249bb7f2b2c408defb3b96.tar.xz systemd-1641c2b1123617f7be249bb7f2b2c408defb3b96.zip |
cryptsetup: handle more gracefully if "keyslots" LUKS2 JSON header field is invalid
The field is not owned by us (even though is in our JSON objects) but by
the LUKS2 spec. Hence let's handle this a bit more gracefully: let's not
get confused by it, just warn and skip over it.
Fixes: #20847
Diffstat (limited to 'src/cryptenroll')
-rw-r--r-- | src/cryptenroll/cryptenroll-tpm2.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cryptenroll/cryptenroll-tpm2.c b/src/cryptenroll/cryptenroll-tpm2.c index 23deeed272..801014af11 100644 --- a/src/cryptenroll/cryptenroll-tpm2.c +++ b/src/cryptenroll/cryptenroll-tpm2.c @@ -34,8 +34,12 @@ static int search_policy_hash( return log_error_errno(r, "Failed to read JSON token data off disk: %m"); keyslot = cryptsetup_get_keyslot_from_token(v); - if (keyslot < 0) - return log_error_errno(keyslot, "Failed to determine keyslot of JSON token: %m"); + if (keyslot < 0) { + /* Handle parsing errors of the keyslots field gracefully, since it's not 'owned' by + * us, but by the LUKS2 spec */ + log_warning_errno(keyslot, "Failed to determine keyslot of JSON token %i, skipping: %m", token); + continue; + } w = json_variant_by_key(v, "tpm2-policy-hash"); if (!w || !json_variant_is_string(w)) |