Skip to content

Commit

Permalink
TCTI: Separate namespaces for internal struct
Browse files Browse the repository at this point in the history
Some (dynamic) linkers seam to resolve internal symbols against
the loading library in a dlopen() instead of its local symbols.
Namely a tss2_tcti_info symbol ref of e.g. tcti-device would resolve
against the symbol of tctildr.
We protect against such situations by separating the names.

Signed-off-by: Andreas Fuchs <andreas.fuchs@infineon.com>
  • Loading branch information
AndreasFuchsTPM committed May 23, 2024
1 parent 7543041 commit b1d63ca
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/tss2-tcti/tcti-cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ TSS2_RC Tss2_Tcti_Cmd_Init (TSS2_TCTI_CONTEXT *tctiContext, size_t *size,
}

/* public info structure */
const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tcti_cmd_info = {
.version = TCTI_VERSION,
.name = TCTI_CMD_NAME,
.description = TCTI_CMD_DESCRIPTION,
Expand All @@ -633,5 +633,5 @@ const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO*
Tss2_Tcti_Info (void)
{
return &tss2_tcti_info;
return &tss2_tcti_cmd_info;
}
4 changes: 2 additions & 2 deletions src/tss2-tcti/tcti-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ Tss2_Tcti_Device_Init (
return TSS2_RC_SUCCESS;
}

const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tcti_device_info = {
.version = TCTI_VERSION,
.name = "tcti-device",
.description = "TCTI module for communication with Linux kernel interface.",
Expand All @@ -542,5 +542,5 @@ const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO*
Tss2_Tcti_Info (void)
{
return &tss2_tcti_info;
return &tss2_tcti_device_info;
}
4 changes: 2 additions & 2 deletions src/tss2-tcti/tcti-i2c-ftdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ Tss2_Tcti_I2c_Ftdi_Init (TSS2_TCTI_CONTEXT* tcti_context, size_t* size, const ch
return Tss2_Tcti_I2c_Helper_Init (tcti_context, size, &tcti_platform);
}

const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tcti_i2c_ftdi_info = {
.version = TCTI_VERSION,
.name = "tcti-i2c-ftdi",
.description = "TCTI for communicating with TPM through the USB-FTDI-I2C converter.",
Expand All @@ -291,5 +291,5 @@ const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO *
Tss2_Tcti_Info (void)
{
return &tss2_tcti_info;
return &tss2_tcti_i2c_ftdi_info;
}
4 changes: 2 additions & 2 deletions src/tss2-tcti/tcti-i2c-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ TSS2_RC Tss2_Tcti_I2c_Helper_Init (TSS2_TCTI_CONTEXT* tcti_context, size_t* size
return TSS2_RC_SUCCESS;
}

static const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tcti_i2c_helper_info = {
.version = TCTI_VERSION,
.name = "tcti-i2c-helper",
.description = "Platform independent TCTI for communication with TPMs over I2C.",
Expand All @@ -861,5 +861,5 @@ static const TSS2_TCTI_INFO tss2_tcti_info = {

const TSS2_TCTI_INFO* Tss2_Tcti_Info (void)
{
return &tss2_tcti_info;
return &tss2_tcti_i2c_helper_info;
}
4 changes: 2 additions & 2 deletions src/tss2-tcti/tcti-libtpms.c
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ Tss2_Tcti_Libtpms_Init(
}

/* public info structure */
const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tcti_libtpms_info = {
.version = TCTI_VERSION,
.name = "tcti-libtpms",
.description = "TCTI module for communication with the libtpms library.",
Expand All @@ -891,5 +891,5 @@ const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO *
Tss2_Tcti_Info(void)
{
return &tss2_tcti_info;
return &tss2_tcti_libtpms_info;
}
4 changes: 2 additions & 2 deletions src/tss2-tcti/tcti-mssim.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ Tss2_Tcti_Mssim_Init (
}

/* public info structure */
const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tcti_mssim_info = {
.version = TCTI_VERSION,
.name = "tcti-socket",
.description = "TCTI module for communication with the Microsoft TPM2 Simulator.",
Expand All @@ -677,5 +677,5 @@ const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO*
Tss2_Tcti_Info (void)
{
return &tss2_tcti_info;
return &tss2_tcti_mssim_info;
}
4 changes: 2 additions & 2 deletions src/tss2-tcti/tcti-pcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ Tss2_Tcti_Pcap_Init (
}

/* public info structure */
const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tcti_pcap_info = {
.version = TCTI_VERSION,
.name = "tcti-pcap",
.description = "TCTI module for logging TPM commands in pcapng format.",
Expand All @@ -297,5 +297,5 @@ const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO*
Tss2_Tcti_Info (void)
{
return &tss2_tcti_info;
return &tss2_tcti_pcap_info;
}
4 changes: 2 additions & 2 deletions src/tss2-tcti/tcti-spi-ftdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ Tss2_Tcti_Spi_Ftdi_Init (TSS2_TCTI_CONTEXT* tcti_context, size_t* size, const ch
return Tss2_Tcti_Spi_Helper_Init (tcti_context, size, &tcti_platform);
}

const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tcti_spi_ftdi_info = {
.version = TCTI_VERSION,
.name = "tcti-spi-ftdi",
.description = "TCTI for communicating with TPM through the USB-FTDI-SPI converter.",
Expand All @@ -199,5 +199,5 @@ const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO *
Tss2_Tcti_Info (void)
{
return &tss2_tcti_info;
return &tss2_tcti_spi_ftdi_info;
}
4 changes: 2 additions & 2 deletions src/tss2-tcti/tcti-spi-helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,7 @@ TSS2_RC Tss2_Tcti_Spi_Helper_Init (TSS2_TCTI_CONTEXT* tcti_context, size_t* size
return TSS2_RC_SUCCESS;
}

static const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tcti_spi_helper_info = {
.version = TCTI_VERSION,
.name = "tcti-spi-helper",
.description = "Platform independent TCTI for communication with TPMs over SPI.",
Expand All @@ -782,5 +782,5 @@ static const TSS2_TCTI_INFO tss2_tcti_info = {

const TSS2_TCTI_INFO* Tss2_Tcti_Info (void)
{
return &tss2_tcti_info;
return &tss2_tcti_spi_helper_info;
}
4 changes: 2 additions & 2 deletions src/tss2-tcti/tcti-spi-ltt2go.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ Tss2_Tcti_Spi_Ltt2go_Init (TSS2_TCTI_CONTEXT* tcti_context, size_t* size, const
return Tss2_Tcti_Spi_Helper_Init (tcti_context, size, &tcti_platform);
}

const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tcti_ltt2go_info = {
.version = TCTI_VERSION,
.name = "tcti-spi-ltt2go",
.description = "TCTI for communicating with LetsTrust-TPM2Go.",
Expand All @@ -325,5 +325,5 @@ const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO *
Tss2_Tcti_Info (void)
{
return &tss2_tcti_info;
return &tss2_tcti_ltt2go_info;
}
4 changes: 2 additions & 2 deletions src/tss2-tcti/tcti-spidev.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ Tss2_Tcti_Spidev_Init (TSS2_TCTI_CONTEXT* tcti_context, size_t* size, const char
return Tss2_Tcti_Spi_Helper_Init (tcti_context, size, &platform);
}

const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tcti_spidev_info = {
.version = TCTI_VERSION,
.name = "tcti-spidev",
.description = "TCTI for communicating with a TPM via spidev.",
Expand All @@ -208,5 +208,5 @@ const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO *
Tss2_Tcti_Info (void)
{
return &tss2_tcti_info;
return &tss2_tcti_spidev_info;
}
4 changes: 2 additions & 2 deletions src/tss2-tcti/tcti-swtpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ Tss2_Tcti_Swtpm_Init (
}

/* public info structure */
const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tcti_swtpm_info = {
.version = TCTI_VERSION,
.name = "tcti-swtpm",
.description = "TCTI module for communication with the swtpm.",
Expand All @@ -650,5 +650,5 @@ const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO*
Tss2_Tcti_Info (void)
{
return &tss2_tcti_info;
return &tss2_tcti_swtpm_info;
}
4 changes: 2 additions & 2 deletions src/tss2-tcti/tcti-tbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ Tss2_Tcti_Tbs_Init (
return TSS2_RC_SUCCESS;
}

const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tcti_tbs_info = {
.version = TCTI_VERSION,
.name = "tcti-tbs",
.description = "TCTI module for communication with Windows TPM Base Services",
Expand All @@ -326,5 +326,5 @@ const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO*
Tss2_Tcti_Info (void)
{
return &tss2_tcti_info;
return &tss2_tcti_tbs_info;
}
4 changes: 2 additions & 2 deletions src/tss2-tcti/tctildr.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ TSS2_RC Tss2_Tcti_TctiLdr_Init (TSS2_TCTI_CONTEXT *tctiContext, size_t *size,
}

__attribute__((weak))
const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tctildr_info = {
.version = TCTI_VERSION,
.name = "tctildr",
.description = "TCTI module for dynamically loading other TCTI modules",
Expand Down Expand Up @@ -615,5 +615,5 @@ __attribute__((weak))
const TSS2_TCTI_INFO*
Tss2_Tcti_Info (void)
{
return &tss2_tcti_info;
return &tss2_tctildr_info;
}
4 changes: 2 additions & 2 deletions test/fuzz/tcti/tcti-fuzzing.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ Tss2_Tcti_Fuzzing_Init (
}

/* public info structure */
const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO tss2_tcti_fuzzing_info = {
.version = TCTI_VERSION,
.name = "tcti-fuzzing",
.description = "TCTI module for fuzzing the System API.",
Expand All @@ -276,5 +276,5 @@ const TSS2_TCTI_INFO tss2_tcti_info = {
const TSS2_TCTI_INFO*
Tss2_Tcti_Info (void)
{
return &tss2_tcti_info;
return &tss2_tcti_fuzzing_info;
}

0 comments on commit b1d63ca

Please sign in to comment.