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

esys: close TR handle for input persistent handle in EvictControl_Finish #2667

Merged
merged 1 commit into from
Jul 26, 2023

Conversation

rshearman
Copy link
Contributor

The TSS ESAPI spec (1.00 rev 14) says:

If the ESYS_TR object on input was a persistent object, [the ESYS_TR
output] parameter will not return a ESYS_TR object but instead will
return ESYS_TR_NULL. Also the metadata in the ESYS_CONTEXT regarding
the ESYS_TR object will be removed and the ESYS_TR object will be
marked as invalid.

However, currently although the output parameter is set to ESYS_TR_NONE, the input ESYS_TR object isn't closed. Other than the obvious leak, this can cause an error when Esys_TR_FromTPMPublic is called twice, with the object having been recreated with different public data and persisted with Esys_EvictControl in between, since Esys_TR_FromTPMPublic now verifies that the public data hasn't changed for the ESYS_TR object (which it now has).

Address this by closing the input ESYS_TR handle in the case that it referred to a persistent object.

The TSS ESAPI spec (1.00 rev 14) says:

> If the ESYS_TR object on input was a persistent object, [the ESYS_TR
> output] parameter will not return a ESYS_TR object but instead will
> return ESYS_TR_NULL. Also the metadata in the ESYS_CONTEXT regarding
> the ESYS_TR object will be removed and the ESYS_TR object will be
> marked as invalid.

However, currently although the output parameter is set to
ESYS_TR_NONE, the input ESYS_TR object isn't closed. Other than the
obvious leak, this can cause an error when Esys_TR_FromTPMPublic is
called twice, with the object having been recreated with different
public data and persisted with Esys_EvictControl in between, since
Esys_TR_FromTPMPublic now verifies that the public data hasn't changed
for the ESYS_TR object (which it now has).

Address this by closing the input ESYS_TR handle in the case that it
referred to a persistent object.

Signed-off-by: Rob Shearman <rob@graphiant.com>
Copy link
Member

@JuergenReppSIT JuergenReppSIT left a comment

Choose a reason for hiding this comment

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

Thank you for fixing this bug. I will cherry pick it for 3.2.x

@JuergenReppSIT JuergenReppSIT merged commit 86949f7 into tpm2-software:master Jul 26, 2023
26 checks passed
@rshearman rshearman deleted the evictcontrol-leak branch July 26, 2023 20:03
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