[meta-virtualization] [PATCH 3/7] tpm-emulator: apply patch to fix memcmp defect found by gcc

christopher.w.clark at gmail.com christopher.w.clark at gmail.com
Wed Jul 18 15:03:44 PDT 2018


From: Christopher Clark <christopher.w.clark at gmail.com>

| tpm_emulator-0.7.4/tpm/tpm_deprecated.c:437:7:
| error: 'memcmp' reading 20 bytes from a region of size 8
| [-Werror=stringop-overflow=]

|    if (memcmp(&b1, &newAuthLink, sizeof(TPM_HMAC))) {
|        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Apply patch from Xen: vtpm_TPM_ChangeAuthAsymFinish.patch

Signed-off-by: Christopher Clark <christopher.clark6 at baesystems.com>
---
Please use my gmail address for any correspondence to me.

 .../xen/files/vtpm_TPM_ChangeAuthAsymFinish.patch  | 28 ++++++++++++++++++++++
 recipes-extended/xen/tpm-emulator_0.7.4.bb         |  1 +
 2 files changed, 29 insertions(+)
 create mode 100644 recipes-extended/xen/files/vtpm_TPM_ChangeAuthAsymFinish.patch

diff --git a/recipes-extended/xen/files/vtpm_TPM_ChangeAuthAsymFinish.patch b/recipes-extended/xen/files/vtpm_TPM_ChangeAuthAsymFinish.patch
new file mode 100644
index 0000000..aefca28
--- /dev/null
+++ b/recipes-extended/xen/files/vtpm_TPM_ChangeAuthAsymFinish.patch
@@ -0,0 +1,28 @@
+Patch derived from below Xen changeset.
+Signed-off-by: Christopher Clark <christopher.clark6 at baesystems.com>
+
+commit 22bf5be3237cb482a2ffd772ffd20ce37285eebf
+Author: Olaf Hering <olaf at aepfle.de>
+Date:   Mon Jun 18 14:55:36 2018 +0200
+
+stubdom/vtpm: fix memcmp in TPM_ChangeAuthAsymFinish
+
+gcc8 spotted this error:
+error: 'memcmp' reading 20 bytes from a region of size 8 [-Werror=stringop-overflow=]
+
+Signed-off-by: Olaf Hering <olaf at aepfle.de>
+Reviewed-by: Samuel Thibault <samuel.thibault at ens-lyon.org>
+
+diff --git a/tpm/tpm_deprecated.c b/tpm/tpm_deprecated.c
+index c362b56..4c49f54 100644
+--- a/tpm/tpm_deprecated.c
++++ b/tpm/tpm_deprecated.c
+@@ -434,7 +434,7 @@ TPM_RESULT TPM_ChangeAuthAsymFinish(TPM_KEY_HANDLE parentHandle,
+   tpm_hmac_final(&hmac_ctx, b1.digest);
+   /* 6. The TPM SHALL compare b1 with newAuthLink. The TPM SHALL
+         indicate a failure if the values do not match. */
+-  if (memcmp(&b1, &newAuthLink, sizeof(TPM_HMAC))) {
++  if (memcmp(&b1, newAuthLink, sizeof(TPM_HMAC))) {
+     debug("TPM_ChangeAuthAsymFinish(): newAuthLink value does not match.");
+     return TPM_FAIL;
+   }
diff --git a/recipes-extended/xen/tpm-emulator_0.7.4.bb b/recipes-extended/xen/tpm-emulator_0.7.4.bb
index f626929..96a4090 100644
--- a/recipes-extended/xen/tpm-emulator_0.7.4.bb
+++ b/recipes-extended/xen/tpm-emulator_0.7.4.bb
@@ -16,6 +16,7 @@ SRC_URI = "\
     file://vtpm-deepquote-anyloc.patch \
     file://vtpm-cmake-Wextra.patch \
     file://vtpm-implicit-fallthrough.patch \
+    file://vtpm_TPM_ChangeAuthAsymFinish.patch \
 "
 SRC_URI[tpm-emulator.md5sum] = "e26becb8a6a2b6695f6b3e8097593db8"
 SRC_URI[tpm-emulator.sha256sum] = "4e48ea0d83dd9441cc1af04ab18cd6c961b9fa54d5cbf2c2feee038988dea459"
-- 
2.7.4



More information about the meta-virtualization mailing list