Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1031193imn; Sat, 30 Jul 2022 12:22:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR7vN2k07OYfzW9kkInrLdHN/J3CYsxyT85n21V6ANOT3rya1LzBxgk6i4G42IR9iSk2ToYG X-Received: by 2002:a17:90a:94c2:b0:1f3:2590:8693 with SMTP id j2-20020a17090a94c200b001f325908693mr11243972pjw.153.1659208976721; Sat, 30 Jul 2022 12:22:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659208976; cv=none; d=google.com; s=arc-20160816; b=vvxYRJHSjIBZEGAPq+QRcY8w2PZR+OopRnaVlGeBIL1Fv57fgtzAkvSdrezxH+nkEm mAFObL0FsFZJ5/Sbgb3BfScLFzj+j/63N9583K8X4FvJMtN67fDrc6YT9txlXVuWopOF olXAPaTMu3fJBrUdQgFB1giK4HwPOCgAcHxNml8hbKIaIMo9NSABCO8bWEu2yg5zlUe+ tz1WXeHkLsbjeadY8phqpYcv0PjyO/ozptAzwcj6n31CmL4YnqY3T4CWVh/1wwoWpuk/ q7h9PUUWYjowFQ8zJT0Pxk2rFEPF3jageDJ8VddIdCYAxnWoVEjTyWVwhVSnC0LPZ9UU q5cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:to:from:date:dkim-signature; bh=otsMurNw6rOau+TwQIVyBkqzIXRbcZn0BhUs1sbZAyk=; b=j+uBjTFcAux7XaDgy364bENOpGnwcKoWK9MiTn9julcjvLiuGGNrS1/Mq3sdutCfVM 4yIwpG2m2a2ZUTg+u9d2E6mtcJTffVSr7Z46rMO/oLfdAdtZAHAFFbs6HdW9hlISTmOb Z61g5gKBB9scUdV9GekHWkPDOhxlid/gZ0V2/yh1WS/de1v7rstKcjT1eWc7vtDh65E9 vRKsEjx+4U10kSHMxIvK/ILYbNXgILm79EDIctE0g6FRJmOLanXA6J4grm+ZBBk1uERQ R7CmYKb5gGELpZqM9KKLUf7ssXzS/lDPPn/u7n4TL9jcYoALGeMspXdpF8Tqv8UPzRDW pOHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=OqCn9F5V; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f8-20020a056a00228800b005184ae7a3c4si7906140pfe.140.2022.07.30.12.22.41; Sat, 30 Jul 2022 12:22:56 -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=@gmx.net header.s=badeba3b8450 header.b=OqCn9F5V; 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=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235572AbiG3Sue (ORCPT + 99 others); Sat, 30 Jul 2022 14:50:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235571AbiG3Suc (ORCPT ); Sat, 30 Jul 2022 14:50:32 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6426A442; Sat, 30 Jul 2022 11:50:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1659207020; bh=lb1Lf8t4xaY9Y+QKg74YnMmqnO8vj3n92i+vvXEUpGA=; h=X-UI-Sender-Class:Date:From:To:Subject:References:In-Reply-To; b=OqCn9F5VJ0ZzU4RrAfP9GQO5F0OrM8Tr8bjpKCvVtP4itsId9U2SMQTbAmFlDCSv4 uAr6BOqixGqUSFPLDv2CuOERLaIas5fIpEkntGPTE1xhbdvZj76ECEb3UHT9MGE46I apaqNGOPUz59Wbcxkkb6AAwzGUOK0dmgGB9//wMw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100 ([92.116.141.10]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MWics-1nxw0K0OL2-00X1Ln; Sat, 30 Jul 2022 20:50:20 +0200 Date: Sat, 30 Jul 2022 20:50:18 +0200 From: Helge Deller To: Khalid Masum , syzbot , dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, Greg Kroah-Hartman , Jiri Slaby Subject: [PATCH] vt: Clear selection before changing the font Message-ID: References: <000000000000bbdd0405d120c155@google.com> <20220729065139.6529-1-khalid.masum.92@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Provags-ID: V03:K1:aOJ76y6sEpgwGrwvfAja8bpGQzr5GQjvWnu3S4B6ULoT14KB9IS 1kW0r3aNgXnf0ZQAjCzdN524HpXX3bNj2x5ReEp6m58tt6DPYuZvv4Mp4cBAdqNzbOs2q0Y 4sFI7UcoIuDhGgXx46OTbL1STGIB/oqgyMpvnc2y9xNP/swxVQGZC9k0l9ByEZ7RDiDO1o3 BDKWJaS7E2t4JTbcihZHw== X-UI-Out-Filterresults: notjunk:1;V03:K0:9vIoM7sHZEo=:mhN90fgXNBTJz11SQ1Z03B z9UUnW1mIkP+eG+jQmGYjaUMTW+e5dZIhqh/PcpFoLYPlzvIRxzA7+Pc75i3B1LmzH9VtspTI L2GBlFOqO1W9/nMx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, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,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 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. Signed-off-by: Helge Deller Reported-by: syzbot+14b0e8f3fd1612e35350@syzkaller.appspotmail.com diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c index dfc1f4b445f3..3f09205185a4 100644 --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -4662,9 +4662,11 @@ static int con_font_set(struct vc_data *vc, struct console_font_op *op) 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_data *vc, struct console_font_op *op) 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) {