Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp6830276rwn; Tue, 13 Sep 2022 09:32:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR7VMj7Dnr60SPh2Qpwl62UZXJSgwCGkuKsI5P+P5azDq3DOXyEIhCAvWsTEXG2qVX2Zt6R2 X-Received: by 2002:a17:902:d502:b0:177:f287:269d with SMTP id b2-20020a170902d50200b00177f287269dmr26866262plg.140.1663086726896; Tue, 13 Sep 2022 09:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663086726; cv=none; d=google.com; s=arc-20160816; b=kBy791MWf9oTWmO9YLeqYEoAM8fBRzdm/RmzIFtrW9x19/6BUmJK/kPD8FALUNztFW dZ6gLNBQ0T47xk1z0zXA9WdLUGkosZZ914QbzULewV2z5Ks0/TJc7Q/sV7NoXHpyc1Ol 2w8By1locORfft18YBdIQAC8Z5VAgFj2mdgO/EgvG942iVXgKC2P3bqvCjJ6a3BItEGa RZxMlgtpnbqmGucdROda9Xvg2zMXpTgwQrGnxcdDB1qKJx8a9XuOvTLqbd9ySmazZ2PY v5OLe/oUusmCoRdeecYFkFj5EA3gZS2GBChcQcG7dRG6oJ+k/Jj+blJmxDR3QQKwNM8G qZ+A== 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=5fGgI1nCrfOmGBNGLaLVBdI6izX+OdWnY7O9ughT+QQ=; b=qRAUGsS83ckqssO9kRoyrKBeoRfy3Qf0ezJ2IC0iaqKprWL8iQGWeL593pvfezSBaw 9OKkwHJ/0uVcAh5gXZrB6EV2mZ31BojuypFlhKasAAyo49ZiRESBZ9lFYTxvyUpeJ8E0 zQrT/2vbhtUDE+6FmALSerbB7jiGRka+WRVxI4dSwIL5AHC1k5WjPAKOF8+84mGRm8nM 9XfWJmA+X02tJvgpioQAo4mgLiPSawicXcr8rRY82qcMgkNla5X3Jauo6APjgbIu7HVt ENhXjlJX+Gjrw9bHbfuhZhPV3VNw2RCU8Hj8tPThAmqEsQsnreIKXIjWfXgJFj/YsrJv hlCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=aa+tKaQO; 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 o10-20020a63e34a000000b00434dfe7b75esi10216310pgj.223.2022.09.13.09.31.48; Tue, 13 Sep 2022 09:32:06 -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=aa+tKaQO; 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 S232120AbiIMPdO (ORCPT + 99 others); Tue, 13 Sep 2022 11:33:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236479AbiIMPcR (ORCPT ); Tue, 13 Sep 2022 11:32:17 -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 1243D6CF60; Tue, 13 Sep 2022 07:40:44 -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 5509FB80FA1; Tue, 13 Sep 2022 14:37:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD1C3C43147; Tue, 13 Sep 2022 14:36:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663079820; bh=e28Tqsl9X5LrOAMbqEPA8WEGAyDGwUMRE/iZx5Q4Yck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aa+tKaQOl16/2ds1gSCEuJVgkR4fkK8buQ7+oGyZpxgaKha47FSQcM1sAK9U2yJa3 MBeRuXhv/URF2WyN1iU82bHRdLSaFPGfAx8ZgPuQBSpD4iHRBzLqe5kfma47siBAtM Q+FtSFq2GwiDSBHXtCV4aEsQUSJaSfPEW+ihoeqA= 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.9 06/42] vt: Clear selection before changing the font Date: Tue, 13 Sep 2022 16:07:37 +0200 Message-Id: <20220913140342.566361976@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913140342.228397194@linuxfoundation.org> References: <20220913140342.228397194@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 @@ -4183,9 +4183,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); @@ -4212,9 +4214,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) {