Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3534815pxj; Mon, 24 May 2021 08:52:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMn3Qrgon/VZ3REwf03VTnJcGsnnMK8j9G6cMr/ysRISbjaym99HG85TBVVAgnVA9aOxIc X-Received: by 2002:a6b:f118:: with SMTP id e24mr16517377iog.125.1621871529447; Mon, 24 May 2021 08:52:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871529; cv=none; d=google.com; s=arc-20160816; b=k2og/Syzr/CArnuAWRiZOES+FQKTX0cTiR3SykQrjYiwHzHiOxR0H3g3dHiYqkQ0Ic x0wU7/IL34J9j4Sr0S3tlMUYcW+bR3gfHmXkSBWva5F65yYS37ND7b4bGGMnKS9e6LHO 90bh1RFjWtqTlpIsGCF8nyiT1SWup2S+PVB9R1EEtRD+C0WAm5jUUwIvORhTj1rVE9WS ebrNXo/2pSK/Ra0MQq6PliY1s3TVOBacYkzwucL5F+AmFI1n+RRKTq0A2Ko+7YhNQLtI Id56TiqF6YdaNWgS95fPj5C3e8B7u/42PsWflaSyFT0oHv1rhujeh+4DeBiQJRkS65Gn i9xQ== 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=VmU9Fg6tAnWK0CUs+KwLRmq1RJWnr2es5t76dfWmtC8=; b=PKTw1JaMN3byepIlj427ztDrp8EgCZrcMdhI5fSv6DX7Ha15tFcDHjdaCA1Zw7T4dO Ac3byCOw/P7NNosyMfc41WrAFBtZ+eIRUFGaTKnSOLvwvzbATlK8cyh0Cxo8Oy2R+x9F UA8NqHDIGNS1Cq8kv1RYn8g+/NtwpgoeSsvlblGXLCtmXVm2mw5OUkQPu0mBgRi80fNX HimtwSHc8Bb5zjT2+SGAY7PXKYlDrua7u5wsOdTybHckp+cWg0YUspmPtqcaB+FVHY2f vHBC/EZKHEMvjIZ6wCAi5h/ITN+okPzdIXkyM0sASRK7K6eutESzxKBeyLd0zi2NvPi0 ivNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="GX/WF4wS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si13809832ils.114.2021.05.24.08.51.56; Mon, 24 May 2021 08:52:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="GX/WF4wS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S233923AbhEXPvN (ORCPT + 99 others); Mon, 24 May 2021 11:51:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:33886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234555AbhEXPoX (ORCPT ); Mon, 24 May 2021 11:44:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AAFF961458; Mon, 24 May 2021 15:35:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870552; bh=4ph7AhNTIjy12h3LtzFs5aVxmWVCpkURGY/4sV0p0gk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GX/WF4wS97Xfv2/GgNkal5mlsAenUCF3r82RkzWqZkg5oS2PdwCJ5LLWNTnSHyhqu lcT99ge50ewOoAE+mVx6wbD4gzGwmPlrMQ08X43xZWG7oFlctjOLOVpXbG6RGzr9HS 98EMBP5BkkxcSlVmvVFNvuvrjuKaTAsnu3fv7cRg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Linus Torvalds , Tetsuo Handa Subject: [PATCH 4.19 48/49] tty: vt: always invoke vc->vc_sw->con_resize callback Date: Mon, 24 May 2021 17:25:59 +0200 Message-Id: <20210524152325.921616003@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.382084875@linuxfoundation.org> References: <20210524152324.382084875@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tetsuo Handa commit ffb324e6f874121f7dce5bdae5e05d02baae7269 upstream. syzbot is reporting OOB write at vga16fb_imageblit() [1], for resize_screen() from ioctl(VT_RESIZE) returns 0 without checking whether requested rows/columns fit the amount of memory reserved for the graphical screen if current mode is KD_GRAPHICS. ---------- #include #include #include #include #include #include int main(int argc, char *argv[]) { const int fd = open("/dev/char/4:1", O_RDWR); struct vt_sizes vt = { 0x4100, 2 }; ioctl(fd, KDSETMODE, KD_GRAPHICS); ioctl(fd, VT_RESIZE, &vt); ioctl(fd, KDSETMODE, KD_TEXT); return 0; } ---------- Allow framebuffer drivers to return -EINVAL, by moving vc->vc_mode != KD_GRAPHICS check from resize_screen() to fbcon_resize(). Link: https://syzkaller.appspot.com/bug?extid=1f29e126cf461c4de3b3 [1] Reported-by: syzbot Suggested-by: Linus Torvalds Signed-off-by: Tetsuo Handa Tested-by: syzbot Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- drivers/tty/vt/vt.c | 2 +- drivers/video/fbdev/core/fbcon.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -1169,7 +1169,7 @@ static inline int resize_screen(struct v /* Resizes the resolution of the display adapater */ int err = 0; - if (vc->vc_mode != KD_GRAPHICS && vc->vc_sw->con_resize) + if (vc->vc_sw->con_resize) err = vc->vc_sw->con_resize(vc, width, height, user); return err; --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2025,7 +2025,7 @@ static int fbcon_resize(struct vc_data * return -EINVAL; DPRINTK("resize now %ix%i\n", var.xres, var.yres); - if (con_is_visible(vc)) { + if (con_is_visible(vc) && vc->vc_mode == KD_TEXT) { var.activate = FB_ACTIVATE_NOW | FB_ACTIVATE_FORCE; fb_set_var(info, &var);