summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJia Zhang <zhang.jia@linux.alibaba.com>2018-06-16 05:33:13 -0400
committerJia Zhang <zhang.jia@linux.alibaba.com>2018-06-16 05:33:13 -0400
commit5497078ef4ff074f717c7cd7c4aaa0089e98a710 (patch)
treeaf9a649afbb27c4b58d77d228192e279296d3ff5
parent0bb383b60a8f61df2c4e078d34294e5ef996445b (diff)
downloadmeta-secure-core-5497078ef4ff074f717c7cd7c4aaa0089e98a710.tar.gz
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>
-rw-r--r--meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools-3.0.4/0001-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch77
-rw-r--r--meta-tpm2/recipes-tpm/tpm2-tools/tpm2-tools_3.0.4.bb5
2 files changed, 81 insertions, 1 deletions
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 @@
1From cb1b28d795dd120dcc8b75fff926b0abcda06535 Mon Sep 17 00:00:00 2001
2From: Jia Zhang <zhang.jia@linux.alibaba.com>
3Date: Fri, 16 Feb 2018 20:31:58 -0500
4Subject: [PATCH] tpm2-tools: use dynamic linkage with tpm2-abrmd
5
6tpm2-abrmd has huge dependencies and they are not necessary to be involved
7in initramfs.
8
9Signed-off-by: Jia Zhang <zhang.jia@linux.alibaba.com>
10---
11 Makefile.am | 2 +-
12 lib/tcti/tpm2_tools_tcti_abrmd.c | 21 +++++++++++++++++++--
13 2 files changed, 20 insertions(+), 3 deletions(-)
14
15diff --git a/Makefile.am b/Makefile.am
16index 7ac86cd..1a8074a 100644
17--- a/Makefile.am
18+++ b/Makefile.am
19@@ -48,7 +48,7 @@ AM_LDFLAGS := $(EXTRA_LDFLAGS) $(CODE_COVERAGE_LIBS)
20
21 LDADD = \
22 $(LIB_COMMON) $(SAPI_LIBS) $(TCTI_SOCK_LIBS) $(TCTI_TABRMD_LIBS) \
23- $(TCTI_DEV_LIBS) $(CRYPTO_LIBS)
24+ $(TCTI_DEV_LIBS) $(CRYPTO_LIBS) -ldl
25
26 # keep me sorted
27 bin_PROGRAMS = \
28diff --git a/lib/tcti/tpm2_tools_tcti_abrmd.c b/lib/tcti/tpm2_tools_tcti_abrmd.c
29index 5e50288..48e0df6 100644
30--- a/lib/tcti/tpm2_tools_tcti_abrmd.c
31+++ b/lib/tcti/tpm2_tools_tcti_abrmd.c
32@@ -30,6 +30,7 @@
33 //**********************************************************************;
34 #include <inttypes.h>
35 #include <stdlib.h>
36+#include <dlfcn.h>
37 #include <tcti/tcti-tabrmd.h>
38
39 #include <sapi/tpm20.h>
40@@ -42,8 +43,24 @@ TSS2_TCTI_CONTEXT *tpm2_tools_tcti_abrmd_init(char *opts) {
41
42 UNUSED(opts);
43
44+ /*
45+ * Intend to "forget" the handle in order to make sure libtcti-tabrmd
46+ * is unloaded along with the deconstructed functions.
47+ */
48+ void *tabrmd_handle;
49+ tabrmd_handle = dlopen("libtcti-tabrmd.so.0", RTLD_LAZY);
50+ if (!tabrmd_handle) {
51+ LOG_ERR ("Unable to find out the tabrmd tcti library");
52+ return NULL;
53+ }
54+
55+ TSS2_RC (*init)(TSS2_TCTI_CONTEXT *, size_t *);
56+ init = dlsym(tabrmd_handle, "tss2_tcti_tabrmd_init");
57+ if (!init)
58+ return NULL;
59+
60 size_t size;
61- TSS2_RC rc = tss2_tcti_tabrmd_init(NULL, &size);
62+ TSS2_RC rc = init(NULL, &size);
63 if (rc != TSS2_RC_SUCCESS) {
64 LOG_ERR("Failed to get size for TABRMD TCTI context: 0x%" PRIx32, rc);
65 return NULL;
66@@ -55,7 +72,7 @@ TSS2_TCTI_CONTEXT *tpm2_tools_tcti_abrmd_init(char *opts) {
67 return NULL;
68 }
69
70- rc = tss2_tcti_tabrmd_init(tcti_ctx, &size);
71+ rc = init(tcti_ctx, &size);
72 if (rc != TSS2_RC_SUCCESS) {
73 LOG_ERR ("Failed to initialize TABRMD TCTI context: 0x%" PRIx32, rc);
74 free(tcti_ctx);
75--
761.8.3.1
77
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 @@
1include ${BPN}.inc 1include ${BPN}.inc
2 2
3SRC_URI = "https://github.com/tpm2-software/${BPN}/releases/download/${PV}/${BPN}-${PV}.tar.gz" 3SRC_URI = "\
4 https://github.com/tpm2-software/${BPN}/releases/download/${PV}/${BPN}-${PV}.tar.gz \
5 file://0001-tpm2-tools-use-dynamic-linkage-with-tpm2-abrmd.patch \
6"
4SRC_URI[md5sum] = "f7a962c6e3d2997efe8949ac7aec8283" 7SRC_URI[md5sum] = "f7a962c6e3d2997efe8949ac7aec8283"
5SRC_URI[sha256sum] = "ac05028347a9fa1da79b5d53b998193de0c3a76000badb961c3feb8b8a0e8e8e" 8SRC_URI[sha256sum] = "ac05028347a9fa1da79b5d53b998193de0c3a76000badb961c3feb8b8a0e8e8e"
6 9