diff mbox series

[1/1] EDAC/skx_common: Filter out the invalid address

Message ID 20231207014512.78564-1-qiuxu.zhuo@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/1] EDAC/skx_common: Filter out the invalid address | expand

Commit Message

Zhuo, Qiuxu Dec. 7, 2023, 1:45 a.m. UTC
Decoding an invalid address with certain firmware decoders could
cause a #PF (Page Fault) in the EFI runtime context, which could
subsequently hang the system. To make {i10nm,skx}_edac more robust
against such bogus firmware decoders, filter out invalid addresses
before allowing the firmware decoder to process them.

Suggested-by: Tony Luck <tony.luck@intel.com>
Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
---
 drivers/edac/skx_common.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Luck, Tony Jan. 2, 2024, 5:37 p.m. UTC | #1
> Decoding an invalid address with certain firmware decoders could
> cause a #PF (Page Fault) in the EFI runtime context, which could
> subsequently hang the system. To make {i10nm,skx}_edac more robust
> against such bogus firmware decoders, filter out invalid addresses
> before allowing the firmware decoder to process them.

Applied. Thanks.

[Boris: This one with a "Link:" tag]

-Tony
Borislav Petkov Jan. 2, 2024, 6:08 p.m. UTC | #2
On Tue, Jan 02, 2024 at 05:37:20PM +0000, Luck, Tony wrote:
> > Decoding an invalid address with certain firmware decoders could
> > cause a #PF (Page Fault) in the EFI runtime context, which could
> > subsequently hang the system. To make {i10nm,skx}_edac more robust
> > against such bogus firmware decoders, filter out invalid addresses
> > before allowing the firmware decoder to process them.
> 
> Applied. Thanks.
> 
> [Boris: This one with a "Link:" tag]

Thanks! :)
diff mbox series

Patch

diff --git a/drivers/edac/skx_common.c b/drivers/edac/skx_common.c
index ce3e0069e028..9c5b6f8bd8bd 100644
--- a/drivers/edac/skx_common.c
+++ b/drivers/edac/skx_common.c
@@ -648,6 +648,10 @@  int skx_mce_check_error(struct notifier_block *nb, unsigned long val,
 	memset(&res, 0, sizeof(res));
 	res.mce  = mce;
 	res.addr = mce->addr & MCI_ADDR_PHYSADDR;
+	if (!pfn_to_online_page(res.addr >> PAGE_SHIFT)) {
+		pr_err("Invalid address 0x%llx in IA32_MC%d_ADDR\n", mce->addr, mce->bank);
+		return NOTIFY_DONE;
+	}
 
 	/* Try driver decoder first */
 	if (!(driver_decode && driver_decode(&res))) {