Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2466609rdb; Wed, 4 Oct 2023 01:55:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFe/NEWvsE6jjjy3QZg0hEX93pXtJ5nQt6zBdSnMLml69XoHz+yG/eHzAY/8PnkU5Z0OKvO X-Received: by 2002:a05:6358:261a:b0:14f:d52:39cb with SMTP id l26-20020a056358261a00b0014f0d5239cbmr2036533rwc.26.1696409718474; Wed, 04 Oct 2023 01:55:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696409718; cv=none; d=google.com; s=arc-20160816; b=0dU0gksLdEvvfeLpte5owYiPB81IstF0AHXlj2R2SHgknQpnn2JWwpzwXCzujvNTBK GRWqaKGhU6KnsP5Yz71nkmFcS3ehBlYdJpn9g6nh3YJkX98tdnYZQry2tDMsuBxkEdDS idf8jkgS8fwDroUQ/hcQrvESMqmdCKRLaucwAq0bokLUEDnf+/2JJIKcOV7YfnAtMwVK dYdfw90l/LbzsM7K/I6MT+WG9fhF3rixd3WOInRakjHq5svgzpRSppxmOAOw+n6sb/cv tR1gVdNm/xJsDH5jcYVIPknUAeXwuAfJ/gl/3ucOe89FfZBEAix5YacXki1IIwX9mqr9 h3pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=QHSDXSZDfLcDWLMe+H5lrfI+IsxykQEocVzwTVa7VEc=; fh=58ImmVCuFle95JFvhXW8TMFJHv6YLSLeJPpTl3/7Lp8=; b=njaQSVRlygRjKjYJbsuREY2OAGZjovSwANM5Pg4X2j8DvPUOFjwr811GLChFcsD5yr OB9Og5bZ3akXpbGFs7uxFm32ikvZ56rTKgXmaRf+86Kok+s/fiv21zOrGvdm6v3A5GqB Nwa9dOPjhH9mzaehZJCL9nTfkWyYIRdlGjDEh694abD3U+7Gp9+xoZxer7G4S7wTh7xe to5OBOTe+pMWF2l1H4/zCFK5ESws840JDaw7Q9ODURSyINjRE5lrjvBB0ENhv4aS18E4 j/fFpczfTtQJAKAQWoSlpAzFBVQp/whWQ6CQaEP40g5zTdQG2KGVEMnctHaGj7OXebK8 0P/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id v23-20020a17090a899700b0027b123fbe9dsi156226pjn.156.2023.10.04.01.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 01:55:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id E0FA081A6C28; Wed, 4 Oct 2023 01:55:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232988AbjJDIzI (ORCPT + 99 others); Wed, 4 Oct 2023 04:55:08 -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: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 04 Oct 2023 01:55:16 -0700 (PDT) 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 idx, char *options, struct console_cmdline *c; int i; + /* See struct console */ + if (idx > SHRT_MAX) + return -EINVAL; + /* * See if this tty is not yet registered, and * if we have a slot free. -- 2.42.0