All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] tpm: use kmemdup() to copy the event log
@ 2018-02-20 11:41 Jarkko Sakkinen
  2018-02-20 14:26 ` Javier Martinez Canillas
  0 siblings, 1 reply; 3+ messages in thread
From: Jarkko Sakkinen @ 2018-02-20 11:41 UTC (permalink / raw
  To: linux-integrity
  Cc: Nayna Jain, Thiebaud Weksteen, Jarkko Sakkinen, Peter Huewe,
	Jason Gunthorpe, open list

Replaced kmalloc() + memcpy() in tpm_eventlog_efi.c and
tpm_eventlog_of.c.

Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
---
v2: update also tpm_eventlog_of.c
 drivers/char/tpm/tpm_eventlog_efi.c | 3 +--
 drivers/char/tpm/tpm_eventlog_of.c  | 5 +----
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/char/tpm/tpm_eventlog_efi.c b/drivers/char/tpm/tpm_eventlog_efi.c
index e3f9ffd341d2..57c8b3cc46be 100644
--- a/drivers/char/tpm/tpm_eventlog_efi.c
+++ b/drivers/char/tpm/tpm_eventlog_efi.c
@@ -50,10 +50,9 @@ int tpm_read_log_efi(struct tpm_chip *chip)
 	}
 
 	/* malloc EventLog space */
-	log->bios_event_log = kmalloc(log_size, GFP_KERNEL);
+	log->bios_event_log = kmemdup(log_tbl->log, log_size, GFP_KERNEL);
 	if (!log->bios_event_log)
 		goto err_memunmap;
-	memcpy(log->bios_event_log, log_tbl->log, log_size);
 	log->bios_event_log_end = log->bios_event_log + log_size;
 
 	tpm_log_version = log_tbl->version;
diff --git a/drivers/char/tpm/tpm_eventlog_of.c b/drivers/char/tpm/tpm_eventlog_of.c
index 96fd5646f866..c4b1d3049060 100644
--- a/drivers/char/tpm/tpm_eventlog_of.c
+++ b/drivers/char/tpm/tpm_eventlog_of.c
@@ -68,14 +68,11 @@ int tpm_read_log_of(struct tpm_chip *chip)
 		return -EIO;
 	}
 
-	log->bios_event_log = kmalloc(size, GFP_KERNEL);
+	log->bios_event_log = kmemdup(__va(base), size, GFP_KERNEL);
 	if (!log->bios_event_log)
 		return -ENOMEM;
-
 	log->bios_event_log_end = log->bios_event_log + size;
 
-	memcpy(log->bios_event_log, __va(base), size);
-
 	if (chip->flags & TPM_CHIP_FLAG_TPM2)
 		return EFI_TCG2_EVENT_LOG_FORMAT_TCG_2;
 	return EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2;
-- 
2.14.1

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

* Re: [PATCH v2] tpm: use kmemdup() to copy the event log
  2018-02-20 11:41 [PATCH v2] tpm: use kmemdup() to copy the event log Jarkko Sakkinen
@ 2018-02-20 14:26 ` Javier Martinez Canillas
  2018-02-20 17:14   ` Jarkko Sakkinen
  0 siblings, 1 reply; 3+ messages in thread
From: Javier Martinez Canillas @ 2018-02-20 14:26 UTC (permalink / raw
  To: Jarkko Sakkinen, linux-integrity
  Cc: Nayna Jain, Thiebaud Weksteen, Peter Huewe, Jason Gunthorpe,
	open list

On 02/20/2018 12:41 PM, Jarkko Sakkinen wrote:
> Replaced kmalloc() + memcpy() in tpm_eventlog_efi.c and
> tpm_eventlog_of.c.
> 
> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> ---

Looks good to me.

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

Best regards,
-- 
Javier Martinez Canillas
Software Engineer - Desktop Hardware Enablement
Red Hat

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

* Re: [PATCH v2] tpm: use kmemdup() to copy the event log
  2018-02-20 14:26 ` Javier Martinez Canillas
@ 2018-02-20 17:14   ` Jarkko Sakkinen
  0 siblings, 0 replies; 3+ messages in thread
From: Jarkko Sakkinen @ 2018-02-20 17:14 UTC (permalink / raw
  To: Javier Martinez Canillas, linux-integrity
  Cc: Nayna Jain, Thiebaud Weksteen, Peter Huewe, Jason Gunthorpe,
	open list

On Tue, 2018-02-20 at 15:26 +0100, Javier Martinez Canillas wrote:
> On 02/20/2018 12:41 PM, Jarkko Sakkinen wrote:
> > Replaced kmalloc() + memcpy() in tpm_eventlog_efi.c and
> > tpm_eventlog_of.c.
> > 
> > Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> > ---
> 
> Looks good to me.
> 
> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

Thanks!

/Jarkko

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

end of thread, other threads:[~2018-02-20 17:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-20 11:41 [PATCH v2] tpm: use kmemdup() to copy the event log Jarkko Sakkinen
2018-02-20 14:26 ` Javier Martinez Canillas
2018-02-20 17:14   ` Jarkko Sakkinen

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.