All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] efi/tpm.c: Add missing casts
@ 2019-03-22 15:11 Vladimir 'phcoder' Serbinenko
  2019-03-25 12:09 ` Daniel Kiper
  0 siblings, 1 reply; 4+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2019-03-22 15:11 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 42 bytes --]

-- 
Regards
Vladimir 'phcoder' Serbinenko

[-- Attachment #2: 0002-efi-tpm.c-Add-missing-casts.patch --]
[-- Type: application/octet-stream, Size: 1367 bytes --]

From 9443713c3d3403a21aac9b39de4bbd097a531dd4 Mon Sep 17 00:00:00 2001
From: Vladimir Serbinenko <phcoder@gmail.com>
Date: Fri, 22 Mar 2019 16:07:47 +0100
Subject: [PATCH 2/2] efi/tpm.c: Add missing casts

---
 grub-core/commands/efi/tpm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c
index 7475fd87b..32909c192 100644
--- a/grub-core/commands/efi/tpm.c
+++ b/grub-core/commands/efi/tpm.c
@@ -245,7 +245,7 @@ grub_tpm1_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
   grub_memcpy (event->Event, description, event->EventSize);
 
   algorithm = TCG_ALG_SHA;
-  status = efi_call_7 (tpm->log_extend_event, tpm, buf, (grub_uint64_t) size,
+  status = efi_call_7 (tpm->log_extend_event, tpm, (grub_addr_t) buf, (grub_uint64_t) size,
 		       algorithm, event, &eventnum, &lastevent);
 
   switch (status)
@@ -295,7 +295,7 @@ grub_tpm2_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
     sizeof (*event) - sizeof (event->Event) + grub_strlen (description) + 1;
   grub_memcpy (event->Event, description, grub_strlen (description) + 1);
 
-  status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, buf,
+  status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (grub_addr_t) buf,
 		       (grub_uint64_t) size, event);
 
   switch (status)
-- 
2.11.0


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

* Re: [PATCH] efi/tpm.c: Add missing casts
  2019-03-22 15:11 [PATCH] efi/tpm.c: Add missing casts Vladimir 'phcoder' Serbinenko
@ 2019-03-25 12:09 ` Daniel Kiper
  2019-03-25 14:27   ` Vladimir 'phcoder' Serbinenko
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Kiper @ 2019-03-25 12:09 UTC (permalink / raw)
  To: Vladimir 'phcoder' Serbinenko; +Cc: The development of GRUB 2

On Fri, Mar 22, 2019 at 04:11:10PM +0100, Vladimir 'phcoder' Serbinenko wrote:
> From 9443713c3d3403a21aac9b39de4bbd097a531dd4 Mon Sep 17 00:00:00 2001
> From: Vladimir Serbinenko <phcoder@gmail.com>
> Date: Fri, 22 Mar 2019 16:07:47 +0100
> Subject: [PATCH 2/2] efi/tpm.c: Add missing casts

Have you seen any warnings without this patch?

> ---
>  grub-core/commands/efi/tpm.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c
> index 7475fd87b..32909c192 100644
> --- a/grub-core/commands/efi/tpm.c
> +++ b/grub-core/commands/efi/tpm.c
> @@ -245,7 +245,7 @@ grub_tpm1_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
>    grub_memcpy (event->Event, description, event->EventSize);
>
>    algorithm = TCG_ALG_SHA;
> -  status = efi_call_7 (tpm->log_extend_event, tpm, buf, (grub_uint64_t) size,
> +  status = efi_call_7 (tpm->log_extend_event, tpm, (grub_addr_t) buf, (grub_uint64_t) size,
>  		       algorithm, event, &eventnum, &lastevent);
>
>    switch (status)
> @@ -295,7 +295,7 @@ grub_tpm2_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
>      sizeof (*event) - sizeof (event->Event) + grub_strlen (description) + 1;
>    grub_memcpy (event->Event, description, grub_strlen (description) + 1);
>
> -  status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, buf,
> +  status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (grub_addr_t) buf,

Should not you use grub_efi_physical_address_t instead of grub_addr_t?

Daniel


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

* Re: [PATCH] efi/tpm.c: Add missing casts
  2019-03-25 12:09 ` Daniel Kiper
@ 2019-03-25 14:27   ` Vladimir 'phcoder' Serbinenko
  2019-03-25 17:52     ` Daniel Kiper
  0 siblings, 1 reply; 4+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2019-03-25 14:27 UTC (permalink / raw)
  To: Daniel Kiper; +Cc: The development of GRUB 2

