Commit 186d124f authored by Harald Hoyer's avatar Harald Hoyer Committed by Jarkko Sakkinen

tpm_eventlog.c: fix binary_bios_measurements

The commit 0cc698af ("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@linux.intel.com: fixed minor coding style issues and
 renamed the local variable tempPtr as temp_ptr now that there is an
 excuse to do this.]
Signed-off-by: default avatarHarald Hoyer <harald@redhat.com>
Fixes: 0cc698af ("vTPM: support little endian guests")
Reviewed-by: default avatarJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
cc: stable@vger.kernel.org
parent 4f3b193d
...@@ -232,7 +232,7 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v) ...@@ -232,7 +232,7 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
{ {
struct tcpa_event *event = v; struct tcpa_event *event = v;
struct tcpa_event temp_event; struct tcpa_event temp_event;
char *tempPtr; char *temp_ptr;
int i; int i;
memcpy(&temp_event, event, sizeof(struct tcpa_event)); memcpy(&temp_event, event, sizeof(struct tcpa_event));
...@@ -242,10 +242,16 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v) ...@@ -242,10 +242,16 @@ 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_type = do_endian_conversion(event->event_type);
temp_event.event_size = do_endian_conversion(event->event_size); temp_event.event_size = do_endian_conversion(event->event_size);
tempPtr = (char *)&temp_event; temp_ptr = (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]); seq_putc(m, temp_ptr[i]);
temp_ptr = (char *) v;
for (i = (sizeof(struct tcpa_event) - 1);
i < (sizeof(struct tcpa_event) + temp_event.event_size); i++)
seq_putc(m, temp_ptr[i]);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment