Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp3018511imm; Sun, 1 Jul 2018 10:24:12 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLEdyrLbjUDsR4LEcAIRj9qSes/BszBfUTldwUEFQQ/W2wE81cYGI4jPaesg/T19GBKNcGq X-Received: by 2002:a63:6441:: with SMTP id y62-v6mr18877871pgb.240.1530465852912; Sun, 01 Jul 2018 10:24:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530465852; cv=none; d=google.com; s=arc-20160816; b=Smo2psvVxwKtc4A5WfrHljZln0A7sHTTrVRvwJthkkzSR85ja4Mtf/CSUjcdX49dk0 b/BU4Zi50dXtkqLpGbFasosygQ6CPW1o9xsl0yuYL10/2Eq8IsF+8TezDJ10x/1RKUhI q0qY5UW574lbty2no9bTRcMnk7zZuzjPB0+oAWrCgFplG4WainBwO0DKCfprid5q6Haz 0DG1BsCaSoS4hjvF/zWmwJDkCsx8zgZbRrDed5XdmEt2VmgYeCvBgaF0UKbDybzW7v2l kxc+7RtrPU5Z3/CzPms4m2HWvnk82GRRh9fmylhxU6ySP6VP/cBPHK6R0e2eA99/WG3q ky+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=hPQ/wfTGs+xZIHA60pS7jD0E5lQQHpobjDN947CUcLI=; b=HdLCneQELvO5Y5SDDr5qCiUIhrHzNrCpkW6wCfg0C1flOlOuHgZQGJrvuS6wWhcW6F SFehOYowe1/Ups4GuNrI7FbREPrYYlQHqDx7reoJioOnwEaMOJknpF/gSC2o9SerGABY xTqwq4nc/dxYEW3rYuTHeYdIPcQ0DLkcjjc6IYyQuzq9g0qHPEFEvGmCekO7n6ub4h/m juWu6oKn17/4TShAgBtPhFXqGIpaVbf7C8OGQ25mt4gFjRa/Jyo9ACWg4FG+UdSK2/8o BAUSzv+EoTJmfzDh6zWNL5oCIQ+Y0JwRtgOlNpDRNWtc2iLhEfnlSPqmTmnJXeN9X7ne SDIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a95-v6si14162732pla.401.2018.07.01.10.23.58; Sun, 01 Jul 2018 10:24:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965568AbeGARVm (ORCPT + 99 others); Sun, 1 Jul 2018 13:21:42 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36668 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031094AbeGAQiO (ORCPT ); Sun, 1 Jul 2018 12:38:14 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B383292B; Sun, 1 Jul 2018 16:38:13 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tony Luck , Borislav Petkov , Thomas Gleixner Subject: [PATCH 4.17 009/220] x86/mce: Do not overwrite MCi_STATUS in mce_no_way_out() Date: Sun, 1 Jul 2018 18:20:33 +0200 Message-Id: <20180701160908.712729964@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Borislav Petkov commit 1f74c8a64798e2c488f86efc97e308b85fb7d7aa upstream. mce_no_way_out() does a quick check during #MC to see whether some of the MCEs logged would require the kernel to panic immediately. And it passes a struct mce where MCi_STATUS gets written. However, after having saved a valid status value, the next iteration of the loop which goes over the MCA banks on the CPU, overwrites the valid status value because we're using struct mce as storage instead of a temporary variable. Which leads to MCE records with an empty status value: mce: [Hardware Error]: CPU 0: Machine Check Exception: 6 Bank 0: 0000000000000000 mce: [Hardware Error]: RIP 10: {trigger_mce+0x7/0x10} In order to prevent the loss of the status register value, return immediately when severity is a panic one so that we can panic immediately with the first fatal MCE logged. This is also the intention of this function and not to noodle over the banks while a fatal MCE is already logged. Tony: read the rest of the MCA bank to populate the struct mce fully. Suggested-by: Tony Luck Signed-off-by: Borislav Petkov Signed-off-by: Thomas Gleixner Cc: Link: https://lkml.kernel.org/r/20180622095428.626-8-bp@alien8.de Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/cpu/mcheck/mce.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c @@ -772,23 +772,25 @@ EXPORT_SYMBOL_GPL(machine_check_poll); static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp, struct pt_regs *regs) { - int i, ret = 0; char *tmp; + int i; for (i = 0; i < mca_cfg.banks; i++) { m->status = mce_rdmsrl(msr_ops.status(i)); - if (m->status & MCI_STATUS_VAL) { - __set_bit(i, validp); - if (quirk_no_way_out) - quirk_no_way_out(i, m, regs); - } + if (!(m->status & MCI_STATUS_VAL)) + continue; + + __set_bit(i, validp); + if (quirk_no_way_out) + quirk_no_way_out(i, m, regs); if (mce_severity(m, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) { + mce_read_aux(m, i); *msg = tmp; - ret = 1; + return 1; } } - return ret; + return 0; } /*