From patchwork Fri Jun 19 14:32:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 191262 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp696116ilo; Fri, 19 Jun 2020 09:44:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykWtbF4fGtUepNDgBiTlgBgwQvuz+XOlUT/wBISLHePYKNCyja/EFXVead7gG0XpxYz7zQ X-Received: by 2002:a17:906:6d19:: with SMTP id m25mr4399775ejr.524.1592585090433; Fri, 19 Jun 2020 09:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592585090; cv=none; d=google.com; s=arc-20160816; b=fpFkyMI3PicUT5U+K2SIn8jeMNc7Fp5re9l2GkogFeU8z5YHC2xC/CSmJ1zjzsQW4t 7AgR8j+qCjgJArS/oSL/O1yASlSgPAJ75/1Bw4btpqYxD98NKGjCGKnoj3hVJOUDYdK4 xhIRCx6oq1nn90c2yiFqe0goOrpp3q5c1oWVl1mwPYkAzk9qaDCGsA+rR1LUWHPZZ33u gnx7FAHU8hnslczZ/DurViWi81M/nQETbdNPOFFaE6786HMTesS28RcvQvOPuTPS7yUh UT7jjZUjLSOa5jI243GK1QBv9lysTyxz76C7Bclpl4Sj+iXCnL4oo5sA6NCzUvfzXZfi DUAA== 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=rmoajm/oedAkSRyZzAzyhX1OxUJm11pT8HOduLThg69/gK4VsJitWQGuF4L2XNBG0w wknVmNn8cVt/Uo9yVfzVqOF2afzKsNIfvFySH3dM2Y5YaOnte2yUaZwctciqfpEMBFBm OK63lH1WmSwcezRUkAaojGE3wC035NZVQJiLu+o8AHZKO/4ued+dba6FxcZ1P7GavcaQ D5KoagTyFCVhM7mbiDhG3HPhhkQdaGTWYwor5l6zoERuleMwg3YENA7O8hn1no8OMHNO yZYCnarb+QzvHAVIzl8MqcTkYGUKaKUEWqXut/8ReiEIT5xylSMdIul5ZpIxg6Zd4agU 5svA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MEoQryJW; 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 oq17si3961161ejb.666.2020.06.19.09.44.50; Fri, 19 Jun 2020 09:44:50 -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=MEoQryJW; 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 S2388417AbgFSOmy (ORCPT + 15 others); Fri, 19 Jun 2020 10:42:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:33698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388409AbgFSOmt (ORCPT ); Fri, 19 Jun 2020 10:42:49 -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 A549721582; Fri, 19 Jun 2020 14:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592577769; bh=Uw9/vRLVgKmqGjw40c38O9e7lpuxn5NHt5DzieU+7Dk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MEoQryJWHkCjwLfv9TeQuuMenxQ6cdmLcK+2XzZI5SO8oXrUX40i1iJS9C14E1DmV MP0cyUwumRuQNJoI8aaTUPOzuzy3Ych7BYnEmE5SESBu8EXltiU6/m8Rr8BB+VfQbO Z6UX/iGdZw5S7Gy9wvo2VIlLA2QcWxJRobf9P9i4= 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.9 081/128] kgdb: Fix spurious true from in_dbg_master() Date: Fri, 19 Jun 2020 16:32:55 +0200 Message-Id: <20200619141624.450359947@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141620.148019466@linuxfoundation.org> References: <20200619141620.148019466@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 */