Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1162441imm; Wed, 1 Aug 2018 11:12:49 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeFFLxl+Bl9M5rxu07I/m2WM0sC1O+X5jZdlgLsxhl7qZlXBgXmJhwW/8U0i0Nhcmd0AOUb X-Received: by 2002:a62:a6db:: with SMTP id r88-v6mr27977434pfl.60.1533147168967; Wed, 01 Aug 2018 11:12:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533147168; cv=none; d=google.com; s=arc-20160816; b=SB/NylfR2fFE1zMyJz7KCimfBAqCplwzEf+NzWGta8T7eXwW0UzOTCk6DnXI/dz5jC 47dpoJ9Bqz7EK0FHsD/JpMKaxR0BaDSBS0Ijv7SqdrP0Cd5CZwT512PJUeWJf762Vim7 O/7r83WT11RzyCd7HgdGArqyunv/RlUrOlaNWS7QGOB9b5i2iaZV2/m0UMmpVThT6kCL M7HrrGpJOW5Gf+0lx7c88x1Gx97uzNP7Dtiig+StdimlMB4I03Smke1YmK2t6W+TLPzc VfIlgMUEVkvpwXzjYZSm6HKInNX3ZnulFBOP7FoGcRTMP1RV9XokBkaUZMcCBPOMZc6/ T4IQ== 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=PxiM65CViISI1AKdViB0l9KInPhXt6WpvvENnHZA3Mc=; b=VUGbfm9HwYiWE7HePYvHp80xCb5llinn5v5TIUe0XYQSvlupIiCN04EY+2fbi052Of /bs+9WDRGLrjDUpv6aZAPNC4msbWoJgoVTcaLstUYOPqShE3T+P0edd9PdP5IqH4tsP2 PvlCfcPbbZd9pLPQl5iv5afH9z/g98TKlkMcyKMlgkfm2UbPYbNfzsOMHneLplsYvlyy xc6rFDhEjLzpjF55brYexzWlMGHYhtF4FSNBunpRYhBrDOpfAlkZLzj60CK/hGtR6dho kX14CKMWHy45ggvwc1xPQ4y/NZqK++bXGjgP/5tjIENj/d3wDB9zF8Z3P7Vwl31r1TF3 dvMw== 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 h2-v6si76480pgj.550.2018.08.01.11.12.34; Wed, 01 Aug 2018 11:12:48 -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 S2405742AbeHATIf (ORCPT + 99 others); Wed, 1 Aug 2018 15:08:35 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:49440 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405273AbeHATId (ORCPT ); Wed, 1 Aug 2018 15:08:33 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B0ACD1369; Wed, 1 Aug 2018 17:13:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, Steven Rostedt Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Zijlstra , Sergey Senozhatsky , Petr Mladek , Sasha Levin Subject: [PATCH 4.14 041/246] printk: drop in_nmi check from printk_safe_flush_on_panic() Date: Wed, 1 Aug 2018 18:49:11 +0200 Message-Id: <20180801165013.685247499@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sergey Senozhatsky [ Upstream commit 554755be08fba31c74f66b82a485e5513205af84 ] Drop the in_nmi() check from printk_safe_flush_on_panic() and attempt to re-init (IOW unlock) locked logbuf spinlock from panic CPU regardless of its context. Otherwise, theoretically, we can deadlock on logbuf trying to flush per-CPU buffers: a) Panic CPU is running in non-NMI context b) Panic CPU sends out shutdown IPI via reboot vector c) Panic CPU fails to stop all remote CPUs d) Panic CPU sends out shutdown IPI via NMI vector One of the CPUs that we bring down via NMI vector can hold logbuf spin lock (theoretically). Link: http://lkml.kernel.org/r/20180530070350.10131-1-sergey.senozhatsky@gmail.com To: Steven Rostedt Cc: Peter Zijlstra Cc: linux-kernel@vger.kernel.org Signed-off-by: Sergey Senozhatsky Signed-off-by: Petr Mladek Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- kernel/printk/printk_safe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/printk/printk_safe.c +++ b/kernel/printk/printk_safe.c @@ -284,7 +284,7 @@ void printk_safe_flush_on_panic(void) * Make sure that we could access the main ring buffer. * Do not risk a double release when more CPUs are up. */ - if (in_nmi() && raw_spin_is_locked(&logbuf_lock)) { + if (raw_spin_is_locked(&logbuf_lock)) { if (num_online_cpus() > 1) return;