Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2358040rwb; Fri, 9 Dec 2022 00:45:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf4mWpnVAVWfxjLQVb6r7adS3GtXu1OysFngSrJ/MFNNndDFz+1EFhOXajnhte5gkf3Aq9El X-Received: by 2002:a05:6a20:6918:b0:9d:efc0:62 with SMTP id q24-20020a056a20691800b0009defc00062mr9466747pzj.10.1670575511324; Fri, 09 Dec 2022 00:45:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670575511; cv=none; d=google.com; s=arc-20160816; b=dgRxHyTCZYYowKbBQc3TgWOhBu3EzYp1X6nZcfOPr7Qgg7vkDc3rJOOlDG6AlRXBcy 4ufY0YoxETUm7pgyfmsedJ8ikHlALhkbQj9ID2G9/HuCCHhd+Dun/sn92lQCKl47fIvk R37m28BlD/WoTlm7gNKr7LJtD6KhsKU1pK2cnlC6JMmH6h+99Z3vY6s7V/xhgaMsHMGN XK0Z2p1doQoxlvq5NERlbJr9ZUQK2GX01QlZruaavSXhg9ddQuLZq0wM3x3Oro1P6rNB gIa1+kOqZGyCrtCFW49sOW/w0uG8yS26qH1k9xByWdHZWdJgE38k8Gb43BQx0Tb1djvV bJ1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=N3CyM7RoWAs+iQLaB4/0UEohYfeWGrXHD9ljZuxHYf4=; b=wjnI3xq+6UZ4JjNmmL8OkjUJjnq1tULxInkhBHej7/87bhhtLLIpGcZwkTarkWPDoN rMvp4gPvyX2TMhk6v4gBMrH3skqk0GBfmmj7xaWAQGya2sHTicgBfPN4Q/2jtuVxvUNd 9AtMwtEt4RjTPV90cV3LSohaJ9GW8AotEwRtpp5wug/67w5aSuFjhYf2BYq2MflejEPR UVBdUyT5WPxvOp1XOJp/BKumehYS4DkAXInjmvMctPo37BFoA9e04HOKMUhCzLnXkHDV 40csLDnDqsU/D9dDcrQU6gPrOleBZg/OektoWAPvkCBiGonn5VvDJdL4EZm5OxFWRRjs haDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b="DC/o3DTk"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q19-20020a632a13000000b00477bb3c1b5csi899162pgq.871.2022.12.09.00.45.01; Fri, 09 Dec 2022 00:45:11 -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="DC/o3DTk"; 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 S229985AbiLIIKt (ORCPT + 73 others); Fri, 9 Dec 2022 03:10:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229661AbiLIIKm (ORCPT ); Fri, 9 Dec 2022 03:10:42 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E14635E9C9; Fri, 9 Dec 2022 00:10:39 -0800 (PST) Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2B97qMti015249; Fri, 9 Dec 2022 08:10:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : references : date : in-reply-to : message-id : mime-version : content-type; s=pp1; bh=N3CyM7RoWAs+iQLaB4/0UEohYfeWGrXHD9ljZuxHYf4=; b=DC/o3DTkrz+zQQIJzVbo6k9N3IrxPe3BxbjFTyhKm5lFAXmMDTOxpyhDeDkSxsIyw9zu eqpbY2jm3XjYNDtT6dVdllkFv2qrSb2Z/Da3WblaSwpH9xukF2gi9xA3Eir3puo9JJin EgKxTffweWIlYVChP/MpO7MTiQebMlz7Pf5QoFCRWztsjjYjIQXT2timJHQt94YmP/0D iemsMIwjLyMX20+ZxQjJx+Lr0ZLSXVo+ym3FpdeaFWscLCWjqJBu4au0M4kDe5QV6gRo /0gqLtcBH99P8rH2rTtSQ7x3hKajOMjIy7Q+3gTltX+Gk/qFhdAzK4L5zDNjoDVmbbD1 Sw== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3mc10qgcpu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Dec 2022 08:10:36 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 2B8LRswX016423; Fri, 9 Dec 2022 08:10:33 GMT Received: from smtprelay03.fra02v.mail.ibm.com ([9.218.2.224]) by ppma03ams.nl.ibm.com (PPS) with ESMTPS id 3m9m5y5n55-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 09 Dec 2022 08:10:33 +0000 Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay03.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 2B98AVoM35455478 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 9 Dec 2022 08:10:31 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5C26B2004F; Fri, 9 Dec 2022 08:10:31 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 357652004D; Fri, 9 Dec 2022 08:10:31 +0000 (GMT) Received: from tuxmaker.linux.ibm.com (unknown [9.152.85.9]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTPS; Fri, 9 Dec 2022 08:10:31 +0000 (GMT) From: Sven Schnelle To: Jiri Slaby Cc: Greg Kroah-Hartman , Christian Borntraeger , linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: Re: [PATCH 1/1] tty: fix out-of-bounds access in tty_driver_lookup_tty() References: <20221207075236.23171-1-svens@linux.ibm.com> <20221207075236.23171-2-svens@linux.ibm.com> <6614f5d2-d99b-ea8a-f660-7a3433499a9f@kernel.org> Date: Fri, 09 Dec 2022 09:10:30 +0100 In-Reply-To: <6614f5d2-d99b-ea8a-f660-7a3433499a9f@kernel.org> (Jiri Slaby's message of "Fri, 9 Dec 2022 08:17:47 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: z4lDIhrSBh9TrSKJr_LbNcLTt7nao_jO X-Proofpoint-ORIG-GUID: z4lDIhrSBh9TrSKJr_LbNcLTt7nao_jO 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 mlxlogscore=841 spamscore=0 bulkscore=0 phishscore=0 priorityscore=1501 impostorscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 mlxscore=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 Jiri Slaby writes: > On 07. 12. 22, 8:52, Sven Schnelle wrote: >> 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. >> [..] > > Reviewed-by: Jiri Slaby > > Yes, this makes sense as a sanity check for all drivers. But I would > _also_ disallow registering such a console in vt: > --- a/drivers/tty/vt/vt.c > +++ b/drivers/tty/vt/vt.c > @@ -3075,6 +3075,11 @@ int vt_kmsg_redirect(int new) > * The console must be locked when we get here. > */ > > +static int vt_console_setup(struct console *co, char *options) > +{ > + return co->index >= MAX_NR_CONSOLES ? -EINVAL : 0; > +} > + > static void vt_console_print(struct console *co, const char *b, > unsigned count) > { > struct vc_data *vc = vc_cons[fg_console].d; > @@ -3158,6 +3163,7 @@ static struct tty_driver > *vt_console_device(struct console *c, int *index) > > static struct console vt_console_driver = { > .name = "tty", > + .setup = vt_console_setup, > .write = vt_console_print, > .device = vt_console_device, > .unblank = unblank_screen, > > That means dmesg would say: > Console: colour dummy device 80x25 > printk: console [ttyS0] enabled > > And not: > Console: colour dummy device 80x25 > printk: console [tty3270] enabled > printk: console [ttyS0] enabled Makes sense. Should i add that to my patch, add a second patch, or will you submit that? Thanks Sven