linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] x86/MCE/AMD: Check for NULL banks in THR interrupt handler
@ 2018-08-09 14:08 Yazen Ghannam
  2018-08-09 14:08 ` [PATCH 2/2] x86/MCE/AMD: Skip creating kobjects with NULL names Yazen Ghannam
  2018-08-09 16:15 ` [PATCH 1/2] x86/MCE/AMD: Check for NULL banks in THR interrupt handler Borislav Petkov
  0 siblings, 2 replies; 12+ messages in thread
From: Yazen Ghannam @ 2018-08-09 14:08 UTC (permalink / raw)
  To: linux-edac; +Cc: Yazen Ghannam, linux-kernel, bp, tony.luck, x86

From: Yazen Ghannam <yazen.ghannam@amd.com>

If threshold_init_device() fails then per_cpu(threshold_banks) will be
deallocated. The thresholding interrupt handler will still be active, so
it's possible to get a NULL pointer dereference if a THR interrupt
happens and any of the structures are NULL.

Exit the handler if per_cpu(threshold_banks) is NULL and skip NULL
banks. MCA error information will still be in the registers. The
information will be logged during polling or in another MCA exception or
interrupt handler.

Fixes: 17ef4af0ec0f ("x86/mce/AMD: Use saved threshold block info in interrupt handler")
Cc: <stable@vger.kernel.org> # 4.13.x
Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
---
 arch/x86/kernel/cpu/mcheck/mce_amd.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c
index dd33c357548f..2dbf34250bbf 100644
--- a/arch/x86/kernel/cpu/mcheck/mce_amd.c
+++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c
@@ -934,13 +934,21 @@ static void log_and_reset_block(struct threshold_block *block)
 static void amd_threshold_interrupt(void)
 {
 	struct threshold_block *first_block = NULL, *block = NULL, *tmp = NULL;
+	struct threshold_bank *th_bank = NULL;
 	unsigned int bank, cpu = smp_processor_id();
 
+	if (!per_cpu(threshold_banks, cpu))
+		return;
+
 	for (bank = 0; bank < mca_cfg.banks; ++bank) {
 		if (!(per_cpu(bank_map, cpu) & (1 << bank)))
 			continue;
 
-		first_block = per_cpu(threshold_banks, cpu)[bank]->blocks;
+		th_bank = per_cpu(threshold_banks, cpu)[bank];
+		if (!th_bank)
+			continue;
+
+		first_block = th_bank->blocks;
 		if (!first_block)
 			continue;
 
-- 
2.17.1


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

end of thread, other threads:[~2018-08-21 18:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-09 14:08 [PATCH 1/2] x86/MCE/AMD: Check for NULL banks in THR interrupt handler Yazen Ghannam
2018-08-09 14:08 ` [PATCH 2/2] x86/MCE/AMD: Skip creating kobjects with NULL names Yazen Ghannam
2018-08-09 16:18   ` Borislav Petkov
2018-08-09 18:46     ` Ghannam, Yazen
2018-08-15 15:54       ` Borislav Petkov
2018-08-16 18:46         ` Ghannam, Yazen
2018-08-21 13:15           ` Borislav Petkov
2018-08-21 18:27             ` Ghannam, Yazen
2018-08-09 16:15 ` [PATCH 1/2] x86/MCE/AMD: Check for NULL banks in THR interrupt handler Borislav Petkov
2018-08-09 18:18   ` Ghannam, Yazen
2018-08-16 19:00     ` Ghannam, Yazen
2018-08-21 13:21       ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).