[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200922094128.26245-1-ardb@kernel.org>
Date: Tue, 22 Sep 2020 11:41:28 +0200
From: Ard Biesheuvel <ardb@...nel.org>
To: linux-integrity@...r.kernel.org
Cc: linux-kernel@...r.kernel.org, Ard Biesheuvel <ardb@...nel.org>,
Peter Huewe <peterhuewe@....de>,
Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>,
Jason Gunthorpe <jgg@...pe.ca>
Subject: [PATCH] tpm: of: avoid __va() translation for event log address
The TPM event log is provided to the OS by the firmware, by loading
it into an area in memory and passing the physical address via a node
in the device tree.
Currently, we use __va() to access the memory via the kernel's linear
map: however, it is not guaranteed that the linear map covers this
particular address, as we may be running under HIGHMEM on a 32-bit
architecture, or running firmware that uses a memory type for the
event log that is omitted from the linear map (such as EfiReserved).
So instead, use memremap(), which will reuse the linear mapping if
it is valid, or create another mapping otherwise.
Cc: Peter Huewe <peterhuewe@....de>
Cc: Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
Cc: Jason Gunthorpe <jgg@...pe.ca>
Signed-off-by: Ard Biesheuvel <ardb@...nel.org>
---
drivers/char/tpm/eventlog/of.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/char/tpm/eventlog/of.c b/drivers/char/tpm/eventlog/of.c
index a9ce66d09a75..9178547589a3 100644
--- a/drivers/char/tpm/eventlog/of.c
+++ b/drivers/char/tpm/eventlog/of.c
@@ -11,6 +11,7 @@
*/
#include <linux/slab.h>
+#include <linux/io.h>
#include <linux/of.h>
#include <linux/tpm_eventlog.h>
@@ -25,6 +26,7 @@ int tpm_read_log_of(struct tpm_chip *chip)
struct tpm_bios_log *log;
u32 size;
u64 base;
+ void *p;
log = &chip->log;
if (chip->dev.parent && chip->dev.parent->of_node)
@@ -65,7 +67,11 @@ int tpm_read_log_of(struct tpm_chip *chip)
return -EIO;
}
- log->bios_event_log = kmemdup(__va(base), size, GFP_KERNEL);
+ p = memremap(base, size, MEMREMAP_WB);
+ if (!p)
+ return -ENOMEM;
+ log->bios_event_log = kmemdup(p, size, GFP_KERNEL);
+ memunmap(p);
if (!log->bios_event_log)
return -ENOMEM;
--
2.17.1
Powered by blists - more mailing lists