mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 2/2] tpm: bios log parsing fixes
@ 2006-05-26 14:43 Seiji Munetoh
  2006-05-26 14:43 ` Kylene Jo Hall
  0 siblings, 1 reply; 6+ messages in thread
From: Seiji Munetoh @ 2006-05-26 14:43 UTC (permalink / raw)
  To: linux-kernel; +Cc: kjhall, akpm, tpmdd-devel

This patch changes the binary output format to actual ACPI TCPA log
structure since the current format does not contain all event-data
information that need to verify the PCRs in TPM. 
tpm_binary_bios_measurements_show() uses get_event_name() to convert the
binary event-data to ascii format, and puts them as binary. However, to
verify the PCRs, the event-data must be a actual binary event-data used
by SHA1 calc. in BIOS. 

So, I think actual ACPI TCPA log is good for this binary output format. 
That way, any userland tools easily parse this data with reference to
TCG PC specification.

Signed-off-by: Seiji Munetoh <seiji.munetoh@gmail.com>
---

--- linux-2.6.17-rc4/drivers/char/tpm/tpm_bios.c	2006-05-16
09:33:06.000000000 +0900
+++ linux-2.6.17-rc4-tpm/drivers/char/tpm/tpm_bios.c	2006-05-24
07:11:44.000000000 +0900
@@ -275,53 +284,13 @@ static int get_event_name(char *dest, st
 
 static int tpm_binary_bios_measurements_show(struct seq_file *m, void
*v)
 {
-
-	char *eventname;
-	char data[4];
-	u32 help;
-	int i, len;
 	struct tcpa_event *event = (struct tcpa_event *) v;
-	unsigned char *event_entry =
-	    (unsigned char *) (v + sizeof(struct tcpa_event));
-
-	eventname = kmalloc(MAX_TEXT_EVENT, GFP_KERNEL);
-	if (!eventname) {
-		printk(KERN_ERR "%s: ERROR - No Memory for event name\n ",
-		       __func__);
-		return -ENOMEM;
-	}
-
-	/* 1st: PCR used is in little-endian format (4 bytes) */
-	help = le32_to_cpu(event->pcr_index);
-	memcpy(data, &help, 4);
-	for (i = 0; i < 4; i++)
-		seq_putc(m, data[i]);
-
-	/* 2nd: SHA1 (20 bytes) */
-	for (i = 0; i < 20; i++)
-		seq_putc(m, event->pcr_value[i]);
+	char *data = (char *) v;
+	int i;
 
-	/* 3rd: event type identifier (4 bytes) */
-	help = le32_to_cpu(event->event_type);
-	memcpy(data, &help, 4);
-	for (i = 0; i < 4; i++)
+	for (i = 0;i < sizeof(struct tcpa_event) + event->event_size; i++)
 		seq_putc(m, data[i]);
 
-	len = 0;
-
-	len += get_event_name(eventname, event, event_entry);
-
-	/* 4th:  filename <= 255 + \'0' delimiter */
-	if (len > TCG_EVENT_NAME_LEN_MAX)
-		len = TCG_EVENT_NAME_LEN_MAX;
-
-	for (i = 0; i < len; i++)
-		seq_putc(m, eventname[i]);
-
-	/* 5th: delimiter */
-	seq_putc(m, '\0');
-
-	kfree(eventname);
 	return 0;
 }
 




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] tpm: bios log parsing fixes
  2006-05-26 14:43 [PATCH 2/2] tpm: bios log parsing fixes Seiji Munetoh
@ 2006-05-26 14:43 ` Kylene Jo Hall
  0 siblings, 0 replies; 6+ messages in thread
From: Kylene Jo Hall @ 2006-05-26 14:43 UTC (permalink / raw)
  To: Seiji Munetoh; +Cc: linux-kernel, akpm

Ack'ed-by: Kylene Hall <kjhall@us.ibm.com>

