Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tpm : more verbose error reporting when policy check fails #3315

Merged
merged 3 commits into from
Jul 11, 2023

Conversation

shjala
Copy link
Member

@shjala shjala commented Jul 5, 2023

When EVE fails to unseal the vault due to policy check failure, it reports a generic error. This changes makes the error more verbose by finding the mismatching PCR(s) and report it.

Before this changes we would get :
UnsealWithSession failed: session 1, error code 0x1d : a policy check failed

Now for example if indexes 1, 7 and 8 are not matching the original value, it reports :
UnsealWithSession failed: session 1, error code 0x1d : a policy check failed, possibly mismatching PCR indexes [1 7 8]


second commit, makes the errors more informative and easier to follow in the logs.

@shjala shjala requested review from eriknordmark and rvs as code owners July 5, 2023 12:56
@shjala shjala force-pushed the tpm-error-handling branch from 5eef527 to 038d6f8 Compare July 5, 2023 14:11
Copy link
Contributor

@rouming rouming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

@shjala shjala requested a review from rouming July 6, 2023 10:02
Copy link
Contributor

@rouming rouming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack

@shjala shjala force-pushed the tpm-error-handling branch 4 times, most recently from c567553 to 473f9e3 Compare July 6, 2023 12:02
@shjala shjala changed the title tpm : more verbose error reporting when policy check failed tpm : more verbose error reporting when policy check fails Jul 6, 2023
@shjala shjala force-pushed the tpm-error-handling branch 2 times, most recently from 65b126e to 473f9e3 Compare July 7, 2023 08:38
shjala added 2 commits July 10, 2023 07:42
When EVE fails to unseal the vault due to policy check failure,
it reports a generic error. This changes makes the error more verbose by
finding the mismatching PCR(s) and report it.

Signed-off-by: Shahriyar Jalayeri <shahriyar@zededa.com>
Signed-off-by: Shahriyar Jalayeri <shahriyar@zededa.com>
@shjala shjala force-pushed the tpm-error-handling branch 5 times, most recently from 5cfd364 to d3d58eb Compare July 10, 2023 10:01
@shjala shjala requested a review from eriknordmark July 10, 2023 10:21
Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@rene rene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shjala, please, fix the yetus error so we can make a full pass on this file.

// TPM is enabled. Check if defaultVault directory exists, if not set vaultconfig
tpmKeyOnlyMode := checkAndPublishVaultConfig(&ctx)
handler.SetHandlerOptions(vault.HandlerOptions{TpmKeyOnlyMode: tpmKeyOnlyMode})
}

if tpmEnabled {
Copy link
Contributor

@rene rene Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about integrate these messages to the if above, so we don't have another redundant check here....

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get rid of it intentionally because these are two separate tasks, one is configuring and the other is setup, I thought there might be added some intermediary stages in between in the two in future, and having the "SetupDefaultVault" log in the configuration part and then having the log for intermediary stage after it (which should go before setup) might cause confusion when reading logs.

what do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I got it, thanks, just let as it is...

Use WriteRename to be resilient against sudden crash/poweroff,
it will create a tmp file, writes to and does a atomic rename.

This commit also fixes some mindless  yetus complains on using %w
instead of %v.

Signed-off-by: Shahriyar Jalayeri <shahriyar@zededa.com>
@shjala shjala force-pushed the tpm-error-handling branch from d3d58eb to feeb41a Compare July 11, 2023 15:02
Comment on lines +239 to +240
t.Errorf("OpenTPM failed with err: %v", err)
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this the same as:

Suggested change
t.Errorf("OpenTPM failed with err: %v", err)
return
t.Fatalf("OpenTPM failed with err: %v", err)

Copy link
Member Author

@shjala shjala Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is, but all the are tests in this file are written like that, I thought it might be intentional (catching/parsing errors in build or something), so I just followed the pattern.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, fine

Copy link
Contributor

@rene rene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eriknordmark eriknordmark merged commit b96ecfa into lf-edge:master Jul 11, 2023
@shjala
Copy link
Member Author

shjala commented Jul 13, 2023

@eriknordmark @rouming should I backport this to lts?

@rouming
Copy link
Contributor

rouming commented Jul 13, 2023

@shjala we try to port only bugfixes, but I know how that can be painful to debug the PCR mismatch issues, so I would say yes. Does it cleanly apply to the 8.12 and 9.4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants