Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3543200pxj; Mon, 24 May 2021 09:02:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2RcB6rCiGbElUO+dtfPSxax36WMfMPxSA/awErfZtuAwXRyZItVFgSWdZXGNocvY9j7U1 X-Received: by 2002:a05:6638:44b:: with SMTP id r11mr24838383jap.85.1621872155082; Mon, 24 May 2021 09:02:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872155; cv=none; d=google.com; s=arc-20160816; b=Rf6Pn0e5lzWH77wFdIgZee0thqy94dKfDxk1nuyWnm/eOWnaaRKaZ4hHO6Hid3dGFE hiIhDOiJpz0KTqxactF91tMR7qf9SBVGjGPHVyp3Pq99IlqIrtWEl84zVTI0I2+lT+gl WwEePYytg9cVK/tL/5Xh/FztZNIxbxyw0ZERPvn0jIbG0dsRMbpc0QQGCZIikGbbvm7i /QDv8oXujnEhbSF2K43rfnVVV9TTwm33i1AVWbRKTajad1siq9qY5H1sGEfbE+FD5TDJ O4dTChxrWF4Ayrd26ZzdKw5pfBqaTWEjIhta0bsS/cWaDi8kVZ9C6fglhebIYU+sm/7D E1pw== 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=/53WJEZ75S1B231VwjZiIgLfYNKFzmb7G/zXkYlYGn0=; b=Aq5fxYaHl7xGIC3DPI4yHQjY8xEPk/nT9Z5OfqiBdcY0L6wGuoKSjfT/KJl4Q9F5IP vWEXGLaZ/PNXghkkXdySfx7ZK8UPwLDIM9bUBjATnCjbNwmluq31al7STx+HSQzRkuk/ 9yAD7qbWU5QB7ipl+QjbtsDhz1/GOlvNrOB4OfYfq5ckkeAPcsSwCEgjHCM2WmpUyPb2 prUZ76j+ZXd38Q9LZAjLjp1DQhGqxmiNWDcdEwa6DuIirNES8DM1eMY1I+fC4d4EMLUb 3PTfx7Y2D38WkKwVuMK6/AKYSGAmqmZ9OsHh7oFSa7ZJlhj2mH2OWoywu1jThctnvqtA 266A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="0M/rWghL"; 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 p10si14291769ilq.156.2021.05.24.09.02.19; Mon, 24 May 2021 09:02:35 -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="0M/rWghL"; 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 S233770AbhEXQCz (ORCPT + 99 others); Mon, 24 May 2021 12:02:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:41136 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235245AbhEXP4J (ORCPT ); Mon, 24 May 2021 11:56:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B4FD961406; Mon, 24 May 2021 15:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870955; bh=nBv1sJiOQyi/w8aksGlAB21yWZGy0Ta74Fyx7UUtGm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0M/rWghLj6ozf/1CVUl9OJCBoWCQMkjB3n8Dkd5kiqvRcUuAz+w1sdMQuE8I1grii df4sUslE0vWVtOzj8okxaj1NgpYIvF6ZIoUbVNT59aHqdBJj1vinQUZaThqsoCoIvV OsdGkkJdcvn6TQsVPHJD3E4iyum4bq+4uYq0fpCQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Maciej W. Rozycki" , Linus Torvalds Subject: [PATCH 5.10 095/104] vgacon: Record video mode changes with VT_RESIZEX Date: Mon, 24 May 2021 17:26:30 +0200 Message-Id: <20210524152335.997697627@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: Maciej W. Rozycki commit d4d0ad57b3865795c4cde2fb5094c594c2e8f469 upstream. Fix an issue with VGA console font size changes made after the initial video text mode has been changed with a user tool like `svgatextmode' calling the VT_RESIZEX ioctl. As it stands in that case the original screen geometry continues being used to validate further VT resizing. Consequently when the video adapter is firstly reprogrammed from the original say 80x25 text mode using a 9x16 character cell (720x400 pixel resolution) to say 80x37 text mode and the same character cell (720x592 pixel resolution), and secondly the CRTC character cell updated to 9x8 (by loading a suitable font with the KD_FONT_OP_SET request of the KDFONTOP ioctl), the VT geometry does not get further updated from 80x37 and only upper half of the screen is used for the VT, with the lower half showing rubbish corresponding to whatever happens to be there in the video memory that maps to that part of the screen. Of course the proportions change according to text mode geometries and font sizes chosen. Address the problem then, by updating the text mode geometry defaults rather than checking against them whenever the VT is resized via a user ioctl. Signed-off-by: Maciej W. Rozycki Fixes: e400b6ec4ede ("vt/vgacon: Check if screen resize request comes from userspace") Cc: stable@vger.kernel.org # v2.6.24+ Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- drivers/video/console/vgacon.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c @@ -1108,12 +1108,20 @@ static int vgacon_resize(struct vc_data if ((width << 1) * height > vga_vram_size) return -EINVAL; + if (user) { + /* + * Ho ho! Someone (svgatextmode, eh?) may have reprogrammed + * the video mode! Set the new defaults then and go away. + */ + screen_info.orig_video_cols = width; + screen_info.orig_video_lines = height; + vga_default_font_height = c->vc_font.height; + return 0; + } if (width % 2 || width > screen_info.orig_video_cols || height > (screen_info.orig_video_lines * vga_default_font_height)/ c->vc_font.height) - /* let svgatextmode tinker with video timings and - return success */ - return (user) ? 0 : -EINVAL; + return -EINVAL; if (con_is_visible(c) && !vga_is_gfx) /* who knows */ vgacon_doresize(c, width, height);