Skip to content

Commit af166a8

Browse files
jiazhang0uudiin
authored andcommitted
tpm: Fix off-by-one when reading binary_bios_measurements
commit 64494d3 upstream It is unable to read the entry when it is the only one in binary_bios_measurements: 00000000 00 00 00 00 08 00 00 00 c4 2f ed ad 26 82 00 cb 00000010 1d 15 f9 78 41 c3 44 e7 9d ae 33 20 00 00 00 00 00000020 This is obviously a firmware problem on my linux machine: Manufacturer: Inspur Product Name: SA5212M4 Version: 01 However, binary_bios_measurements should return it any way, rather than nothing, after all its content is completely valid. Fixes: 55a82ab ("tpm: add bios measurement log") Signed-off-by: Jia Zhang <zhang.jia@linux.alibaba.com> Reviewd-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> Reviewed-by: Jia Zhang <zhang.jia@linux.alibaba.com>
1 parent 659d95b commit af166a8

File tree

1 file changed

+4
-4
lines changed
  • drivers/char/tpm/eventlog

1 file changed

+4
-4
lines changed

drivers/char/tpm/eventlog/tpm1.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static void *tpm1_bios_measurements_start(struct seq_file *m, loff_t *pos)
8888
event = addr;
8989

9090
/* check if current entry is valid */
91-
if (addr + sizeof(struct tcpa_event) >= limit)
91+
if (addr + sizeof(struct tcpa_event) > limit)
9292
return NULL;
9393

9494
converted_event_size =
@@ -98,7 +98,7 @@ static void *tpm1_bios_measurements_start(struct seq_file *m, loff_t *pos)
9898

9999
if (((converted_event_type == 0) && (converted_event_size == 0))
100100
|| ((addr + sizeof(struct tcpa_event) + converted_event_size)
101-
>= limit))
101+
> limit))
102102
return NULL;
103103

104104
if (i++ == *pos)
@@ -125,7 +125,7 @@ static void *tpm1_bios_measurements_next(struct seq_file *m, void *v,
125125
v += sizeof(struct tcpa_event) + converted_event_size;
126126

127127
/* now check if current entry is valid */
128-
if ((v + sizeof(struct tcpa_event)) >= limit)
128+
if ((v + sizeof(struct tcpa_event)) > limit)
129129
return NULL;
130130

131131
event = v;
@@ -134,7 +134,7 @@ static void *tpm1_bios_measurements_next(struct seq_file *m, void *v,
134134
converted_event_type = do_endian_conversion(event->event_type);
135135

136136
if (((converted_event_type == 0) && (converted_event_size == 0)) ||
137-
((v + sizeof(struct tcpa_event) + converted_event_size) >= limit))
137+
((v + sizeof(struct tcpa_event) + converted_event_size) > limit))
138138
return NULL;
139139

140140
(*pos)++;

0 commit comments

Comments
 (0)