On Fri, 2006-05-26 at 23:43 +0900, Seiji Munetoh wrote:
> This patch changes the binary output format to actual ACPI TCPA log
> structure since the current format does not contain all event-data
> information that need to verify the PCRs in TPM. 
> tpm_binary_bios_measurements_show() uses get_event_name() to convert the
> binary event-data to ascii format, and puts them as binary. However, to
> verify the PCRs, the event-data must be a actual binary event-data used
> by SHA1 calc. in BIOS. 
> 
> So, I think actual ACPI TCPA log is good for this binary output format. 
> That way, any userland tools easily parse this data with reference to
> TCG PC specification.
> 
> Signed-off-by: Seiji Munetoh <seiji.munetoh@gmail.com>
> ---
> 
> --- linux-2.6.17-rc4/drivers/char/tpm/tpm_bios.c	2006-05-16
> 09:33:06.000000000 +0900
> +++ linux-2.6.17-rc4-tpm/drivers/char/tpm/tpm_bios.c	2006-05-24
> 07:11:44.000000000 +0900
> @@ -275,53 +284,13 @@ static int get_event_name(char *dest, st
>  
>  static int tpm_binary_bios_measurements_show(struct seq_file *m, void
> *v)
>  {
> -
> -	char *eventname;
> -	char data[4];
> -	u32 help;
> -	int i, len;
>  	struct tcpa_event *event = (struct tcpa_event *) v;
> -	unsigned char *event_entry =
> -	    (unsigned char *) (v + sizeof(struct tcpa_event));
> -
> -	eventname = kmalloc(MAX_TEXT_EVENT, GFP_KERNEL);
> -	if (!eventname) {
> -		printk(KERN_ERR "%s: ERROR - No Memory for event name\n ",
> -		       __func__);
> -		return -ENOMEM;
> -	}
> -
> -	/* 1st: PCR used is in little-endian format (4 bytes) */
> -	help = le32_to_cpu(event->pcr_index);
> -	memcpy(data, &help, 4);
> -	for (i = 0; i < 4; i++)
> -		seq_putc(m, data[i]);
> -
> -	/* 2nd: SHA1 (20 bytes) */
> -	for (i = 0; i < 20; i++)
> -		seq_putc(m, event->pcr_value[i]);
> +	char *data = (char *) v;
> +	int i;
>  
> -	/* 3rd: event type identifier (4 bytes) */
> -	help = le32_to_cpu(event->event_type);
> -	memcpy(data, &help, 4);
> -	for (i = 0; i < 4; i++)
> +	for (i = 0;i < sizeof(struct tcpa_event) + event->event_size; i++)
>  		seq_putc(m, data[i]);
>  
> -	len = 0;
> -
> -	len += get_event_name(eventname, event, event_entry);
> -
> -	/* 4th:  filename <= 255 + \'0' delimiter */
> -	if (len > TCG_EVENT_NAME_LEN_MAX)
> -		len = TCG_EVENT_NAME_LEN_MAX;
> -
> -	for (i = 0; i < len; i++)
> -		seq_putc(m, eventname[i]);
> -
> -	/* 5th: delimiter */
> -	seq_putc(m, '\0');
> -
> -	kfree(eventname);
>  	return 0;
>  }
>  
> 
> 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] tpm: bios log parsing fixes
  2006-05-18 23:57 ` Alexey Dobriyan
@ 2006-05-22  0:26   ` Seiji Munetoh
  0 siblings, 0 replies; 6+ messages in thread
From: Seiji Munetoh @ 2006-05-22  0:26 UTC (permalink / raw)
  To: Alexey Dobriyan; +Cc: linux-kernel, kjhall, tpmdd-devel

2006/5/19, Alexey Dobriyan <adobriyan@gmail.com>:
> On Fri, May 19, 2006 at 08:29:07AM +0900, Seiji Munetoh wrote:
> > This patch fixes the BINARY output format to actual ACPI TCPA log
> > structure for any userland tool easily parse the binary data with
> > reference to TCG PC specification.
> Do you realize that you break backward compatibility? What was wrong
> with old format?

Yes I do, The problem is  the binary output use get_event_name() to convert the
eventdata to ascii format. and the get_event_name() does not support all
eventdata types.Thus userspace application could not get the eventdata which
required to verify the PCRs in TPM.

I think actual ACPI log data is good for the binary output rather than current
unique binary format. It seems we are doing unnecessary transformation.

