0013-src-security-tpm-Deal-with-zero-length-tlcl-writes.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From 6c9fe645f8444bd4586e26b545cc9dceb162f03a Mon Sep 17 00:00:00 2001
  2. From: Patrick Georgi <pgeorgi@google.com>
  3. Date: Wed, 12 May 2021 14:54:49 +0200
  4. Subject: [PATCH 13/19] src/security/tpm: Deal with zero length tlcl writes
  5. While memcpy(foo, bar, 0) should be a no-op, that's hard to prove for a
  6. compiler and so gcc 11.1 complains about the use of an uninitialized
  7. "bar" even though it's harmless in this case.
  8. Change-Id: Idbffa508c2cd68790efbc0b4ab97ae1b4d85ad51
  9. Signed-off-by: Patrick Georgi <pgeorgi@google.com>
  10. Reviewed-on: https://review.coreboot.org/c/coreboot/+/54095
  11. Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
  12. Reviewed-by: Jacob Garber <jgarber1@ualberta.ca>
  13. Reviewed-by: Angel Pons <th3fanbus@gmail.com>
  14. ---
  15. src/security/tpm/tss/tcg-1.2/tss.c | 3 ++-
  16. 1 file changed, 2 insertions(+), 1 deletion(-)
  17. diff --git a/src/security/tpm/tss/tcg-1.2/tss.c b/src/security/tpm/tss/tcg-1.2/tss.c
  18. index 8b7778ddb2..413b68193f 100644
  19. --- a/src/security/tpm/tss/tcg-1.2/tss.c
  20. +++ b/src/security/tpm/tss/tcg-1.2/tss.c
  21. @@ -215,7 +215,8 @@ uint32_t tlcl_write(uint32_t index, const void *data, uint32_t length)
  22. to_tpm_uint32(cmd.buffer + tpm_nv_write_cmd.index, index);
  23. to_tpm_uint32(cmd.buffer + tpm_nv_write_cmd.length, length);
  24. - memcpy(cmd.buffer + tpm_nv_write_cmd.data, data, length);
  25. + if (length > 0)
  26. + memcpy(cmd.buffer + tpm_nv_write_cmd.data, data, length);
  27. return tlcl_send_receive(cmd.buffer, response, sizeof(response));
  28. }
  29. --
  30. 2.25.1