Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp862475yba; Wed, 24 Apr 2019 10:48:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqwn1w2IQlPHTiCy/sGJj8fpUIL1gm/SDd+pofDD1pgKowplfvDZyOrrPZXrmYbMqbbA+wAP X-Received: by 2002:a63:750c:: with SMTP id q12mr32075883pgc.133.1556128121356; Wed, 24 Apr 2019 10:48:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556128121; cv=none; d=google.com; s=arc-20160816; b=wrRzVd1jNCWIvWMIf5oldzS9alo0Xi6Tu3JVvfGBhe62zWDz7NZlRfwfwXl4Byjssv FLqXAA7hCi2Ji+0Mod1/5ZGUuTkqVx/8HuUJa03p9RpQuYDOdLSiPHgqJxNB0dwUu5ur LcSRvyW49+wQw+4dEtD45WFQsDdCzNiDbv9lyTPKIKn90vY0e3P5yulRe1oPhkd0u6or i3lm8TaL89U8UX21QqB2kFSWNfM8WG24JqnU3pOQU5BdS7XuJKAFMGrpA85X/Wz7ABSc soUd/ieuGKS7ApkAvfJey2KGcc+1PIasxTbscvUNmowMKq/scfRMmF3wf+8yYlV0o3k+ idmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bFcVXdmvO4uFZpBcq5LWI9XbBhSsf64dPycXYNQ/GOM=; b=Hs3jzHvtRmltDPFYfCbcTyKlWFOD8qIgv/a1OwRC5w3hGXPexYv/RvtLiZDhg/TZup G0XUUTZYhSt0aP4Dwce+/rfnwWOlhsGhX8AL65ZDNFpVHLSZ0Cu/VCP0jNZfuYcK9qF7 XiuzjRlKHh3bqeMt8R80//MHRgtdjl+agcseog5hfvk95sxAG2nCHHK2WVT3PxUA+pfW M4dNtqiMr844ep9/1OParvXpFWBGOFijFHHrVxbEKdKcPaSrT6DVCOcni+fxdZXfdufQ 1Hz3jTdo9gre0Ka0l3BaW69FhT4gT+C/E4eNdtcrmqDK7KG3hGXaLCkJcVZAnrBbVsTR AQUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UnFInW8F; 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 i3si17074673pgq.350.2019.04.24.10.48.26; Wed, 24 Apr 2019 10:48:41 -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; dkim=pass header.i=@kernel.org header.s=default header.b=UnFInW8F; 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 S2391318AbfDXRcT (ORCPT + 99 others); Wed, 24 Apr 2019 13:32:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:58926 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391309AbfDXRcS (ORCPT ); Wed, 24 Apr 2019 13:32:18 -0400 Received: from localhost (62-193-50-229.as16211.net [62.193.50.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0BCF921906; Wed, 24 Apr 2019 17:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556127137; bh=KvnMzeYMC+DEtYdigmfzkFAkCX2JLyp/utJM9teUTG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UnFInW8FkQxGS2+/5EAd9GW0fHnqExH701TkatrZ2Ulv1cZxlPWQbKsjoxXzLVTBh zYYux3Y/6clJsX6OBNsMJTRtzpzkB81unXkVUMw+G/gLzepc7vL+vVPYRi7XyrstF8 N4gzUWjdPzL61PA2aMd035MQN8mL1ln4txZjoC7g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikhail Gavrilov , Thomas Gleixner , Thomas Lendacky Subject: [PATCH 4.19 75/96] x86/speculation: Prevent deadlock on ssb_state::lock Date: Wed, 24 Apr 2019 19:10:20 +0200 Message-Id: <20190424170924.815623557@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190424170919.829037226@linuxfoundation.org> References: <20190424170919.829037226@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner commit 2f5fb19341883bb6e37da351bc3700489d8506a7 upstream. Mikhail reported a lockdep splat related to the AMD specific ssb_state lock: CPU0 CPU1 lock(&st->lock); local_irq_disable(); lock(&(&sighand->siglock)->rlock); lock(&st->lock); lock(&(&sighand->siglock)->rlock); *** DEADLOCK *** The connection between sighand->siglock and st->lock comes through seccomp, which takes st->lock while holding sighand->siglock. Make sure interrupts are disabled when __speculation_ctrl_update() is invoked via prctl() -> speculation_ctrl_update(). Add a lockdep assert to catch future offenders. Fixes: 1f50ddb4f418 ("x86/speculation: Handle HT correctly on AMD") Reported-by: Mikhail Gavrilov Signed-off-by: Thomas Gleixner Tested-by: Mikhail Gavrilov Cc: Thomas Lendacky Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/alpine.DEB.2.21.1904141948200.4917@nanos.tec.linutronix.de Signed-off-by: Greg Kroah-Hartman --- arch/x86/kernel/process.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c @@ -411,6 +411,8 @@ static __always_inline void __speculatio u64 msr = x86_spec_ctrl_base; bool updmsr = false; + lockdep_assert_irqs_disabled(); + /* * If TIF_SSBD is different, select the proper mitigation * method. Note that if SSBD mitigation is disabled or permanentely @@ -462,10 +464,12 @@ static unsigned long speculation_ctrl_up void speculation_ctrl_update(unsigned long tif) { + unsigned long flags; + /* Forced update. Make sure all relevant TIF flags are different */ - preempt_disable(); + local_irq_save(flags); __speculation_ctrl_update(~tif, tif); - preempt_enable(); + local_irq_restore(flags); } /* Called from seccomp/prctl update */