mirror of
https://github.com/jiazhang0/meta-secure-core.git
synced 2026-07-16 20:56:58 +00:00
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 <zhang.jia@linux.alibaba.com>
This commit is contained in:
+77
@@ -0,0 +1,77 @@
|
|||||||
|
From cb1b28d795dd120dcc8b75fff926b0abcda06535 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jia Zhang <zhang.jia@linux.alibaba.com>
|
||||||
|
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 <zhang.jia@linux.alibaba.com>
|
||||||
|
---
|
||||||
|
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 <inttypes.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
+#include <dlfcn.h>
|
||||||
|
#include <tcti/tcti-tabrmd.h>
|
||||||
|
|
||||||
|
#include <sapi/tpm20.h>
|
||||||
|
@@ -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
|
||||||
|
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
include ${BPN}.inc
|
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[md5sum] = "f7a962c6e3d2997efe8949ac7aec8283"
|
||||||
SRC_URI[sha256sum] = "ac05028347a9fa1da79b5d53b998193de0c3a76000badb961c3feb8b8a0e8e8e"
|
SRC_URI[sha256sum] = "ac05028347a9fa1da79b5d53b998193de0c3a76000badb961c3feb8b8a0e8e8e"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user