On Mon, Mar 25, 2019 at 1:09 PM Daniel Kiper <dkiper@net-space.pl> wrote:
>
> On Fri, Mar 22, 2019 at 04:11:10PM +0100, Vladimir 'phcoder' Serbinenko wrote:
> > From 9443713c3d3403a21aac9b39de4bbd097a531dd4 Mon Sep 17 00:00:00 2001
> > From: Vladimir Serbinenko <phcoder@gmail.com>
> > Date: Fri, 22 Mar 2019 16:07:47 +0100
> > Subject: [PATCH 2/2] efi/tpm.c: Add missing casts
>
> Have you seen any warnings without this patch?
>
Yes, That we make either incompatible pointer type or integer from pointer.
> > ---
> >  grub-core/commands/efi/tpm.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c
> > index 7475fd87b..32909c192 100644
> > --- a/grub-core/commands/efi/tpm.c
> > +++ b/grub-core/commands/efi/tpm.c
> > @@ -245,7 +245,7 @@ grub_tpm1_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
> >    grub_memcpy (event->Event, description, event->EventSize);
> >
> >    algorithm = TCG_ALG_SHA;
> > -  status = efi_call_7 (tpm->log_extend_event, tpm, buf, (grub_uint64_t) size,
> > +  status = efi_call_7 (tpm->log_extend_event, tpm, (grub_addr_t) buf, (grub_uint64_t) size,
> >                      algorithm, event, &eventnum, &lastevent);
> >
> >    switch (status)
> > @@ -295,7 +295,7 @@ grub_tpm2_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
> >      sizeof (*event) - sizeof (event->Event) + grub_strlen (description) + 1;
> >    grub_memcpy (event->Event, description, grub_strlen (description) + 1);
> >
> > -  status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, buf,
> > +  status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (grub_addr_t) buf,
>
> Should not you use grub_efi_physical_address_t instead of grub_addr_t?
Nope. On 32-bit system we can cast the pointer only to 32-bit but
grub_efi_physical_address_t is 64-bit. Casting pointer directly to
64-bit create a warning. This way we have explicit cast to addr_t and
then implicit cat to efi_physical_address_t.
>
> Daniel



-- 
Regards
Vladimir 'phcoder' Serbinenko


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

* Re: [PATCH] efi/tpm.c: Add missing casts
  2019-03-25 14:27   ` Vladimir 'phcoder' Serbinenko
@ 2019-03-25 17:52     ` Daniel Kiper
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Kiper @ 2019-03-25 17:52 UTC (permalink / raw)
  To: Vladimir 'phcoder' Serbinenko; +Cc: The development of GRUB 2

On Mon, Mar 25, 2019 at 03:27:11PM +0100, Vladimir 'phcoder' Serbinenko wrote:
> On Mon, Mar 25, 2019 at 1:09 PM Daniel Kiper <dkiper@net-space.pl> wrote:
> >
> > On Fri, Mar 22, 2019 at 04:11:10PM +0100, Vladimir 'phcoder' Serbinenko wrote:
> > > From 9443713c3d3403a21aac9b39de4bbd097a531dd4 Mon Sep 17 00:00:00 2001
> > > From: Vladimir Serbinenko <phcoder@gmail.com>
> > > Date: Fri, 22 Mar 2019 16:07:47 +0100
> > > Subject: [PATCH 2/2] efi/tpm.c: Add missing casts
> >
> > Have you seen any warnings without this patch?
> >
> Yes, That we make either incompatible pointer type or integer from pointer.

Please say it in the commit message.

> > > ---
> > >  grub-core/commands/efi/tpm.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/grub-core/commands/efi/tpm.c b/grub-core/commands/efi/tpm.c
> > > index 7475fd87b..32909c192 100644
> > > --- a/grub-core/commands/efi/tpm.c
> > > +++ b/grub-core/commands/efi/tpm.c
> > > @@ -245,7 +245,7 @@ grub_tpm1_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
> > >    grub_memcpy (event->Event, description, event->EventSize);
> > >
> > >    algorithm = TCG_ALG_SHA;
> > > -  status = efi_call_7 (tpm->log_extend_event, tpm, buf, (grub_uint64_t) size,
> > > +  status = efi_call_7 (tpm->log_extend_event, tpm, (grub_addr_t) buf, (grub_uint64_t) size,
> > >                      algorithm, event, &eventnum, &lastevent);
> > >
> > >    switch (status)
> > > @@ -295,7 +295,7 @@ grub_tpm2_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
> > >      sizeof (*event) - sizeof (event->Event) + grub_strlen (description) + 1;
> > >    grub_memcpy (event->Event, description, grub_strlen (description) + 1);
> > >
> > > -  status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, buf,
> > > +  status = efi_call_5 (tpm->hash_log_extend_event, tpm, 0, (grub_addr_t) buf,
> >
> > Should not you use grub_efi_physical_address_t instead of grub_addr_t?
> Nope. On 32-bit system we can cast the pointer only to 32-bit but
> grub_efi_physical_address_t is 64-bit. Casting pointer directly to
> 64-bit create a warning. This way we have explicit cast to addr_t and
> then implicit cat to efi_physical_address_t.

OK, if you add why to the commit message then you can add
  Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


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

end of thread, other threads:[~2019-03-25 17:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-22 15:11 [PATCH] efi/tpm.c: Add missing casts Vladimir 'phcoder' Serbinenko
2019-03-25 12:09 ` Daniel Kiper
2019-03-25 14:27   ` Vladimir 'phcoder' Serbinenko
2019-03-25 17:52     ` Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.