From nobody Tue Dec 16 19:40:41 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7E03E8FDDD for ; Wed, 4 Oct 2023 08:55:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241826AbjJDIzJ (ORCPT ); Wed, 4 Oct 2023 04:55:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232554AbjJDIzH (ORCPT ); Wed, 4 Oct 2023 04:55:07 -0400 Received: from muru.com (unknown [72.249.23.125]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 95657A6 for ; Wed, 4 Oct 2023 01:55:01 -0700 (PDT) Received: from hillo.muru.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTP id 459A480BD; Wed, 4 Oct 2023 08:54:45 +0000 (UTC) From: Tony Lindgren To: Petr Mladek , Steven Rostedt , John Ogness , Sergey Senozhatsky Cc: linux-kernel@vger.kernel.org Subject: [PATCH] printk: Check valid console index for preferred console Date: Wed, 4 Oct 2023 11:54:33 +0300 Message-ID: <20231004085434.42570-1-tony@atomide.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Let's check for valid console index values. Signed-off-by: Tony Lindgren --- kernel/printk/printk.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -2410,6 +2410,10 @@ static int __add_preferred_console(char *name, int i= dx, char *options, struct console_cmdline *c; int i; =20 + /* See struct console */ + if (idx > SHRT_MAX) + return -EINVAL; + /* * See if this tty is not yet registered, and * if we have a slot free. --=20 2.42.0