Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4482454rwb; Tue, 6 Sep 2022 08:08:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR7lx0YYFYYlqBqNaPTYfDp20hi7U3+CBd9aUI2N0NGssP0Il8k+HpPC+oq1g0OkSUZYmcl3 X-Received: by 2002:a17:902:9894:b0:172:ca00:f305 with SMTP id s20-20020a170902989400b00172ca00f305mr55237016plp.107.1662476883082; Tue, 06 Sep 2022 08:08:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662476883; cv=none; d=google.com; s=arc-20160816; b=rGTjsauEqvRKSggRzf62WEv+OfzE4D2ZiFnKnxc8ekUodo/VhhUWX+EC6a384tXcMY ZUpoHV8QoHmhqQSYQ3Za5cOgPYrxYhqVjiVOiTevLbTFMnGYjZ9Yn2I4TGrjjkPI+oEG SbSREyeNAsMkMFgVrbGwcSO8dT/bFW9bJAcbkl7ppQy4Jygi9MZXAQK3HliPT5v507zi NF4v9MmbtkceArFt2RI3eIkQ9gt2bToI/ZAN93J8+9vAgqYSnJAMVgXvFG+BW8qWmw2P KbEB7HXColc17jGfVEcS7z13+41YjY4elcc2QSFeDo3MZiKHWlSdhDxf9zWd43HjPW1v C1ww== 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=ywFUmxSqRD+i/v0tKp2k5g5KYg9hdqiX0IcpZziggK8=; b=J5Rl+uocn6pkpoS5GfhmaR+ZU/0cEhIcMOGt/hfUzD+TEE4yaT2u9JbPmJSc60uWWi scWPILq756EmzEdLqof0Bkjgj7Mrk3Z4fXQk1ghkEt54T3+3jed+xBnsZiegh/TcL4q3 CLQ8lcthf3tvnQOsIowxkH15g1m0UTVr1cb4g42t8SsbOrtS24WDTE6nhTKFzMIbfWWA M4eXQdhVBebgn8bJh9VPxC6T1La56xf4RCWeTzGsEWqflIE+F+JoEeNHlsM0vD5WAl9+ 3ZLLYPA7pYIumWAnnKVr+bSrh49H8be/JOBntbx5s4b8jzyc5zP3i3RjBjBzW+NrytYb MKmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=iKO4QeDO; 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 me6-20020a17090b17c600b001fe0682652esi16755724pjb.184.2022.09.06.08.07.30; Tue, 06 Sep 2022 08:08:03 -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=iKO4QeDO; 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 S234450AbiIFNkt (ORCPT + 99 others); Tue, 6 Sep 2022 09:40:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230056AbiIFNiE (ORCPT ); Tue, 6 Sep 2022 09:38:04 -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 88905186CE; Tue, 6 Sep 2022 06:34:53 -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 0492DB818B8; Tue, 6 Sep 2022 13:34:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DB78C433C1; Tue, 6 Sep 2022 13:34:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471280; bh=loIo7ma84uLhfBjM/NLHnlvdJvRHkXpuI6E7j7xEeJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iKO4QeDOums61Y+nfyiOh0zsq6cVHhTb13sgBrW3kEgSKu6azVKq/AhqMTOcb8D7P pCWD7dK7S1MjNweu3zIvYUci9YfFtedu7BO1+zgbYndSrB5zk9BcpVFWsPru6W4FhZ vO1y2j2s2ks6jyLo1qAQsWvlldo3Rjq+EPXcdWZM= 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.10 24/80] vt: Clear selection before changing the font Date: Tue, 6 Sep 2022 15:30:21 +0200 Message-Id: <20220906132817.941273322@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132816.936069583@linuxfoundation.org> References: <20220906132816.936069583@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 @@ -4671,9 +4671,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); @@ -4700,9 +4702,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) {