From patchwork Fri Jun 19 14:31:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 191224 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp626408ilo; Fri, 19 Jun 2020 08:23:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwxHOGHSCZZ0SQHxx7Jnh9Pu+Wv4ZnrheZEIPYQnSRwPTDRKq6xQ86hXwlAhMcy0VBKezy3 X-Received: by 2002:aa7:ce13:: with SMTP id d19mr3934161edv.355.1592580206799; Fri, 19 Jun 2020 08:23:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592580206; cv=none; d=google.com; s=arc-20160816; b=aZ1LoZx80G9Wu0ik3jPY6cm1os+A+sLfpIvWY73BQ8RFm3HJO1HqBk+JoWLSXreqPi D2nGoXvwL5dEpizoCfaIZyj/gQR25kbq0McbMHLUIBwo/FtnRrk3dfZ/ea36YEQ0WhBp Yh3oNwehUxdfZ8Pov3fLR4zHAibTfYlEyndQMTIr7ZnzRKN0IWV7gAPq7roUwzDEBodw eaUmoNlVdAk4kBgwEYTMlvOW3FcKNznt9QllfEWCQELWgF/Nhc+yQt4sOMDgZzHnOtgM /U4+h8By2PwU81Ev2BmxGuRBGScfetFPNFC3M5MddteztSgF7VNgfb8mdWK5meCq2c3D 27Hw== 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=jddOLjkw7utoXNS8o6B3qnGX3/5yJYJ0aTi4mDeqszo=; b=xNVCkTeZhHvMlD7CYKQg5OgxsCr8AZ56hMSm+vmy/6H9VHBPb7foVfT15tLE1KoIlo oM+G+VjFx5bv4T8q3b91THG3AxxbSPLz00syxkz5BslhXRYXmwFYksrmJFlt7IV8SGTM lxk/MA6q2iNWFSribtU0is2x6/1P9g21YpcNnhA3iTahwotnuxo5l/8vLpDq9o3iM0WG HKYEJSeW/x6eoft1ecMj/aa4cUvZpVFNbXZIFNY0N5HbIH5VJuRqhJnD5KLwrKuCLlw7 coDXve+n9r4hclEpARD7dQ63XE91sh0CootM1s7yhvKjlgXWjbIVxwuveZnndjtEMzcf 3L8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OcFaY9yw; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h4si4012418edv.535.2020.06.19.08.23.26; Fri, 19 Jun 2020 08:23:26 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OcFaY9yw; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393175AbgFSPXY (ORCPT + 15 others); Fri, 19 Jun 2020 11:23:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:54916 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393163AbgFSPXW (ORCPT ); Fri, 19 Jun 2020 11:23:22 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 161DB217A0; Fri, 19 Jun 2020 15:23:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592580201; bh=EPvLA69U/3lpdJqAkicuhqkJDkhVEvtI1+W5+HOOb80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OcFaY9ywzfg8N+JpxOu3Lybz/FZ+Lvd2yeeq4pl5A0m8kPfv2q6Axnl7oIWARLYwL g/fikAGm7YgPCPPsTTJ4Rbe3iEi2mT7oKIpk6SDwVaHg/Dv8fAFKQD+yJvw5Cy2p9R kzwBpXkvv4KVotauDeeRyVKLr6CMFNLIYcoh23o0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Douglas Anderson , Daniel Thompson , Sasha Levin Subject: [PATCH 5.7 161/376] kgdb: Fix spurious true from in_dbg_master() Date: Fri, 19 Jun 2020 16:31:19 +0200 Message-Id: <20200619141717.943538361@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141710.350494719@linuxfoundation.org> References: <20200619141710.350494719@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Daniel Thompson [ Upstream commit 3fec4aecb311995189217e64d725cfe84a568de3 ] Currently there is a small window where a badly timed migration could cause in_dbg_master() to spuriously return true. Specifically if we migrate to a new core after reading the processor id and the previous core takes a breakpoint then we will evaluate true if we read kgdb_active before we get the IPI to bring us to halt. Fix this by checking irqs_disabled() first. Interrupts are always disabled when we are executing the kgdb trap so this is an acceptable prerequisite. This also allows us to replace raw_smp_processor_id() with smp_processor_id() since the short circuit logic will prevent warnings from PREEMPT_DEBUG. Fixes: dcc7871128e9 ("kgdb: core changes to support kdb") Suggested-by: Will Deacon Link: https://lore.kernel.org/r/20200506164223.2875760-1-daniel.thompson@linaro.org Reviewed-by: Douglas Anderson Signed-off-by: Daniel Thompson Signed-off-by: Sasha Levin --- include/linux/kgdb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.25.1 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h index b072aeb1fd78..4d6fe87fd38f 100644 --- a/include/linux/kgdb.h +++ b/include/linux/kgdb.h @@ -323,7 +323,7 @@ extern void gdbstub_exit(int status); extern int kgdb_single_step; extern atomic_t kgdb_active; #define in_dbg_master() \ - (raw_smp_processor_id() == atomic_read(&kgdb_active)) + (irqs_disabled() && (smp_processor_id() == atomic_read(&kgdb_active))) extern bool dbg_is_early; extern void __init dbg_late_init(void); extern void kgdb_panic(const char *msg);