From patchwork Fri Jun 19 14:32:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "gregkh@linuxfoundation.org" X-Patchwork-Id: 191264 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp701830ilo; Fri, 19 Jun 2020 09:51:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1BrrlpEZNCuVBJel73Z8HlU3PMXCUhOfhVPAGvW3EJ1pExctwMnOMlnLxKMthUysfKHL/ X-Received: by 2002:a17:906:5e06:: with SMTP id n6mr4366766eju.504.1592585484195; Fri, 19 Jun 2020 09:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592585484; cv=none; d=google.com; s=arc-20160816; b=vDkjbsaLdSKOObxzGayIvzwElwkI6ONyWdCdHS57x9CN47d586JQpvsRcgZRgSoVlG 8ph9r08SvMqiduoSv93/NVXl7e8me+xshqQWYzbT9O3Of+cNX25nyx/g/OQ1URdyazrP mQtSMbTyydjjmvIaJh8ul0ua9g8kEndaSnmJKAlBIYMmKsHs00eBurxwOXr/XDPkTjda RAXdGpWdOk4Ey082IKmN+IRgUejU+fN6GmMs8fOY/seKoo74gfI6ZzRx5miGsS3sxsQY OLmCSLa53gL4x/8ye/FskUlDLz/4TnEGBoEP3Yg9Rj1WHOVr7Ch3AvTyc3+cIN5g4oBq noeA== 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=YZzxlBFe2O2LHiexT9ac/y3DZO0Y8oTx+57qzeMEvXE=; b=E5D38VDFjxqSJMOVDquZ5eA9L+ysCqQlbDoxXDFilt8w4h0DLhUJsJN2oOj41c9l7+ uEi1Rmd072JhWNrCOvP9Ooe4LTiX5AYcOKPtvQGTP+Khvj7++SQHiOCDSJCeXOFAM6Zr 0qgzps3yiIcfJuMloDTPvrTmmX7f8kX7qfYXSIuNIhlnLIdAbaJPXdS/6sM43MDIJgV8 okfY7ADI/CnpzHmTHynNfchk75dusFUoIR0ChFMXOd9k55TTdCiSWAv7dA4FYOLAJeJp 1cGotHA9NgV6SZl6lafFgStHoPCkorRAKB0TbV3Lfv7gzR5Ffg0VcdtCrDwTWIReZLB6 ilLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DniKQu16; 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 y24si4343948edu.80.2020.06.19.09.51.23; Fri, 19 Jun 2020 09:51:24 -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=DniKQu16; 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 S2405875AbgFSQvO (ORCPT + 15 others); Fri, 19 Jun 2020 12:51:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:55190 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733301AbgFSOiL (ORCPT ); Fri, 19 Jun 2020 10:38:11 -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 98B2B208B8; Fri, 19 Jun 2020 14:38:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592577491; bh=Uw9/vRLVgKmqGjw40c38O9e7lpuxn5NHt5DzieU+7Dk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DniKQu16FzvSdTDCfI1IC2lhO6X/ofjhKUDWuTXyhDoSL2op8D/dyAvNItU8FjMbA 3qfxNrXu7dAkOx/PJxnMDERIoyzRnVIxXM0lvyiKuwGuQdU9YAwx7CviIlzOTfmAVH NAXdXfXTu+uhT89uUbNd0MwqUF4xM9ihzRNr7DVs= 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 4.4 064/101] kgdb: Fix spurious true from in_dbg_master() Date: Fri, 19 Jun 2020 16:32:53 +0200 Message-Id: <20200619141617.408531048@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141614.001544111@linuxfoundation.org> References: <20200619141614.001544111@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 e465bb15912d..6be5545d3584 100644 --- a/include/linux/kgdb.h +++ b/include/linux/kgdb.h @@ -317,7 +317,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); #else /* ! CONFIG_KGDB */