>
> > --- linux-2.6.17-rc4/drivers/char/tpm/tpm_bios.c
> > +++ linux-2.6.17-rc4-tpm/drivers/char/tpm/tpm_bios.c
> > @@ -275,53 +285,13 @@ static int get_event_name(char *dest, st
> >
> >  static int tpm_binary_bios_measurements_show(struct seq_file *m, void
> > *v)
> >  {
> > -
> > -     char *eventname;
> > -     char data[4];
> > -     u32 help;
> > -     int i, len;
> >       struct tcpa_event *event = (struct tcpa_event *) v;
> > -     unsigned char *event_entry =
> > -         (unsigned char *) (v + sizeof(struct tcpa_event));
> > -
> > -     eventname = kmalloc(MAX_TEXT_EVENT, GFP_KERNEL);
> > -     if (!eventname) {
> > -             printk(KERN_ERR "%s: ERROR - No Memory for event name\n ",
> > -                    __func__);
> > -             return -ENOMEM;
> > -     }
> > -
> > -     /* 1st: PCR used is in little-endian format (4 bytes) */
> > -     help = le32_to_cpu(event->pcr_index);
> > -     memcpy(data, &help, 4);
> > -     for (i = 0; i < 4; i++)
> > -             seq_putc(m, data[i]);
> > -

> > -     /* 2nd: SHA1 (20 bytes) */
> > -     for (i = 0; i < 20; i++)
> > -             seq_putc(m, event->pcr_value[i]);
> > +     char *data = (char *) v;
> > +     int i;
> >
> > -     /* 3rd: event type identifier (4 bytes) */
> > -     help = le32_to_cpu(event->event_type);
> > -     memcpy(data, &help, 4);
> > -     for (i = 0; i < 4; i++)
> > +     for (i = 0;i < sizeof(struct tcpa_event) + event->event_size; i++)
> >               seq_putc(m, data[i]);
> >
> > -     len = 0;
> > -
> > -     len += get_event_name(eventname, event, event_entry);
> > -
> > -     /* 4th:  filename <= 255 + \'0' delimiter */
> > -     if (len > TCG_EVENT_NAME_LEN_MAX)
> > -             len = TCG_EVENT_NAME_LEN_MAX;
> > -
> > -     for (i = 0; i < len; i++)
> > -             seq_putc(m, eventname[i]);
> > -
> > -     /* 5th: delimiter */
> > -     seq_putc(m, '\0');
> > -
> > -     kfree(eventname);
> >       return 0;
> >  }
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] tpm: bios log parsing fixes
  2006-05-18 23:29 Seiji Munetoh
  2006-05-18 23:57 ` Alexey Dobriyan
@ 2006-05-19  1:18 ` Kylene Jo Hall
  1 sibling, 0 replies; 6+ messages in thread
From: Kylene Jo Hall @ 2006-05-19  1:18 UTC (permalink / raw)
  To: Seiji Munetoh; +Cc: linux-kernel, TPM Device Driver List

Ack'ed by: Kylene Hall <kjhall@us.ibm.com>

