Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp830768ybt; Fri, 19 Jun 2020 15:08:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPmPSbj/R5wsyb4P4AKZAZU6N4PyoN01yLmvuqe2dsCvcXmiyKVAkG2GvJ0UI26twrXlX4 X-Received: by 2002:a50:b964:: with SMTP id m91mr5731762ede.37.1592604507799; Fri, 19 Jun 2020 15:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592604507; cv=none; d=google.com; s=arc-20160816; b=WREJnuCRdmpfzl+tMzahb12f0b1lFHGJv3N9zoy7trlcTEvdK3TeIYeHsjIqndMCa5 HQ4pOTK/lBuPD2yDYuf5G59+JjKrnVsvjY6uPQ9zwEaZHM6VNQguBeI/pyb2RuD2Ncxh sDvACX6i0PdqUtiibORhYZUQpbqKjlIkxurALIwn7iOoz03JMh+4P44xJvlm0INWgvcx X6FVPNxrlEfZQzrzDY+Wn/5tgmssjgGWjbWoureUCysfmXDNZd3S2pUwA19FRBZ06A4d EjzDzJ+XEFr6KMKDFiqQem2A5MWDMZKC6yiQEqq+VijQIbaQRvxcfxpHSBq4dgG6D1eE brUw== 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=sG97H/Pvpeod2bl1sqgeqneK9PcLo7xBzTrpGzq7ZD+kbiL4H/4RIULazHhXWq7Gss afDwTQFww58xZEuCgnsP5PA2e2FI/q3egycu0737qkiVmPSqH3ySSNYqDHL+6d7e6weL cbQiPwg8xOuV6B9ODHDnmyZ1dD961I+qgE+kAi8DAToDbTZa0LuRtVlvFKuBmSuNVyma 3QSIwbqufC12mw4A0gULyVg0z31O5cbpNEYuC8C6IX66l3k/Hca5gxW3xkja9P3NjpQJ vPgd0lWe+E24jVfRB3AA8+fr1UTEVZ7x5IXsQjGdCXuWwW8CUcTxM29RouQgab2N46LV 5jJw== 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 linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 b27si4552432ejq.568.2020.06.19.15.08.05; Fri, 19 Jun 2020 15:08:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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 linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404213AbgFSPZ7 (ORCPT + 99 others); Fri, 19 Jun 2020 11:25:59 -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 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: 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(-) 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); -- 2.25.1