Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3527841pxj; Mon, 24 May 2021 08:42:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5Lp8iIQu5l7EmFnk2dqX6p5UH0Zrj1oip3F9ck2eCop3UU97D9w6cZXVjJuGaFA48pB1a X-Received: by 2002:aa7:d598:: with SMTP id r24mr26842681edq.250.1621870946060; Mon, 24 May 2021 08:42:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621870946; cv=none; d=google.com; s=arc-20160816; b=fB9UEwud9FZ/r/jiFfRUxR1a0GnFhAiS694NrXXVmUeu2GFYGMtKOejszfZ98rjVGV mkvQwU3ayNVwUVeSotQY04ehoY6CZEWXjGu1heD+4QxOv1HTXrb43XgFGDsXv6WR0J98 lAfc5ayMpzhpJv0rcATw3eFu2wlgqZPJQXJsCLsbSpNcfQlSVmCoeQcV+PDurYIAdmOO I2CddxR1HWfzAYsugpnA27OnlV6A82a2nIJzWfZHKh/yqhiUYZNk4Rkowp1v6TIwzHx7 YCetuA+GmavyIS2SkuQoDC+LDpDcGAoY7K5KSSN+4frgUqWqKqva9TeMjtsdpByhvTTF QJOg== 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=Oz1zsc3dJa877+SRshhOV8H7Jqi4lbX+Gz+1mPCPGsk=; b=R/3pMvRiEQrYA7fsHf18O0bIZLPmwjGFhIwUbwjfyQlyssHUmmvfHEYw2x0WFPQWZa iomgyV4aDMcca/QPYzbnOOdfcISNsVk+L3DyOB38sRZjr6rdgpAx/sN8TpAFjI0Y0Uz4 jvhPRIBn1ot/jdVpruR3rtajdKfbLS5tGd4S5KOIXCR1blZUWGLwLUkxIHcDg+ipqiZI fXt4NOO+q05RAHJHlsUjOps30F2of9klfo23hEL/l0dkoQUj8/yJxWNqCHLK8g2IDfNg vGJvQoJqdPl2rasI9hKQkLWjm4O3aSxFV0ilGnG44Nx9Pi/fvqZ8Uan9Y4US5TxxHw2Y 0m7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sG2hVx1I; 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 hr15si6918707ejc.526.2021.05.24.08.42.03; Mon, 24 May 2021 08:42:26 -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=sG2hVx1I; 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 S234236AbhEXPjO (ORCPT + 99 others); Mon, 24 May 2021 11:39:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:50504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233889AbhEXPgX (ORCPT ); Mon, 24 May 2021 11:36:23 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6FA916140E; Mon, 24 May 2021 15:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870359; bh=SsbNvQaUdj20wLzoljS0f2x1A3hb77seJHzsZL169dQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sG2hVx1IJLFkWk/lK0WBMsn1nszMcZwqeFkxpRl5Cq8bDSs+/yrcKui0EDdQQZd3E R3fyOQ0H68AWfAGSWf6X8jVUJwXG6ygwQmdrIIlXusGlddWoiEKxENZFLwFMmGevrb LEJdfb+lIgyA9Nv57Iwg2dN+aoQXblX19p8BJDKM= 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.9 35/36] tty: vt: always invoke vc->vc_sw->con_resize callback Date: Mon, 24 May 2021 17:25:20 +0200 Message-Id: <20210524152325.298259254@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.158146731@linuxfoundation.org> References: <20210524152324.158146731@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/console/fbcon.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) --- a/drivers/tty/vt/vt.c +++ b/drivers/tty/vt/vt.c @@ -838,7 +838,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/console/fbcon.c +++ b/drivers/video/console/fbcon.c @@ -1986,7 +1986,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);