mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
tpm: fix event_size output in tpm1_binary_bios_measurements_show
commit1a58f6115bupstream. Commit186d124f07("tpm_eventlog.c: fix binary_bios_measurements") split the output to write the endian-converted event header first and then the variable-length event data. However, the split was at sizeof(struct tcpa_event) - 1, even though event_data was a zero-length array, and later a flexible array member, both of which already excluded the event data. Therefore, the current code writes the first three bytes of event_size from the endian-converted header and then the last byte from the raw header, which can emit a corrupted event_size on PPC64, where do_endian_conversion() maps to be32_to_cpu(). Split one byte later to write the full endian-converted header first, followed by the variable-length event->event_data. Fixes:186d124f07("tpm_eventlog.c: fix binary_bios_measurements") Cc: stable@vger.kernel.org # v5.10+ Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
e9c90756f1
commit
0084fd985f
@@ -236,12 +236,12 @@ static int tpm1_binary_bios_measurements_show(struct seq_file *m, void *v)
|
||||
|
||||
temp_ptr = (char *) &temp_event;
|
||||
|
||||
for (i = 0; i < (sizeof(struct tcpa_event) - 1) ; i++)
|
||||
for (i = 0; i < sizeof(struct tcpa_event); i++)
|
||||
seq_putc(m, temp_ptr[i]);
|
||||
|
||||
temp_ptr = (char *) v;
|
||||
|
||||
for (i = (sizeof(struct tcpa_event) - 1);
|
||||
for (i = sizeof(struct tcpa_event);
|
||||
i < (sizeof(struct tcpa_event) + temp_event.event_size); i++)
|
||||
seq_putc(m, temp_ptr[i]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user