[PATCH 4.19 091/205] acpi/nfit, x86/mce: Validate a MCEs address before using it
From: Greg Kroah-Hartman
Date: Mon Nov 19 2018 - 11:34:09 EST
4.19-stable review patch. If anyone has any objections, please let me know.
------------------
From: Vishal Verma <vishal.l.verma@xxxxxxxxx>
commit e8a308e5f47e545e0d41d0686c00f5f5217c5f61 upstream.
The NFIT machine check handler uses the physical address from the mce
structure, and compares it against information in the ACPI NFIT table
to determine whether that location lies on an NVDIMM. The mce->addr
field however may not always be valid, and this is indicated by the
MCI_STATUS_ADDRV bit in the status field.
Export mce_usable_address() which already performs validation for the
address, and use it in the NFIT handler.
Fixes: 6839a6d96f4e ("nfit: do an ARS scrub on hitting a latent media error")
Reported-by: Robert Elliott <elliott@xxxxxxx>
Signed-off-by: Vishal Verma <vishal.l.verma@xxxxxxxxx>
Signed-off-by: Borislav Petkov <bp@xxxxxxx>
CC: Arnd Bergmann <arnd@xxxxxxxx>
Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
CC: Dave Jiang <dave.jiang@xxxxxxxxx>
CC: elliott@xxxxxxx
CC: "H. Peter Anvin" <hpa@xxxxxxxxx>
CC: Ingo Molnar <mingo@xxxxxxxxxx>
CC: Len Brown <lenb@xxxxxxxxxx>
CC: linux-acpi@xxxxxxxxxxxxxxx
CC: linux-edac <linux-edac@xxxxxxxxxxxxxxx>
CC: linux-nvdimm@xxxxxxxxxxxx
CC: Qiuxu Zhuo <qiuxu.zhuo@xxxxxxxxx>
CC: "Rafael J. Wysocki" <rjw@xxxxxxxxxxxxx>
CC: Ross Zwisler <zwisler@xxxxxxxxxx>
CC: stable <stable@xxxxxxxxxxxxxxx>
CC: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
CC: Tony Luck <tony.luck@xxxxxxxxx>
CC: x86-ml <x86@xxxxxxxxxx>
CC: Yazen Ghannam <yazen.ghannam@xxxxxxx>
Link: http://lkml.kernel.org/r/20181026003729.8420-2-vishal.l.verma@xxxxxxxxx
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
arch/x86/include/asm/mce.h | 1 +
arch/x86/kernel/cpu/mcheck/mce.c | 3 ++-
drivers/acpi/nfit/mce.c | 4 ++++
3 files changed, 7 insertions(+), 1 deletion(-)
--- a/arch/x86/include/asm/mce.h
+++ b/arch/x86/include/asm/mce.h
@@ -217,6 +217,7 @@ static inline int umc_normaddr_to_sysadd
int mce_available(struct cpuinfo_x86 *c);
bool mce_is_memory_error(struct mce *m);
bool mce_is_correctable(struct mce *m);
+int mce_usable_address(struct mce *m);
DECLARE_PER_CPU(unsigned, mce_exception_count);
DECLARE_PER_CPU(unsigned, mce_poll_count);
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -485,7 +485,7 @@ static void mce_report_event(struct pt_r
* be somewhat complicated (e.g. segment offset would require an instruction
* parser). So only support physical addresses up to page granuality for now.
*/
-static int mce_usable_address(struct mce *m)
+int mce_usable_address(struct mce *m)
{
if (!(m->status & MCI_STATUS_ADDRV))
return 0;
@@ -505,6 +505,7 @@ static int mce_usable_address(struct mce
return 1;
}
+EXPORT_SYMBOL_GPL(mce_usable_address);
bool mce_is_memory_error(struct mce *m)
{
--- a/drivers/acpi/nfit/mce.c
+++ b/drivers/acpi/nfit/mce.c
@@ -29,6 +29,10 @@ static int nfit_handle_mce(struct notifi
if (!mce_is_memory_error(mce) || mce_is_correctable(mce))
return NOTIFY_DONE;
+ /* Verify the address reported in the MCE is valid. */
+ if (!mce_usable_address(mce))
+ return NOTIFY_DONE;
+
/*
* mce->addr contains the physical addr accessed that caused the
* machine check. We need to walk through the list of NFITs, and see