Skip to content

Conversation

@chrisccoulson
Copy link
Collaborator

@chrisccoulson chrisccoulson commented Jan 22, 2026

This makes the tpm2 platform return the
PlatformHandlerErrorInvalidRoleParams error type when a PCR policy is
invalid, so that the KeyData API returns the appropriate
InvalidKeyDataRoleParamsErrorand the ActivateState contains the new
invalid-role-params keyslot error enum. The existing
PlatformHandlerErrorIncompatibleRole is only returned in the case where
the PCR policy is not authorized for the current configuration, but is
otherwise valid.

Fixes: FR-12368

This makes the tpm2 platform return the
PlatformHandlerErrorInvalidRoleParams error type when a PCR policy is
invalid, so that the KeyData API returns the appropriate
InvalidKeyDataRoleParamsError and the ActivateState contains the new
invalid-role-params keyslot error enum. The existing
PlatformHandlerErrorIncompatibleRole is only returned in the case where
the PCR policy is not authorized for the current configuration, but is
otherwise valid.

Fixes: FR-12368
@chrisccoulson chrisccoulson force-pushed the tpm2-support-invalid-role-params-error branch from cf90789 to 56cf0a2 Compare January 22, 2026 16:03
Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

question

return nil, ErrTPMLockout
case tpm2.IsTPMSessionError(err, tpm2.ErrorPolicyFail, tpm2.CommandUnseal, 1):
return nil, &PCRPolicyDataError{errors.New("the authorization policy check failed during unsealing")}
return nil, InvalidKeyDataError{"the authorization policy check failed during unsealing"}
Copy link
Collaborator

Choose a reason for hiding this comment

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

does the description in errors.go for PCRPolicyDataError or any of the other involved errors need to change now?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

They don't as we're still returning the same errors. It's still returning PCRPolicyDataError in both the cases where the PCR policy metadata is valid but just needs updating and where the PCR policy metadata is actually invalid - the code in tpm2/platform.go distinguishes between the 2 cases with a special error value that it wraps in the first case (errPcrPolicyNotAuthorized). InvalidKeyDataError still has the same meaning - the change here is because this specific error condition won't be corrected by recreating the PCR policy during repair.

Copy link
Collaborator

@pedronis pedronis left a comment

Choose a reason for hiding this comment

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

+1

@chrisccoulson chrisccoulson merged commit 99e0bbd into canonical:master Jan 26, 2026
2 checks passed
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.

2 participants