On Fri, 2006-05-19 at 08:29 +0900, Seiji Munetoh wrote:
> This patch fixes the BINARY output format to actual ACPI TCPA log
> structure for any userland tool easily parse the binary data with
> reference to TCG PC specification.
> 
> Signed-off-by: Seiji Munetoh <seiji.munetoh@gmail.com>
> --- linux-2.6.17-rc4/drivers/char/tpm/tpm_bios.c	2006-05-16
> 09:33:06.000000000 +0900
> +++ linux-2.6.17-rc4-tpm/drivers/char/tpm/tpm_bios.c	2006-05-19
> 08:12:30.000000000 +0900
> @@ -275,53 +285,13 @@ static int get_event_name(char *dest, st
>  
>  static int tpm_binary_bios_measurements_show(struct seq_file *m, void
> *v)
>  {
> -
> -	char *eventname;
> -	char data[4];
> -	u32 help;
> -	int i, len;
>  	struct tcpa_event *event = (struct tcpa_event *) v;
> -	unsigned char *event_entry =
> -	    (unsigned char *) (v + sizeof(struct tcpa_event));
> -
> -	eventname = kmalloc(MAX_TEXT_EVENT, GFP_KERNEL);
> -	if (!eventname) {
> -		printk(KERN_ERR "%s: ERROR - No Memory for event name\n ",
> -		       __func__);
> -		return -ENOMEM;
> -	}
> -
> -	/* 1st: PCR used is in little-endian format (4 bytes) */
> -	help = le32_to_cpu(event->pcr_index);
> -	memcpy(data, &help, 4);
> -	for (i = 0; i < 4; i++)
> -		seq_putc(m, data[i]);
> -
> -	/* 2nd: SHA1 (20 bytes) */
> -	for (i = 0; i < 20; i++)
> -		seq_putc(m, event->pcr_value[i]);
> +	char *data = (char *) v;
> +	int i;
>  
> -	/* 3rd: event type identifier (4 bytes) */
> -	help = le32_to_cpu(event->event_type);
> -	memcpy(data, &help, 4);
> -	for (i = 0; i < 4; i++)
> +	for (i = 0;i < sizeof(struct tcpa_event) + event->event_size; i++)
>  		seq_putc(m, data[i]);
>  
> -	len = 0;
> -
> -	len += get_event_name(eventname, event, event_entry);
> -
> -	/* 4th:  filename <= 255 + \'0' delimiter */
> -	if (len > TCG_EVENT_NAME_LEN_MAX)
> -		len = TCG_EVENT_NAME_LEN_MAX;
> -
> -	for (i = 0; i < len; i++)
> -		seq_putc(m, eventname[i]);
> -
> -	/* 5th: delimiter */
> -	seq_putc(m, '\0');
> -
> -	kfree(eventname);
>  	return 0;
>  }
>  
> 
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] tpm: bios log parsing fixes
  2006-05-18 23:29 Seiji Munetoh
