Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp111018ybg; Mon, 8 Jun 2020 17:55:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwd+i7zH7VAk2CTiGVJHu8Kzcg9OUlahQh7SpW78ieN8Rb8qlbetxFbN9TEp0iARYrQnpcH X-Received: by 2002:a17:906:9a02:: with SMTP id ai2mr22552935ejc.97.1591664101487; Mon, 08 Jun 2020 17:55:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591664101; cv=none; d=google.com; s=arc-20160816; b=yqn+lDpssRA8RZwRtoZ3XoJAvLzVvaISX98/sPsAAI1yyn+E7jwKrvXv2AOWfZCObD A5Q7R5ahjC9xL9LTNwlQaetwEecsM0xz5IaFtAg2uhnbo2HLu4iHvtQEpbmqcO2hdrky dLyZWtMfdwtm5NJ/eEl4UnrPebwKGrVpq+nw8N0df2snm5G8FoyMyBbWlVT8i/pNwFdj ZMEFR4MQI/aWM0Ldcr1Gd5N/B2eK+aXGLVH6N9FnPks/osY3m7aKCM36+XJrymGUn5VW gE2GcIIwRV6ylx6yR9Hl0G2Gsq6NmJI95ogrZxFQREsCu21led1Q1Uka5LYTQ1/pXssa iX/g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jddOLjkw7utoXNS8o6B3qnGX3/5yJYJ0aTi4mDeqszo=; b=IQcp6rmweEpiz42U6FjuYxIm8BTklooa8y+JniA03Dfo/P2vr0GrqJeT/Occo3LVJ6 tJBgxthksjGwT8bF6ZLifl+9jztlaUyNrI/TgMz1YFl+7KW44QXcD1HAtYMaB/jSfJak ISv7qCMBJ9HRIQhTHDOIWhghfUlbkZPLoUPEkylWYk+8+HGKWr7z9gLWlkIE3G6ehFVt LsoIurP56XoetlKw0M6abHhJwVhrFG1r9ETGM6DbeKNWR4htXZbnqj2PDoI0ledIIklq NlmPOdH782T4W/g2r88Mt2nmvYfch+x/Xgd45h7IlxrUVlJVJjmaCobrKfeBpKt1CQIE XdGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gFo8iS1z; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dp4si12087185ejc.258.2020.06.08.17.54.37; Mon, 08 Jun 2020 17:55:01 -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=gFo8iS1z; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732922AbgFIAw4 (ORCPT + 99 others); Mon, 8 Jun 2020 20:52:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:55804 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728527AbgFHXJx (ORCPT ); Mon, 8 Jun 2020 19:09:53 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5B9A0208B6; Mon, 8 Jun 2020 23:09:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591657793; bh=EPvLA69U/3lpdJqAkicuhqkJDkhVEvtI1+W5+HOOb80=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gFo8iS1zcMXWTfdMIeedI51S8Jm2y0M/Ubo4827BFJqDGLDbQoBOrYH2TbRpC9cKa Q3YpJS1XJa2VCIM6+J/7TCqZwpXCA13lJepARka4b3+VPZpF5+fye5PcXP/uMeZsc3 w8bvw/5qY/MLHRZVjX8FB/PJwQFeHhTtm0i/aKT0= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Daniel Thompson , Will Deacon , Douglas Anderson , Sasha Levin , kgdb-bugreport@lists.sourceforge.net Subject: [PATCH AUTOSEL 5.7 172/274] kgdb: Fix spurious true from in_dbg_master() Date: Mon, 8 Jun 2020 19:04:25 -0400 Message-Id: <20200608230607.3361041-172-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200608230607.3361041-1-sashal@kernel.org> References: <20200608230607.3361041-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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