tpm2-tss icon indicating copy to clipboard operation
tpm2-tss copied to clipboard

out of session handles when decrypting

Open marincovic opened this issue 1 year ago • 5 comments

Hello Team,

I am getting the following issue

Error while starting HMAC Session. The error code is: 2309. The decoded value is: tpm:warn(2.0): out of session handles

I have not yet seen this issue but from what I understand the HMAC sessions that I am making are causing the system to have a lot of hanging memory. Is there a way to tell the TPM to release the session handles? It does not happen on all devices but just a few (1 out of 10 or might be less)

BR// Marin

marincovic avatar Aug 23 '23 11:08 marincovic

If the tpm2 tools are installed you can list the session with tpm2_getcap, (-l lists the possibilities). The sessions can be flushed with tpm2_flushcontext (-l for loaded session, -s for saved sessions).

JuergenReppSIT avatar Aug 24 '23 16:08 JuergenReppSIT

And if I am using TPM-TSS I can just use the Esys_FlushContext to clear the HMAC session?

marincovic avatar Aug 25 '23 06:08 marincovic

And if I am using TPM-TSS I can just use the Esys_FlushContext to clear the HMAC session?

yes Esys_FlushContext can be used for this purpose. Or you could use the continue session flag to signal that the session context can be cleared.

JuergenReppSIT avatar Aug 25 '23 08:08 JuergenReppSIT

And how would I set that flag? I am using the Esys_FlushContext but I would like to have some redundancy so that I do not block other tools using the TPM.

BR// Marin

marincovic avatar Aug 29 '23 06:08 marincovic

The continue session flag can be set with Esys_TRSess_SetAttributes (flag TPMA_SESSION_CONTINUESESSION). The default for this flag is clear. So if a command with a session is executed successfully the session will be flushed automatically. But the session will not be flushed if an error did occur in the command.

JuergenReppSIT avatar Aug 29 '23 09:08 JuergenReppSIT