Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3543396pxj; Mon, 24 May 2021 09:02:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMkst+4dabzwr2MwL7I7h9tb3qTn+OFIEWpxfHmMVoQtmt3hMFz2fIcQNDTALVW1CfSYs4 X-Received: by 2002:a5d:9959:: with SMTP id v25mr16854674ios.85.1621872167529; Mon, 24 May 2021 09:02:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872167; cv=none; d=google.com; s=arc-20160816; b=qW2aex7jIIfMcFPllpBupYLVhEst09DF2pDwEJf5V02tJDap1bnxewgIEqFSguWoaN r1pDHoCPhG5xdeskazAUWMY0dZz9Cb9IvCud/7fd/lYzYdI9vuMGMsBhvwtj1kTO8vIl TpvWBmxzIukCioPQys+p4W1KG0n0r8r4HHc6lPIlZV9mW0DcLR5PSQkCOKc9fbrObHX2 OrE1v7b9tHz1LZShIjo3gxb4EOxnkShoB4qv7ZTFWBLRRpx0wsohHrp7UNod0AR8SW2e CoVqUIMaR/9XFUZ130g7ngaQ1XEuqN4M3wNdosNwgnsX2+s13DisGZoGOdJfg6xIblct fOWA== 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=COe3gYptXQ34AsdWu8k+d0K/3dEoEFxsVasRaBdPvrc=; b=LoiyYHJOQdgCD6FQAXJh2sNBXhTvchjOGi/78HO79HjYFbHH0xm3pUiF8BxAU81086 z312715hdC7TQfQ6lVjsEKZmTozhiGtVW/miAm3Oe9+089Gxm+vLHcqkk2ZMDlDOyETg EYwE+kYl9lg7vfT3+YRetCab0I/O+E0Ix71fYQ2yaDppAdaMx7LQZmelUde9ZPAJsc9k 1Dj0vQdnlfHru9ENqpHu0PsvFhlNUeWyj44kymtKAIhKbeVTsw0dJJ+elWRPXZpUCy7I RJXIzdcUlx8Lxaz5idpa8KiIM2VZeYlJ9CtAb/2ZxL38LZiNkG5RyrjlJOfMEeT7t87g 6a7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PZqwRw7W; 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 z14si14923073ioq.100.2021.05.24.09.02.30; Mon, 24 May 2021 09:02:47 -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=PZqwRw7W; 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 S233783AbhEXQCN (ORCPT + 99 others); Mon, 24 May 2021 12:02:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:38928 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235074AbhEXPzp (ORCPT ); Mon, 24 May 2021 11:55:45 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E188B61447; Mon, 24 May 2021 15:42:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870925; bh=L/xPLGm/qLV+YqHAOHzZxxZtnGQFGf7t85dzR4tXEho=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PZqwRw7WjTWeNQrq47jtvFzF0FGL87kFUtOjC3D4XygTSPC0wJE9cwS9nJG8UJic/ 4wtWSZRgzHFtPVQ6K6/gKzzwtB/esvuHXlIKytaNeGKITbmBKGGfROvsbIZ1NAMq4I +Cw06HUiD/SL9busbJ+iwwX2EaGpu47e2OIqnzqM= 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 5.10 098/104] tty: vt: always invoke vc->vc_sw->con_resize callback Date: Mon, 24 May 2021 17:26:33 +0200 Message-Id: <20210524152336.098232142@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152332.844251980@linuxfoundation.org> References: <20210524152332.844251980@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 @@ -1172,7 +1172,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 @@ -2031,7 +2031,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);