Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4459470rwb; Tue, 6 Sep 2022 07:51:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR7qOECC9VO0C1keSHNxaFYiVVKN86Y0eceTyMD9y/jOXFXs871FOSw+NbdhDiaJvGPPMKcz X-Received: by 2002:a05:6402:138b:b0:447:9f18:dbc5 with SMTP id b11-20020a056402138b00b004479f18dbc5mr48377915edv.113.1662475877569; Tue, 06 Sep 2022 07:51:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662475877; cv=none; d=google.com; s=arc-20160816; b=IZ5+4jLs+obj9sjKqfNgGeFdtvpH8O3Qo4lWPnT/u4iHpUYKHmDK0Hec1blgSi+Vyu cl4kBd4kGwuEYlxoud+E9njf8S0Y9IyYOWBMdFVqmyu0CwwaBUS2t+ccMGD4h+ABVA4i aFGaaJsbFCnvGYYcjwaY2sMdkj1gztsi9+SqjyBShZCDzsvxBetZLDprrBLQ6zu3adnY ZFs/A+IWlmYxVCduUC9YNXlH0g1TFq5e5RurldiVp+Eg3FbjsoREjiQ0TUmAnEaMTBpg 6r03nBWmVLep7Dcm7Ch4UW6gof+Jv+3rhq187D8OCCM0WdHhGoym3d2IpMzPuFTvUWX9 kaaw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CFc5UUrz58Kig5aoOLamByMJm5i32ADVQxeP+vF0rc8=; b=scnZZXVUIU7fsPpJ0JdTnL6yV5TR+6/ZEJ346ivj2nld/fnxGH7wsMjFSsgZ3f6QDy Cf0/wcQoI/L0avjO6WCB1lFsRB8Gw/bmlTb9YVjCYW3kJqfC10fvFnuaACvzpF3hFgqf myUOw/w1GkiYqyBG484XuYcKJfvLTaLMr5TdQRkKQNeSx77FONcpwluoD5nxr4W47LHW /coTO+kVO/Kh6cnP8TK+f0FzZPEcJh/ox0Hl+8BWmodcvVbzDy3rQ5fTNf/5vOnjREqE WsI/jXBxpjVQc0UKsijT9VE6WvdDmDfdWMNzSzuj+kY/9+LpjU4N4pa0BH7aKPwkpM70 sgGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="TV/mDjjl"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i16-20020a1709064fd000b0076daf135b26si4111207ejw.791.2022.09.06.07.50.50; Tue, 06 Sep 2022 07:51:17 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b="TV/mDjjl"; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240247AbiIFOHa (ORCPT + 99 others); Tue, 6 Sep 2022 10:07:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240183AbiIFOF3 (ORCPT ); Tue, 6 Sep 2022 10:05:29 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 295977DF48; Tue, 6 Sep 2022 06:45:33 -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 sin.source.kernel.org (Postfix) with ESMTPS id DB29BCE1780; Tue, 6 Sep 2022 13:44:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C2DFC433D6; Tue, 6 Sep 2022 13:44:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471864; bh=7wlCsrVRDBxNF3WWLtS5SZ44/JlKUKUftG/22O5o1qQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TV/mDjjlula05p8FhRZxA4sRLihzQiWzTgGKxRJh4ErEvUZv+7wB6cMR2eUhAbr1t vVEdermZp9tBpMxLJKdkd0M4pMcK72ZUVy+mywserQ4L77cTjm9/OnoLvddq3iN9zS H1VMUJ1PXX+1lgNKkazDb4Anx9TztQNMRRwhKWBY= 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 5.19 064/155] vt: Clear selection before changing the font Date: Tue, 6 Sep 2022 15:30:12 +0200 Message-Id: <20220906132832.139490964@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132829.417117002@linuxfoundation.org> References: <20220906132829.417117002@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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 @@ -4662,9 +4662,11 @@ static int con_font_set(struct vc_data * console_lock(); if (vc->vc_mode != KD_TEXT) rc = -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 = vc->vc_sw->con_font_set(vc, &font, op->flags); - else + } else rc = -ENOSYS; console_unlock(); kfree(font.data); @@ -4691,9 +4693,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 = vc->vc_sw->con_font_default(vc, &font, s); - else + } else rc = -ENOSYS; console_unlock(); if (!rc) {