From b1d63cab9cd33ea4dabaeaebc1c10251df7af82e Mon Sep 17 00:00:00 2001 From: Andreas Fuchs Date: Fri, 17 May 2024 10:01:20 +0200 Subject: [PATCH] TCTI: Separate namespaces for internal struct 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 --- src/tss2-tcti/tcti-cmd.c | 4 ++-- src/tss2-tcti/tcti-device.c | 4 ++-- src/tss2-tcti/tcti-i2c-ftdi.c | 4 ++-- src/tss2-tcti/tcti-i2c-helper.c | 4 ++-- src/tss2-tcti/tcti-libtpms.c | 4 ++-- src/tss2-tcti/tcti-mssim.c | 4 ++-- src/tss2-tcti/tcti-pcap.c | 4 ++-- src/tss2-tcti/tcti-spi-ftdi.c | 4 ++-- src/tss2-tcti/tcti-spi-helper.c | 4 ++-- src/tss2-tcti/tcti-spi-ltt2go.c | 4 ++-- src/tss2-tcti/tcti-spidev.c | 4 ++-- src/tss2-tcti/tcti-swtpm.c | 4 ++-- src/tss2-tcti/tcti-tbs.c | 4 ++-- src/tss2-tcti/tctildr.c | 4 ++-- test/fuzz/tcti/tcti-fuzzing.c | 4 ++-- 15 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/tss2-tcti/tcti-cmd.c b/src/tss2-tcti/tcti-cmd.c index 070670f09..8a3cdb741 100644 --- a/src/tss2-tcti/tcti-cmd.c +++ b/src/tss2-tcti/tcti-cmd.c @@ -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, @@ -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; } diff --git a/src/tss2-tcti/tcti-device.c b/src/tss2-tcti/tcti-device.c index bfa6a9411..3e7cd22ac 100644 --- a/src/tss2-tcti/tcti-device.c +++ b/src/tss2-tcti/tcti-device.c @@ -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.", @@ -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; } diff --git a/src/tss2-tcti/tcti-i2c-ftdi.c b/src/tss2-tcti/tcti-i2c-ftdi.c index dbeae1d30..8f53d0fae 100644 --- a/src/tss2-tcti/tcti-i2c-ftdi.c +++ b/src/tss2-tcti/tcti-i2c-ftdi.c @@ -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.", @@ -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; } diff --git a/src/tss2-tcti/tcti-i2c-helper.c b/src/tss2-tcti/tcti-i2c-helper.c index b7720d64e..68d89dbbb 100644 --- a/src/tss2-tcti/tcti-i2c-helper.c +++ b/src/tss2-tcti/tcti-i2c-helper.c @@ -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.", @@ -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; } diff --git a/src/tss2-tcti/tcti-libtpms.c b/src/tss2-tcti/tcti-libtpms.c index 5f4fcb130..925057273 100644 --- a/src/tss2-tcti/tcti-libtpms.c +++ b/src/tss2-tcti/tcti-libtpms.c @@ -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.", @@ -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; } diff --git a/src/tss2-tcti/tcti-mssim.c b/src/tss2-tcti/tcti-mssim.c index a4df730ea..5a4b66f49 100644 --- a/src/tss2-tcti/tcti-mssim.c +++ b/src/tss2-tcti/tcti-mssim.c @@ -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.", @@ -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; } diff --git a/src/tss2-tcti/tcti-pcap.c b/src/tss2-tcti/tcti-pcap.c index 8dfa6cf3b..16af1b595 100644 --- a/src/tss2-tcti/tcti-pcap.c +++ b/src/tss2-tcti/tcti-pcap.c @@ -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.", @@ -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; } diff --git a/src/tss2-tcti/tcti-spi-ftdi.c b/src/tss2-tcti/tcti-spi-ftdi.c index 5c64cd964..0fb28d470 100644 --- a/src/tss2-tcti/tcti-spi-ftdi.c +++ b/src/tss2-tcti/tcti-spi-ftdi.c @@ -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.", @@ -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; } diff --git a/src/tss2-tcti/tcti-spi-helper.c b/src/tss2-tcti/tcti-spi-helper.c index 66cdb102f..90aed947e 100644 --- a/src/tss2-tcti/tcti-spi-helper.c +++ b/src/tss2-tcti/tcti-spi-helper.c @@ -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.", @@ -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; } diff --git a/src/tss2-tcti/tcti-spi-ltt2go.c b/src/tss2-tcti/tcti-spi-ltt2go.c index 1ab4f6f0e..63f4fe1cc 100644 --- a/src/tss2-tcti/tcti-spi-ltt2go.c +++ b/src/tss2-tcti/tcti-spi-ltt2go.c @@ -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.", @@ -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; } diff --git a/src/tss2-tcti/tcti-spidev.c b/src/tss2-tcti/tcti-spidev.c index 8eb47ad33..92e896bb9 100644 --- a/src/tss2-tcti/tcti-spidev.c +++ b/src/tss2-tcti/tcti-spidev.c @@ -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.", @@ -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; } diff --git a/src/tss2-tcti/tcti-swtpm.c b/src/tss2-tcti/tcti-swtpm.c index 74a8971a0..e3b407fa8 100644 --- a/src/tss2-tcti/tcti-swtpm.c +++ b/src/tss2-tcti/tcti-swtpm.c @@ -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.", @@ -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; } diff --git a/src/tss2-tcti/tcti-tbs.c b/src/tss2-tcti/tcti-tbs.c index 2c61588f5..10fb05e1b 100644 --- a/src/tss2-tcti/tcti-tbs.c +++ b/src/tss2-tcti/tcti-tbs.c @@ -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", @@ -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; } diff --git a/src/tss2-tcti/tctildr.c b/src/tss2-tcti/tctildr.c index 1fa6b23d3..8cca7816e 100644 --- a/src/tss2-tcti/tctildr.c +++ b/src/tss2-tcti/tctildr.c @@ -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", @@ -615,5 +615,5 @@ __attribute__((weak)) const TSS2_TCTI_INFO* Tss2_Tcti_Info (void) { - return &tss2_tcti_info; + return &tss2_tctildr_info; } diff --git a/test/fuzz/tcti/tcti-fuzzing.c b/test/fuzz/tcti/tcti-fuzzing.c index 49215bf8d..b7d3e696f 100644 --- a/test/fuzz/tcti/tcti-fuzzing.c +++ b/test/fuzz/tcti/tcti-fuzzing.c @@ -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.", @@ -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; }