You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 16, 2020. It is now read-only.
libsapi and libtcti functions require us to provided pre-allocated TSS2_TCTI_CONTEXT and TSS2_SYS_CONTEXT memory block from the caller side. And their finalize-functions will leave the caller's pre-allocated memory storage unreleased as designed.
Note: Old stable 1.x branch of TSS currently does not support Tss2_Tcti_Finalize() yet. We need to define it ourselves. The following code implements Tss2_Tcti_Finalize() though an inline function.
/* Micro Tss2_Tcti_Finalize was introduced since 2017-11-20 commit: https://github.com/tpm2-software/tpm2-tss/commit/930b5c1f8feeb13bec29a36c8a5753fb15e27cf6
* Formerly, the micro was named in lower case tss2_tcti_finalize in sapi/tss2_tcti.h
* The Camel_Case macro "Tss2_Tcti_Finalize()" should be used in the future instead of the deprecated lower_case one.
* Here is a patch for branch 1.x of tpm2-tss
*/
#ifndef Tss2_Tcti_Finalize
inline void Tss2_Tcti_Finalize(TSS2_TCTI_CONTEXT *tcti_ctx) {
TSS2_TCTI_FINALIZE_FCN finalize_func_ptr = NULL;
if (!tcti_ctx || TSS2_TCTI_VERSION(tcti_ctx) < 1) {
return;
}
finalize_func_ptr = TSS2_TCTI_FINALIZE(tcti_ctx);
if (!finalize_func_ptr) {
return;
}
finalize_func_ptr(tcti_ctx);
}
#endif
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Memory leaks after every "C_OpenSession()/C_CloseSession()" or "session_init()/session_close()" invocation pair:
tpm2-pk11/src/pk11.c
Lines 66 to 76 in 801f8e6
tpm2-pk11/src/pk11.c
Lines 77 to 82 in 801f8e6
Reason:
In
session_init()
,tcti_ctx
andsession->context
is assigned withcalloc()
:tpm2-pk11/src/sessions.c
Line 75 in 3b93c1e
tpm2-pk11/src/sessions.c
Line 108 in 3b93c1e
Currently after session_close()/Tss2_Sys_Finalize() is called, both the TSS2_TCTI_CONTEXT and TSS2_SYS_CONTEXT will never get released.
tpm2-pk11/src/sessions.c
Lines 135 to 139 in 3b93c1e
see: https://github.com/tpm2-software/tpm2-tss/blob/master/sysapi/sysapi/Tss2_Sys_Finalize.c
libsapi and libtcti functions require us to provided pre-allocated TSS2_TCTI_CONTEXT and TSS2_SYS_CONTEXT memory block from the caller side. And their finalize-functions will leave the caller's pre-allocated memory storage unreleased as designed.
Standard APIs
Tss2_Sys_Initialize(sysContext, size, tctiContext, &abi_version)
Tss2_Sys_Finalize(sysContext)
Tss2_Tcti_Device_Init()
,Tss2_Tcti_Mssim_Init()
,Tss2_Tcti_Tabrmd_Init()
Tss2_Tcti_Finalize(tctiContext)
Legacy APIs
tss2_tcti_finalize(tctiContext)
InitSocketTcti(tctiContext, &size, &socket_conf, 0)
InitDeviceTcti(tctiContext, &size, &conf)
tss2_tcti_tabrmd_init(tctiContext, &size)
The text was updated successfully, but these errors were encountered: