From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C84AAC33CAF for ; Thu, 16 Jan 2020 18:07:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 95DE2214AF for ; Thu, 16 Jan 2020 18:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579198058; bh=5KK9hVvP7HtS8Nhi7+wZ7prpIoAH8W+uEaDpuuwJxjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=BuPGRWtvTqBJiTFbHJK7sboEXiZulzDxLAF3MdSCCT1eG1P+w9MbxjSQWxkUebIjD vYJ1Vrr3iRJs6uozUezpNS5zrXt9kkk+fVoqR1+O9bdOeSOgVMysGxkLU59UOYZIh5 PcfC3YUJx58ZasaVnzeCwj1JeV1vBXrUWfc21pvo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395003AbgAPSHg (ORCPT ); Thu, 16 Jan 2020 13:07:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:55120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393419AbgAPRjE (ORCPT ); Thu, 16 Jan 2020 12:39:04 -0500 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 2A021246D5; Thu, 16 Jan 2020 17:39:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579196344; bh=5KK9hVvP7HtS8Nhi7+wZ7prpIoAH8W+uEaDpuuwJxjc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hGgR8rjEwWhZNbq+9/CxhhD+hRW89aA1/58j2S7o0qD4Ts8LLnrUnhAn0+SG2Tb9a 67P/mtEmrQmjAj9NP+p3DNMYpklyQWSwgiIVh2OrRbfp8oULcWXBJYbvausi23F4Ue 1otD4HC4PNPCsYkCOXEit02KDtl+M01JazjfPD1o= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dan Carpenter , Douglas Anderson , Daniel Thompson , Sasha Levin , kgdb-bugreport@lists.sourceforge.net Subject: [PATCH AUTOSEL 4.9 140/251] kdb: do a sanity check on the cpu in kdb_per_cpu() Date: Thu, 16 Jan 2020 12:34:49 -0500 Message-Id: <20200116173641.22137-100-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200116173641.22137-1-sashal@kernel.org> References: <20200116173641.22137-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: Dan Carpenter [ Upstream commit b586627e10f57ee3aa8f0cfab0d6f7dc4ae63760 ] The "whichcpu" comes from argv[3]. The cpu_online() macro looks up the cpu in a bitmap of online cpus, but if the value is too high then it could read beyond the end of the bitmap and possibly Oops. Fixes: 5d5314d6795f ("kdb: core for kgdb back end (1 of 2)") Signed-off-by: Dan Carpenter Reviewed-by: Douglas Anderson Signed-off-by: Daniel Thompson Signed-off-by: Sasha Levin --- kernel/debug/kdb/kdb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index 5a58421d7e2d..a52a6da8c3d0 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c @@ -2632,7 +2632,7 @@ static int kdb_per_cpu(int argc, const char **argv) diag = kdbgetularg(argv[3], &whichcpu); if (diag) return diag; - if (!cpu_online(whichcpu)) { + if (whichcpu >= nr_cpu_ids || !cpu_online(whichcpu)) { kdb_printf("cpu %ld is not online\n", whichcpu); return KDB_BADCPUNUM; } -- 2.20.1