@ 2006-05-18 23:57 ` Alexey Dobriyan
  2006-05-22  0:26   ` Seiji Munetoh
  2006-05-19  1:18 ` Kylene Jo Hall
  1 sibling, 1 reply; 6+ messages in thread
From: Alexey Dobriyan @ 2006-05-18 23:57 UTC (permalink / raw)
  To: Seiji Munetoh; +Cc: linux-kernel, kjhall, tpmdd-devel

On Fri, May 19, 2006 at 08:29:07AM +0900, Seiji Munetoh wrote:
> This patch fixes the BINARY output format to actual ACPI TCPA log
> structure for any userland tool easily parse the binary data with
> reference to TCG PC specification.

Do you realize that you break backward compatibility? What was wrong
with old format?

> --- linux-2.6.17-rc4/drivers/char/tpm/tpm_bios.c
> +++ linux-2.6.17-rc4-tpm/drivers/char/tpm/tpm_bios.c
> @@ -275,53 +285,13 @@ static int get_event_name(char *dest, st
>  
>  static int tpm_binary_bios_measurements_show(struct seq_file *m, void
> *v)
>  {
> -
> -	char *eventname;
> -	char data[4];
> -	u32 help;
> -	int i, len;
>  	struct tcpa_event *event = (struct tcpa_event *) v;
> -	unsigned char *event_entry =
> -	    (unsigned char *) (v + sizeof(struct tcpa_event));
> -
> -	eventname = kmalloc(MAX_TEXT_EVENT, GFP_KERNEL);
> -	if (!eventname) {
> -		printk(KERN_ERR "%s: ERROR - No Memory for event name\n ",
> -		       __func__);
> -		return -ENOMEM;
> -	}
> -
> -	/* 1st: PCR used is in little-endian format (4 bytes) */
> -	help = le32_to_cpu(event->pcr_index);
> -	memcpy(data, &help, 4);
> -	for (i = 0; i < 4; i++)
> -		seq_putc(m, data[i]);
> -
> -	/* 2nd: SHA1 (20 bytes) */
> -	for (i = 0; i < 20; i++)
> -		seq_putc(m, event->pcr_value[i]);
> +	char *data = (char *) v;
> +	int i;
>  
> -	/* 3rd: event type identifier (4 bytes) */
> -	help = le32_to_cpu(event->event_type);
> -	memcpy(data, &help, 4);
> -	for (i = 0; i < 4; i++)
> +	for (i = 0;i < sizeof(struct tcpa_event) + event->event_size; i++)
>  		seq_putc(m, data[i]);
>  
> -	len = 0;
> -
> -	len += get_event_name(eventname, event, event_entry);
> -
> -	/* 4th:  filename <= 255 + \'0' delimiter */
> -	if (len > TCG_EVENT_NAME_LEN_MAX)
> -		len = TCG_EVENT_NAME_LEN_MAX;
> -
> -	for (i = 0; i < len; i++)
> -		seq_putc(m, eventname[i]);
> -
> -	/* 5th: delimiter */
> -	seq_putc(m, '\0');
> -
> -	kfree(eventname);
>  	return 0;
>  }


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/2] tpm: bios log parsing fixes
@ 2006-05-18 23:29 Seiji Munetoh
  2006-05-18 23:57 ` Alexey Dobriyan
  2006-05-19  1:18 ` Kylene Jo Hall
  0 siblings, 2 replies; 6+ messages in thread
From: Seiji Munetoh @ 2006-05-18 23:29 UTC (permalink / raw)
  To: linux-kernel; +Cc: kjhall, tpmdd-devel

This patch fixes the BINARY output format to actual ACPI TCPA log
structure for any userland tool easily parse the binary data with
reference to TCG PC specification.

Signed-off-by: Seiji Munetoh <seiji.munetoh@gmail.com>
--- linux-2.6.17-rc4/drivers/char/tpm/tpm_bios.c	2006-05-16
09:33:06.000000000 +0900
+++ linux-2.6.17-rc4-tpm/drivers/char/tpm/tpm_bios.c	2006-05-19
08:12:30.000000000 +0900
@@ -275,53 +285,13 @@ static int get_event_name(char *dest, st
 
 static int tpm_binary_bios_measurements_show(struct seq_file *m, void
*v)
 {
-
-	char *eventname;
-	char data[4];
-	u32 help;
-	int i, len;
 	struct tcpa_event *event = (struct tcpa_event *) v;
-	unsigned char *event_entry =
-	    (unsigned char *) (v + sizeof(struct tcpa_event));
-
-	eventname = kmalloc(MAX_TEXT_EVENT, GFP_KERNEL);
-	if (!eventname) {
-		printk(KERN_ERR "%s: ERROR - No Memory for event name\n ",
-		       __func__);
-		return -ENOMEM;
-	}
-
-	/* 1st: PCR used is in little-endian format (4 bytes) */
-	help = le32_to_cpu(event->pcr_index);
-	memcpy(data, &help, 4);
-	for (i = 0; i < 4; i++)
-		seq_putc(m, data[i]);
-
-	/* 2nd: SHA1 (20 bytes) */
-	for (i = 0; i < 20; i++)
-		seq_putc(m, event->pcr_value[i]);
+	char *data = (char *) v;
+	int i;
 
-	/* 3rd: event type identifier (4 bytes) */
-	help = le32_to_cpu(event->event_type);
-	memcpy(data, &help, 4);
-	for (i = 0; i < 4; i++)
+	for (i = 0;i < sizeof(struct tcpa_event) + event->event_size; i++)
 		seq_putc(m, data[i]);
 
-	len = 0;
-
-	len += get_event_name(eventname, event, event_entry);
-
-	/* 4th:  filename <= 255 + \'0' delimiter */
-	if (len > TCG_EVENT_NAME_LEN_MAX)
-		len = TCG_EVENT_NAME_LEN_MAX;
-
-	for (i = 0; i < len; i++)
-		seq_putc(m, eventname[i]);
-
-	/* 5th: delimiter */
-	seq_putc(m, '\0');
-
-	kfree(eventname);
 	return 0;
 }
 



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-05-26 14:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-26 14:43 [PATCH 2/2] tpm: bios log parsing fixes Seiji Munetoh
2006-05-26 14:43 ` Kylene Jo Hall
  -- strict thread matches above, loose matches on Subject: below --
2006-05-18 23:29 Seiji Munetoh
2006-05-18 23:57 ` Alexey Dobriyan
2006-05-22  0:26   ` Seiji Munetoh
2006-05-19  1:18 ` Kylene Jo Hall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®