[PATCH v2 4/4] tpm_eventlog.c: fix binary_bios_measurements
From: Jarkko Sakkinen
Date: Sat Feb 13 2016 - 08:47:45 EST
From: Harald Hoyer <harald@xxxxxxxxxx>
The commit 0cc698af36ff ("vTPM: support little endian guests") copied
the event, but without the event data, did an endian conversion on the
size and tried to output the event data from the copied version, which
has only have one byte of the data, resulting in garbage event data.
[jarkko.sakkinen@xxxxxxxxxxxxxxx: minor coding style fixes]
Signed-off-by: Harald Hoyer <harald@xxxxxxxxxx>
Fixes: 0cc698af36ff ("vTPM: support little endian guests")
cc: stable@xxxxxxxxxxxxxxx
---
drivers/char/tpm/tpm_eventlog.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
index bd72fb0..6011751 100644
--- a/drivers/char/tpm/tpm_eventlog.c
+++ b/drivers/char/tpm/tpm_eventlog.c
@@ -242,9 +242,15 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
temp_event.event_type = do_endian_conversion(event->event_type);
temp_event.event_size = do_endian_conversion(event->event_size);
- tempPtr = (char *)&temp_event;
+ tempPtr = (char *) &temp_event;
- for (i = 0; i < sizeof(struct tcpa_event) + temp_event.event_size; i++)
+ for (i = 0; i < sizeof(struct tcpa_event)-1 ; i++)
+ seq_putc(m, tempPtr[i]);
+
+ tempPtr = (char *) v;
+
+ for (i = sizeof(struct tcpa_event) - 1;
+ i < sizeof(struct tcpa_event) + temp_event.event_size; i++)
seq_putc(m, tempPtr[i]);
return 0;
--
2.7.0