Skip to contentSkip to conversation

stubdom/vtpm: fix memcmp in TPM_ChangeAuthAsymFinish

PATCH In review Olaf Hering 3 participants 3 messages Jun 18, 2018 – Jun 25, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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=]

---
 stubdom/Makefile                            |  1 +
 stubdom/vtpm_TPM_ChangeAuthAsymFinish.patch | 12 ++++++++++++
 2 files changed, 13 insertions(+)
 create mode 100644 stubdom/vtpm_TPM_ChangeAuthAsymFinish.patch
stubdom/Makefile +1 -0
index cad672f59d..d39d16786b 100644
@@ -230,6 +230,7 @@ tpm_emulator-$(XEN_TARGET_ARCH): tpm_emulator-$(TPMEMU_VERSION).tar.gz
 	patch -d $@ -p1 < vtpm-cmake-Wextra.patch
 	patch -d $@ -p1 < vtpm-implicit-fallthrough.patch
 	patch -d $@ -p1 < vtpm-cmake_glob_sort.patch
+	patch -d $@ -p1 < vtpm_TPM_ChangeAuthAsymFinish.patch
 	mkdir $@/build
 	cd $@/build; CC=${CC} $(CMAKE) .. -DCMAKE_C_FLAGS:STRING="-std=c99 -DTPM_NO_EXTERN $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-declaration-after-statement"
 	touch $@
stubdom/vtpm_TPM_ChangeAuthAsymFinish.patch new file +12 -0
new file mode 100644
index 0000000000..10b89a4c3a
@@ -0,0 +1,12 @@
+error: 'memcmp' reading 20 bytes from a region of size 8 [-Werror=stringop-overflow=]
+--- a/tpm/tpm_deprecated.c
++++ b/tpm/tpm_deprecated.c
+@@ -434,7 +434,7 @@ TPM_RESULT TPM_ChangeAuthAsymFinish(TPM_
+   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;
+   }

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v1 1/1
#1 lore raw

Olaf Hering, le lun. 18 juin 2018 14:55:36 +0200, a ecrit:

Quoted 4 lines

gcc8 spotted this error:
error: 'memcmp' reading 20 bytes from a region of size 8 [-Werror=stringop-overflow=]

Indeed!

Quoted 37 lines
---
 stubdom/Makefile                            |  1 +
 stubdom/vtpm_TPM_ChangeAuthAsymFinish.patch | 12 ++++++++++++
 2 files changed, 13 insertions(+)
 create mode 100644 stubdom/vtpm_TPM_ChangeAuthAsymFinish.patch
stubdom/Makefile +1 -0
index cad672f59d..d39d16786b 100644
@@ -230,6 +230,7 @@ tpm_emulator-$(XEN_TARGET_ARCH): tpm_emulator-$(TPMEMU_VERSION).tar.gz
 	patch -d $@ -p1 < vtpm-cmake-Wextra.patch
 	patch -d $@ -p1 < vtpm-implicit-fallthrough.patch
 	patch -d $@ -p1 < vtpm-cmake_glob_sort.patch
+	patch -d $@ -p1 < vtpm_TPM_ChangeAuthAsymFinish.patch
 	mkdir $@/build
 	cd $@/build; CC=${CC} $(CMAKE) .. -DCMAKE_C_FLAGS:STRING="-std=c99 -DTPM_NO_EXTERN $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -Wno-declaration-after-statement"
 	touch $@
stubdom/vtpm_TPM_ChangeAuthAsymFinish.patch new file +12 -0
new file mode 100644
index 0000000000..10b89a4c3a
@@ -0,0 +1,12 @@
+error: 'memcmp' reading 20 bytes from a region of size 8 [-Werror=stringop-overflow=]
+--- a/tpm/tpm_deprecated.c
++++ b/tpm/tpm_deprecated.c
+@@ -434,7 +434,7 @@ TPM_RESULT TPM_ChangeAuthAsymFinish(TPM_
+   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;
+   }
Signature · 15 lines
Samuel
...
<rv_> et Ctrl alt F2 pour aller sous console
<rv_> mais c koi pour passer d'un bureau a un autre !
<rv_> au fait c koi le raccourci pour passer d'un bureau a un autre 'question stupide"
<cycyx> ça dépend du window manager et de ta conf
<Firebird> ce qui fonctionne toujours c'est CTRL-ALT-BCKSP
-:- SignOff rv_: #linuxfr (Read error: EOF from client)
-:- rv_ [[email protected]] has joined #linuxfr
<rv_> Firebird: MEURT...

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
#2 lore raw
Quoted 9 lines · Samuel Thibault

Olaf Hering, le lun. 18 juin 2018 14:55:36 +0200, a ecrit:

Quoted 4 lines

gcc8 spotted this error:
error: 'memcmp' reading 20 bytes from a region of size 8 [-Werror=stringop-overflow=]

Indeed!

Thanks, I will apply this patch once the tree is open.

Wei.

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel