From nobody Thu Sep 4 03:09:59 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 C7E5EC54EE9 for ; Tue, 13 Sep 2022 15:08:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235433AbiIMPIG (ORCPT ); Tue, 13 Sep 2022 11:08:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235361AbiIMPGT (ORCPT ); Tue, 13 Sep 2022 11:06:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 672A974DC9; Tue, 13 Sep 2022 07:30:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2333BB80F1A; Tue, 13 Sep 2022 14:30:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8835AC433D6; Tue, 13 Sep 2022 14:30:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079428; bh=fVTPf3kZWUEOzXkJeJsw7Qw1cjNO7q4MAtA0lzT95Qs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PD7QvzD3rywL1xBJ6C/lWaOkPluZhga8Qb/eDJOHp7dpLj8BEujG229zZZ0zq/by5 di5pU4knr7CX5NZQ9ORSbk683iJ3Z21EDOWcphcrp7JQXM0insykqolmi3WdUSEFGO Qp+JpxzY6kWe6pmuQyv4XMLOcdoFuERAoTyxSKQ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+14b0e8f3fd1612e35350@syzkaller.appspotmail.com, stable , Khalid Masum , Helge Deller Subject: [PATCH 4.19 22/79] vt: Clear selection before changing the font Date: Tue, 13 Sep 2022 16:06:40 +0200 Message-Id: <20220913140349.970511449@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140348.835121645@linuxfoundation.org> References: <20220913140348.835121645@linuxfoundation.org> User-Agent: quilt/0.67 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" From: Helge Deller commit 566f9c9f89337792070b5a6062dff448b3e7977f upstream. When changing the console font with ioctl(KDFONTOP) the new font size can be bigger than the previous font. A previous selection may thus now be outside of the new screen size and thus trigger out-of-bounds accesses to graphics memory if the selection is removed in vc_do_resize(). Prevent such out-of-memory accesses by dropping the selection before the various con_font_set() console handlers are called. Reported-by: syzbot+14b0e8f3fd1612e35350@syzkaller.appspotmail.com Cc: stable Tested-by: Khalid Masum Signed-off-by: Helge Deller Link: https://lore.kernel.org/r/YuV9apZGNmGfjcor@p100 Signed-off-by: Greg Kroah-Hartman --- drivers/tty/vt/vt.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -4518,9 +4518,11 @@ static int con_font_set(struct vc_data * console_lock(); if (vc->vc_mode !=3D KD_TEXT) rc =3D -EINVAL; - else if (vc->vc_sw->con_font_set) + else if (vc->vc_sw->con_font_set) { + if (vc_is_sel(vc)) + clear_selection(); rc =3D vc->vc_sw->con_font_set(vc, &font, op->flags); - else + } else rc =3D -ENOSYS; console_unlock(); kfree(font.data); @@ -4547,9 +4549,11 @@ static int con_font_default(struct vc_da console_unlock(); return -EINVAL; } - if (vc->vc_sw->con_font_default) + if (vc->vc_sw->con_font_default) { + if (vc_is_sel(vc)) + clear_selection(); rc =3D vc->vc_sw->con_font_default(vc, &font, s); - else + } else rc =3D -ENOSYS; console_unlock(); if (!rc) {