diff mbox

[1/3] vTPM: fixed the limit checking

Message ID 1430873486-25868-2-git-send-email-honclo@linux.vnet.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

Hon Ching (Vicky) Lo May 6, 2015, 12:51 a.m. UTC
Do not skip the last entry of the event log.

Signed-off-by: Hon Ching(Vicky) Lo <honclo@linux.vnet.ibm.com>
Signed-off-by: Joy Latten <jmlatten@linux.vnet.ibm.com>

Changelog:
- remove redundant code
---
 drivers/char/tpm/tpm_eventlog.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

Comments

Stefan Berger May 11, 2015, 1:02 p.m. UTC | #1
On 05/05/2015 08:51 PM, Hon Ching(Vicky) Lo wrote:
> Do not skip the last entry of the event log.
>
> Signed-off-by: Hon Ching(Vicky) Lo <honclo@linux.vnet.ibm.com>
> Signed-off-by: Joy Latten <jmlatten@linux.vnet.ibm.com>
>
> Changelog:
> - remove redundant code
> ---
>   drivers/char/tpm/tpm_eventlog.c |    5 +----
>   1 files changed, 1 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
> index 3a56a13..e77d8c1 100644
> --- a/drivers/char/tpm/tpm_eventlog.c
> +++ b/drivers/char/tpm/tpm_eventlog.c
> @@ -116,11 +116,8 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
>
>   	event = v;
>
> -	if (event->event_type == 0 && event->event_size == 0)
> -		return NULL;
> -
>   	if ((event->event_type == 0 && event->event_size == 0) ||
> -	    ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
> +	    ((v + sizeof(struct tcpa_event) + event->event_size) > limit))
>   		return NULL;
>
>   	(*pos)++;

The limit stems from log->bios_event_log_end and is calculated as follows:

  log->bios_event_log_end = log->bios_event_log + len;

The '>=' above is correct since the limit address itself is not part of 
the log anymore.

The log is the following sequence of addresses:

[log->bios_event_log ... log->bios_event_log + len - 1 ]

or

[log->bios_event_log ... log->bios_event_log + len [

with ']' meaning inclusive and '[' meaning exclusive.

     Stefan


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
Joy M. Latten May 12, 2015, 9:19 p.m. UTC | #2
Hi Stefan,

On Mon, 2015-05-11 at 09:02 -0400, Stefan Berger wrote: 
> On 05/05/2015 08:51 PM, Hon Ching(Vicky) Lo wrote:
> > Do not skip the last entry of the event log.
> >
> > Signed-off-by: Hon Ching(Vicky) Lo <honclo@linux.vnet.ibm.com>
> > Signed-off-by: Joy Latten <jmlatten@linux.vnet.ibm.com>
> >
> > Changelog:
> > - remove redundant code
> > ---
> >   drivers/char/tpm/tpm_eventlog.c |    5 +----
> >   1 files changed, 1 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
> > index 3a56a13..e77d8c1 100644
> > --- a/drivers/char/tpm/tpm_eventlog.c
> > +++ b/drivers/char/tpm/tpm_eventlog.c
> > @@ -116,11 +116,8 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
> >
> >   	event = v;
> >
> > -	if (event->event_type == 0 && event->event_size == 0)
> > -		return NULL;
> > -
> >   	if ((event->event_type == 0 && event->event_size == 0) ||
> > -	    ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
> > +	    ((v + sizeof(struct tcpa_event) + event->event_size) > limit))
> >   		return NULL;
> >
> >   	(*pos)++;
> 
> The limit stems from log->bios_event_log_end and is calculated as follows:
> 
>   log->bios_event_log_end = log->bios_event_log + len;
> 
> The '>=' above is correct since the limit address itself is not part of 
> the log anymore.
> 
> The log is the following sequence of addresses:
> 
> [log->bios_event_log ... log->bios_event_log + len - 1 ]
> 
> or
> 
> [log->bios_event_log ... log->bios_event_log + len [
> 
> with ']' meaning inclusive and '[' meaning exclusive.
> 
Thanks for pointing this out... you are correct.
We are just seeing where the spec describes this.

On powerpc(p8/powervm)) using vtpm, the last entry doesn't
get shown when ">=", so I suspect phype may be giving us
an "inclusive" len. Vicky and I will investigate this.

regards,
Joy




------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
diff mbox

Patch

diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
index 3a56a13..e77d8c1 100644
--- a/drivers/char/tpm/tpm_eventlog.c
+++ b/drivers/char/tpm/tpm_eventlog.c
@@ -116,11 +116,8 @@  static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
 
 	event = v;
 
-	if (event->event_type == 0 && event->event_size == 0)
-		return NULL;
-
 	if ((event->event_type == 0 && event->event_size == 0) ||
-	    ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
+	    ((v + sizeof(struct tcpa_event) + event->event_size) > limit))
 		return NULL;
 
 	(*pos)++;