From 5497078ef4ff074f717c7cd7c4aaa0089e98a710 Mon Sep 17 00:00:00 2001 From: Jia Zhang Date: Sat, 16 Jun 2018 05:33:13 -0400 Subject: tpm2-tools: refresh the dlopen patch for 3.0.4 The latest git version has updated to use dl interface to load the library of tpm2-abrmd, instead of linking it on compilation. Signed-off-by: Jia Zhang --- ...tools-use-dynamic-linkage-with-tpm2-abrmd.patch | 77 ++++++++++++++++++++++ .../recipes-tpm/tpm2-tools/tpm2-tools_3.0.4.bb | 5 +- 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools-3.0.4/0001-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch diff --git a/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools-3.0.4/0001-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch b/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools-3.0.4/0001-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch new file mode 100644 index 0000000..b44d588 --- /dev/null +++ b/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools-3.0.4/0001-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch @@ -0,0 +1,77 @@ +From cb1b28d795dd120dcc8b75fff926b0abcda06535 Mon Sep 17 00:00:00 2001 +From: Jia Zhang +Date: Fri, 16 Feb 2018 20:31:58 -0500 +Subject: [PATCH] tpm2-tools: use dynamic linkage with tpm2-abrmd + +tpm2-abrmd has huge dependencies and they are not necessary to be involved +in initramfs. + +Signed-off-by: Jia Zhang +--- + Makefile.am | 2 +- + lib/tcti/tpm2_tools_tcti_abrmd.c | 21 +++++++++++++++++++-- + 2 files changed, 20 insertions(+), 3 deletions(-) + +diff --git a/Makefile.am b/Makefile.am +index 7ac86cd..1a8074a 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -48,7 +48,7 @@ AM_LDFLAGS := $(EXTRA_LDFLAGS) $(CODE_COVERAGE_LIBS) + + LDADD = \ + $(LIB_COMMON) $(SAPI_LIBS) $(TCTI_SOCK_LIBS) $(TCTI_TABRMD_LIBS) \ +- $(TCTI_DEV_LIBS) $(CRYPTO_LIBS) ++ $(TCTI_DEV_LIBS) $(CRYPTO_LIBS) -ldl + + # keep me sorted + bin_PROGRAMS = \ +diff --git a/lib/tcti/tpm2_tools_tcti_abrmd.c b/lib/tcti/tpm2_tools_tcti_abrmd.c +index 5e50288..48e0df6 100644 +--- a/lib/tcti/tpm2_tools_tcti_abrmd.c ++++ b/lib/tcti/tpm2_tools_tcti_abrmd.c +@@ -30,6 +30,7 @@ + //**********************************************************************; + #include + #include ++#include + #include + + #include +@@ -42,8 +43,24 @@ TSS2_TCTI_CONTEXT *tpm2_tools_tcti_abrmd_init(char *opts) { + + UNUSED(opts); + ++ /* ++ * Intend to "forget" the handle in order to make sure libtcti-tabrmd ++ * is unloaded along with the deconstructed functions. ++ */ ++ void *tabrmd_handle; ++ tabrmd_handle = dlopen("libtcti-tabrmd.so.0", RTLD_LAZY); ++ if (!tabrmd_handle) { ++ LOG_ERR ("Unable to find out the tabrmd tcti library"); ++ return NULL; ++ } ++ ++ TSS2_RC (*init)(TSS2_TCTI_CONTEXT *, size_t *); ++ init = dlsym(tabrmd_handle, "tss2_tcti_tabrmd_init"); ++ if (!init) ++ return NULL; ++ + size_t size; +- TSS2_RC rc = tss2_tcti_tabrmd_init(NULL, &size); ++ TSS2_RC rc = init(NULL, &size); + if (rc != TSS2_RC_SUCCESS) { + LOG_ERR("Failed to get size for TABRMD TCTI context: 0x%" PRIx32, rc); + return NULL; +@@ -55,7 +72,7 @@ TSS2_TCTI_CONTEXT *tpm2_tools_tcti_abrmd_init(char *opts) { + return NULL; + } + +- rc = tss2_tcti_tabrmd_init(tcti_ctx, &size); ++ rc = init(tcti_ctx, &size); + if (rc != TSS2_RC_SUCCESS) { + LOG_ERR ("Failed to initialize TABRMD TCTI context: 0x%" PRIx32, rc); + free(tcti_ctx); +-- +1.8.3.1 + diff --git a/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_3.0.4.bb b/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_3.0.4.bb index f4850a7..d9851dc 100644 --- a/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_3.0.4.bb +++ b/meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_3.0.4.bb @@ -1,6 +1,9 @@ include ${BPN}.inc -SRC_URI = "https://github.com/tpm2-software/${BPN}/releases/download/${PV}/${BPN}-${PV}.tar.gz" +SRC_URI = "\ + https://github.com/tpm2-software/${BPN}/releases/download/${PV}/${BPN}-${PV}.tar.gz \ + file://0001-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch \ +" SRC_URI[md5sum] = "f7a962c6e3d2997efe8949ac7aec8283" SRC_URI[sha256sum] = "ac05028347a9fa1da79b5d53b998193de0c3a76000badb961c3feb8b8a0e8e8e" -- cgit v1.2.3-54-g00ecf