diff mbox series

[2/2] tpm/eventlog/tpm1: Fix off-by-1 when reading binary_bios_measurements

Message ID 1546759399-45360-2-git-send-email-zhang.jia@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series [1/2] tpm/eventlog/tpm1: Simplify walking over *pos measurements | expand

Commit Message

Jia Zhang Jan. 6, 2019, 7:23 a.m. UTC
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.

Fix: 55a82ab("tpm: add bios measurement log")
Signed-off-by: Jia Zhang <zhang.jia@linux.alibaba.com>
---
 drivers/char/tpm/eventlog/tpm1.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Jarkko Sakkinen Jan. 10, 2019, 5:36 p.m. UTC | #1
On Sun, Jan 06, 2019 at 03:23:19PM +0800, Jia Zhang wrote:
> 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.
> 
> Fix: 55a82ab("tpm: add bios measurement log")

Fixes:

/Jarkko
diff mbox series

Patch

diff --git a/drivers/char/tpm/eventlog/tpm1.c b/drivers/char/tpm/eventlog/tpm1.c
index 4cf8303..bfdff92 100644
--- a/drivers/char/tpm/eventlog/tpm1.c
+++ b/drivers/char/tpm/eventlog/tpm1.c
@@ -88,7 +88,7 @@  static void *tpm1_bios_measurements_start(struct seq_file *m, loff_t *pos)
 		event = addr;
 
 		/* check if current entry is valid */
-		if (addr + sizeof(struct tcpa_event) >= limit)
+		if (addr + sizeof(struct tcpa_event) > limit)
 			return NULL;
 
 		converted_event_size =
@@ -98,7 +98,7 @@  static void *tpm1_bios_measurements_start(struct seq_file *m, loff_t *pos)
 
 		if (((converted_event_type == 0) && (converted_event_size == 0))
 		    || ((addr + sizeof(struct tcpa_event) + converted_event_size)
-			>= limit))
+			> limit))
 			return NULL;
 
 		if (i++ == *pos)
@@ -125,7 +125,7 @@  static void *tpm1_bios_measurements_next(struct seq_file *m, void *v,
 	v += sizeof(struct tcpa_event) + converted_event_size;
 
 	/* now check if current entry is valid */
-	if ((v + sizeof(struct tcpa_event)) >= limit)
+	if ((v + sizeof(struct tcpa_event)) > limit)
 		return NULL;
 
 	event = v;
@@ -134,7 +134,7 @@  static void *tpm1_bios_measurements_next(struct seq_file *m, void *v,
 	converted_event_type = do_endian_conversion(event->event_type);
 
 	if (((converted_event_type == 0) && (converted_event_size == 0)) ||
-	    ((v + sizeof(struct tcpa_event) + converted_event_size) >= limit))
+	    ((v + sizeof(struct tcpa_event) + converted_event_size) > limit))
 		return NULL;
 
 	(*pos)++;