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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 3A78FC35242 for ; Fri, 24 Jan 2020 11:20:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 02B792077C for ; Fri, 24 Jan 2020 11:20:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579864837; bh=Ma/NnsJPkV1sq94HnMM2zkpaa8R8m+woez7KDZ6AYak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Cs9zfHHqA3/D9a6RL+JcrCG57JZHvXZ/82aVM00hZJt0JGqX5AxdskghMa3DNI6R7 2rBFo8HteBZW1KGziaFz/qHKybdNqFzXUmTwvvyRUJEoRy9+giqaNJ9ck7huhLp5FU OJMh5TN2fOCDrX51ZUxJ84Mk5gngnomf7ccuYe2o= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390935AbgAXLUg (ORCPT ); Fri, 24 Jan 2020 06:20:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:58220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389561AbgAXLUa (ORCPT ); Fri, 24 Jan 2020 06:20:30 -0500 Received: from localhost (ip-213-127-102-57.ip.prioritytelecom.net [213.127.102.57]) (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 DCCEB20704; Fri, 24 Jan 2020 11:20:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579864829; bh=Ma/NnsJPkV1sq94HnMM2zkpaa8R8m+woez7KDZ6AYak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XJ8xNQYW57EgrfZBtG4V1Tpg0wRfF0L10y6T9yZN+QSwVe1z7r7Zkn5J0+aI8fgIN DLxcb6L3DgaUIsOUMi+n4PZVPT7cALUoUeOMpqPlbO0JdHeMsCe6wkm2V5J9v06NDt tk/yQAzlUkbVRo5nF7QJtjXNFup0hhNlHoLTDvh4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Douglas Anderson , Daniel Thompson , Sasha Levin Subject: [PATCH 4.19 369/639] kdb: do a sanity check on the cpu in kdb_per_cpu() Date: Fri, 24 Jan 2020 10:28:59 +0100 Message-Id: <20200124093133.281464823@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124093047.008739095@linuxfoundation.org> References: <20200124093047.008739095@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: 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 f338d23b112b5..dc6bf35e78840 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c @@ -2604,7 +2604,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