]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
tpm: fix event_size output in tpm1_binary_bios_measurements_show
authorThorsten Blum <thorsten.blum@linux.dev>
Mon, 15 Jun 2026 12:02:05 +0000 (15:02 +0300)
committerJarkko Sakkinen <jarkko@kernel.org>
Sun, 21 Jun 2026 01:25:28 +0000 (04:25 +0300)
commit1a58f6115bfb34eabcc7de8a3a9745b219179781
tree1fb72545ac216a11508bd3d21c41bdc5271482b9
parent677042afb97ac5057e1d2900139f123bb15ba6e6
tpm: fix event_size output in tpm1_binary_bios_measurements_show

Commit 186d124f07da ("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: 186d124f07da ("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>
drivers/char/tpm/eventlog/tpm1.c