From patchwork Fri Dec 9 11:27:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 31730 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp717193wrr; Fri, 9 Dec 2022 03:32:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf6HGajRoaU1pgKPJZaeEAZTyArWpISGD9zCmmVzUGbqDuh85d4BmGIie7YR2XeS5dP5cVS9 X-Received: by 2002:a05:6a21:e20a:b0:ac:9108:f506 with SMTP id by10-20020a056a21e20a00b000ac9108f506mr5859850pzc.31.1670585554572; Fri, 09 Dec 2022 03:32:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670585554; cv=none; d=google.com; s=arc-20160816; b=LyTadnmfVWXu2Bdn/j/qakpowsWLpImfwteQL69uMx4uxvBSXHKei9IIJR8SFzFYkG C+aA0bxupzfmTGu8a9bCgrmiGMQfXdeUeoU9f0HgTfqkh25gW38udIrLos+2XXG3ionC LPJLoScIMws9/+xhC2EEJ8NmlitnT51SavjBDLiDEFp40HYcsaopf+c85unW+6MtnS/Y ibqhC3Xu0bKkVRgHT8LwOW5EZWgOvlr4cHz5DX7aU5pIcAsLRFA5aNDHtCnHvpaZ6Zzn OewPHmWaUvIwcCruULYDsiLw4jgTPvpca2GtN5zX/AAW7RGN1pMdBCBBHqdo0Oe4j9vj WS1w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pz6m1Fl1hTAMA9HWy+BsrRjV4oX0XBMq5Eof4xY6s8A=; b=aoMbhaK+dZ1TwNPr8V7rLAaiErmum0ufIzOGfyvaCPaDzsD/Qw4NB79InpUcvWL1qa oldEmI/vutM/4Ix70BTWnUgx3l+daqvY54MFYfn1mGWt9ZrdwD6XUY7X6+afmSTYCjhr n2SfQRpNv6459JeOWf2H1VUKZrT/lLiReaLKXn3aUeilKHBAQKZU9ppk/ypE5rW6vCjl xkN54n0+n/baaAT22Yved0n3BDLJ3yJcevyxzLMKD9JP/orae8KLWbKmaYUtgW2mXKUS rvg5xSgGqXdJmVbNyntyTrn9kLEN8zEN1GvmsqDm+MT+eYR0H9g+O87Odnc9qPeCZQN8 BM3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=JXlFAsEJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a8-20020a631a08000000b004791c6d13f2si1255660pga.162.2022.12.09.03.32.18; Fri, 09 Dec 2022 03:32:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=JXlFAsEJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230074AbiLIL2L (ORCPT + 99 others); Fri, 9 Dec 2022 06:28:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229964AbiLIL15 (ORCPT ); Fri, 9 Dec 2022 06:27:57 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD86D396C4; Fri, 9 Dec 2022 03:27:56 -0800 (PST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B99U7YO012471; Fri, 9 Dec 2022 11:27:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=pz6m1Fl1hTAMA9HWy+BsrRjV4oX0XBMq5Eof4xY6s8A=; b=JXlFAsEJTVnZ/VystQt6zpuw0KRfSMCB3gSKNrxSnAq1M7Meyjp+O6xzxN2oR9aDMkjA rLuRnFge5aNiYDLGt4nEaLEBdjwvNwuWvrVDR4eQs664lVBmMSk3J/I+Uqo8kDxfgjM0 +MT21xBaEhCPlaNeNVeDY05FOC64L8vmMDCqhx4WdF07nQGtE1V1VT6g32upB7GEDGW5 /Etv0GKm58p/PTpwL264FodCdD6dS1rG9EGIkzPl3fcK49CkS7/Y71+dKGqjzgiyZKZw KpDdUGq+p8FzFcCzIPVk9fIWm1dHkE0sgbOw5kw3d8FJf2YRFBs7vq2DrB/56/E7Pbqz WQ== Received: from ppma04ams.nl.ibm.com (63.31.33a9.ip4.static.sl-reverse.com [169.51.49.99]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mbrjkf04w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Dec 2022 11:27:53 +0000 Received: from pps.filterd (ppma04ams.nl.ibm.com [127.0.0.1]) by ppma04ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 2B8Lb9uh027356; Fri, 9 Dec 2022 11:27:51 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma04ams.nl.ibm.com (PPS) with ESMTPS id 3m9ks45w92-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Dec 2022 11:27:51 +0000 Received: from smtpav01.fra02v.mail.ibm.com (smtpav01.fra02v.mail.ibm.com [10.20.54.100]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2B9BRlVO40436098 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Dec 2022 11:27:47 GMT Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3F78B20049; Fri, 9 Dec 2022 11:27:47 +0000 (GMT) Received: from smtpav01.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2E77420040; Fri, 9 Dec 2022 11:27:47 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav01.fra02v.mail.ibm.com (Postfix) with ESMTPS; Fri, 9 Dec 2022 11:27:47 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 55390) id E6DC6E027E; Fri, 9 Dec 2022 12:27:46 +0100 (CET) From: Sven Schnelle To: Greg Kroah-Hartman , Jiri Slaby Cc: Christian Borntraeger , linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v2 1/2] tty: fix out-of-bounds access in tty_driver_lookup_tty() Date: Fri, 9 Dec 2022 12:27:36 +0100 Message-Id: <20221209112737.3222509-2-svens@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221209112737.3222509-1-svens@linux.ibm.com> References: <20221209112737.3222509-1-svens@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: SUuO4uooI-8Oa7dRGxZ8g73z6p6RLqLY X-Proofpoint-ORIG-GUID: SUuO4uooI-8Oa7dRGxZ8g73z6p6RLqLY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-09_04,2022-12-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 spamscore=0 mlxscore=0 priorityscore=1501 bulkscore=0 lowpriorityscore=0 impostorscore=0 adultscore=0 clxscore=1015 malwarescore=0 mlxlogscore=948 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212090066 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751735918698677221?= X-GMAIL-MSGID: =?utf-8?q?1751735918698677221?= When specifying an invalid console= device like console=tty3270, tty_driver_lookup_tty() returns the tty struct without checking whether index is a valid number. To reproduce: qemu-system-x86_64 -enable-kvm -nographic -serial mon:stdio \ -kernel ../linux-build-x86/arch/x86/boot/bzImage \ -append "console=ttyS0 console=tty3270" This crashes with: [ 0.770599] BUG: kernel NULL pointer dereference, address: 00000000000000ef [ 0.771265] #PF: supervisor read access in kernel mode [ 0.771773] #PF: error_code(0x0000) - not-present page [ 0.772609] Oops: 0000 [#1] PREEMPT SMP PTI [ 0.774878] RIP: 0010:tty_open+0x268/0x6f0 [ 0.784013] chrdev_open+0xbd/0x230 [ 0.784444] ? cdev_device_add+0x80/0x80 [ 0.784920] do_dentry_open+0x1e0/0x410 [ 0.785389] path_openat+0xca9/0x1050 [ 0.785813] do_filp_open+0xaa/0x150 [ 0.786240] file_open_name+0x133/0x1b0 [ 0.786746] filp_open+0x27/0x50 [ 0.787244] console_on_rootfs+0x14/0x4d [ 0.787800] kernel_init_freeable+0x1e4/0x20d [ 0.788383] ? rest_init+0xc0/0xc0 [ 0.788881] kernel_init+0x11/0x120 [ 0.789356] ret_from_fork+0x22/0x30 Signed-off-by: Sven Schnelle Reviewed-by: Jiri Slaby --- drivers/tty/tty_io.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c index de06c3c2ff70..1ac6784ea1f9 100644 --- a/drivers/tty/tty_io.c +++ b/drivers/tty/tty_io.c @@ -1224,14 +1224,16 @@ static struct tty_struct *tty_driver_lookup_tty(struct tty_driver *driver, { struct tty_struct *tty; - if (driver->ops->lookup) + if (driver->ops->lookup) { if (!file) tty = ERR_PTR(-EIO); else tty = driver->ops->lookup(driver, file, idx); - else + } else { + if (idx >= driver->num) + return ERR_PTR(-EINVAL); tty = driver->ttys[idx]; - + } if (!IS_ERR(tty)) tty_kref_get(tty); return tty; From patchwork Fri Dec 9 11:27:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Schnelle X-Patchwork-Id: 31731 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp717272wrr; Fri, 9 Dec 2022 03:32:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf7LS48oSEEwMhbyJgjmCssX61HqVmxeFuVdUHSANeoB3eKB1ps0Q/c0xsty1Du/qwLkVvAq X-Received: by 2002:a05:6a20:d903:b0:a3:c448:b03a with SMTP id jd3-20020a056a20d90300b000a3c448b03amr8082407pzb.20.1670585569934; Fri, 09 Dec 2022 03:32:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670585569; cv=none; d=google.com; s=arc-20160816; b=ChxEcbWqxb7xtKYhgaxIW1N4Ha4CTxFNfhO4X6aCCqAivTClImO90cNq4Bt/VRNw3C qUYlH5shaATVfEBNMqql6GELpylwiMg6VI3u31fMw5htU6sSe6yA2ebIfU4PqXgTDPWN lw0+DAAjGDr2mzggAkxMl/J8cryvK1ToPtPcgHCryKng3u7yLUT+EQVGjG/tvIr9Q+xi AQHAPi1D06TXyo8X1WGgMgGQo56YQob6TXc6VcSDTLKeK9eVlFAp4aiZABZz6ok+0Etu oCg6O0UT8xvi98e/syMHg0wC1WuXxy9bInNm/WGgC8kj0o/EnPQztIUanwuhxy2EY/oz eL9Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZSlPhvT/Gwt3QBnevDKmiLdO/2ODroa0WQHJW/W3Nzs=; b=G4TtnCgutCkB8tz0fr36zTfIgfcY+cSLJ71jp5/CZ3emJWMF9f+61ZAokixhDRBfFU vQxD7mhMcQ/HpBoP2xktjTwQzS9TLm+yXcH2jOSmlG1TKNJY6jGF2OqW7LO7TZFlYKzV 3QKz0nWojT6nJKm5ziQwAIsGRZP2hbzMevwJ318JmFqU0otgrZUKlaMa1Cy2Ykbs7eFM W/btEY7uSGiuUyXb8qv1sb+FpJJer728psLdkoGdEXRAyvT/oDJUdzjk+ToQpp5BAEnN 4kgWgWxPEJrRhq9AnHnMZith+ylirUvOWs6w96+giiNmdGkXat/BPWmHWnQtIjb3/fGt yFJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=fxrW5Ykc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q18-20020a17090aa01200b0020cedba54fcsi1472692pjp.55.2022.12.09.03.32.36; Fri, 09 Dec 2022 03:32:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=fxrW5Ykc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229990AbiLIL2P (ORCPT + 99 others); Fri, 9 Dec 2022 06:28:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229968AbiLIL2A (ORCPT ); Fri, 9 Dec 2022 06:28:00 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E72A045A3A; Fri, 9 Dec 2022 03:27:57 -0800 (PST) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B9B9iT0003641; Fri, 9 Dec 2022 11:27:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=ZSlPhvT/Gwt3QBnevDKmiLdO/2ODroa0WQHJW/W3Nzs=; b=fxrW5YkcLRZnVzvUH6NfcsrYkynmfHCYiZkVsCXD9HGXtvlyjxBth+Zc4INNV40Kysht saP5obwcZcsh2jqduzG0rBxqm8XOzY9JmVuZ1T92+fLDLzMm9xw9LCeTwujmJMFwb+pw RE86tCTXEzPzFMDW8sOKYUhgFHgEMZEDUN7gSWiCUrOwLoXXacCw2cM2lj3xZUbMjFoM l+DV1EyGZsUU68fd28UaJDp1YeyKa9MJ0FhgC0quVfQ7oOIJw5sDQlx98CO0Uc4PqUn0 CRIU0ywV7gqcl/p/zkqZ+kL8+sSXspr/gWQpNPmZrfXjv2WhyJRwozfU9x3u0R3XezwF ug== Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mbxakfuf8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Dec 2022 11:27:53 +0000 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 2B8Kw6Mh004817; Fri, 9 Dec 2022 11:27:51 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma06ams.nl.ibm.com (PPS) with ESMTPS id 3m9kvbdvx8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Dec 2022 11:27:51 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2B9BRlsV44827088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Dec 2022 11:27:48 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D524620040; Fri, 9 Dec 2022 11:27:47 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C43DA2004D; Fri, 9 Dec 2022 11:27:47 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTPS; Fri, 9 Dec 2022 11:27:47 +0000 (GMT) Received: by tuxmaker.boeblingen.de.ibm.com (Postfix, from userid 55390) id 8656BE027E; Fri, 9 Dec 2022 12:27:47 +0100 (CET) From: Sven Schnelle To: Greg Kroah-Hartman , Jiri Slaby Cc: Christian Borntraeger , linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH v2 2/2] tty/vt: prevent registration of console with invalid number Date: Fri, 9 Dec 2022 12:27:37 +0100 Message-Id: <20221209112737.3222509-3-svens@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221209112737.3222509-1-svens@linux.ibm.com> References: <20221209112737.3222509-1-svens@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 2CbJFMTMhpsNEWfV2R6OLT-wR3N1LIQk X-Proofpoint-ORIG-GUID: 2CbJFMTMhpsNEWfV2R6OLT-wR3N1LIQk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-12-09_04,2022-12-08_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 mlxlogscore=774 impostorscore=0 mlxscore=0 lowpriorityscore=0 phishscore=0 priorityscore=1501 adultscore=0 suspectscore=0 spamscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2210170000 definitions=main-2212090066 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751735934458658885?= X-GMAIL-MSGID: =?utf-8?q?1751735934458658885?= If a user specifies an invalid console like 'console=tty3000', the vt driver should prevent setting up a vt entry for that. Suggested-by: Jiri Slaby Signed-off-by: Sven Schnelle --- drivers/tty/vt/vt.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index 981d2bfcf9a5..62c8a45ad731 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -3156,8 +3156,14 @@ static struct tty_driver *vt_console_device(struct console *c, int *index) return console_driver; } +static int vt_console_setup(struct console *co, char *options) +{ + return co->index >= MAX_NR_CONSOLES ? -EINVAL : 0; +} + static struct console vt_console_driver = { .name = "tty", + .setup = vt_console_setup, .write = vt_console_print, .device = vt_console_device, .unblank = unblank_screen,