Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3529253pxj; Mon, 24 May 2021 08:44:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxSMNIAM+Mt49rUOgpKPV8BuREF2eL/OCfdAo7sT5drb3yU4T7arB9VKArsiSl/NBgIz0k/ X-Received: by 2002:a02:b718:: with SMTP id g24mr25474866jam.16.1621871078011; Mon, 24 May 2021 08:44:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621871078; cv=none; d=google.com; s=arc-20160816; b=NyeXGJuOnbhxEOnE0xxuQbTkZCXNmprtAVPJEgO8qkR0jCQZaCe7n8L9ONmhcOa+Of tJGVZJ4Q3K/1njP7mbYKFV+eNOMK3RA3MV4ZQ8Gqy+tgYhNfKjVKuTIbrR03Ou92NM7M wL4HE5cN6cnEFW8GfH1ZyV31spx/L0DPvHhpsWEDl5EhWW5+wqeZ2uEie3JGzmwMw2Ek v9JEDNgP0Zp9JUzuqSp2Vb4WmXPKyvWErN89/g3WTl/QG4MvWXHk53k/fTnWTqpAdld/ d4Xm6Lk86FRYavZkr7b+V7ycwSDed+P7j3VyuMbXJ6Z9TGIET6Wy6Q2Su9GPg6nllZf8 exjA== 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=jCnvVugJcvQw6jJe6Y8QhcPS16bIGi7G3RG4mbQiNdY=; b=z1g1OqrTlzsKqGpWOW3vsAYu6kcliEjKli0NCHfAv9eqXZtUZNMfnrXhaWmn9ZtJHc XwPvik/IdJ3Nnuu1v8JQQRcHJ4bFSKc/S5HTLwbdhKHXwihcwD0RlrDCvJzBUoYWJexQ 8u4nRWVgUtYPBt+Inh/5pwB6OMkLPdT9ITeEphH5y7ZY9KzZQGttTTFjJXqrY6K0FZax jJxb2hp1kVhWwkJGGfFQpipdUSUIgA110BU4+TSPtqcoB3YpQ21j2xyuYeBndo/8JnB2 2dZ+DOulPij6uxan3ua6AvUCL5d5jTfycGD1uU05S3a2v2azJtUxxe/9OwSQT1HT+Cyk EcJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dvfF+CEH; 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 u15si16778764iot.55.2021.05.24.08.44.25; Mon, 24 May 2021 08:44:38 -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=dvfF+CEH; 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 S234790AbhEXPoz (ORCPT + 99 others); Mon, 24 May 2021 11:44:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:56778 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233528AbhEXPkw (ORCPT ); Mon, 24 May 2021 11:40:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3A69F6142C; Mon, 24 May 2021 15:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870464; bh=cqS4uG4oymDwgtZch5JHh0WuULcKvxegNLzQvl62z24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dvfF+CEHgtANe5q1voma2wnneqiOdyEGPMplA0Kle1LLJKi8iBQ2ZQzXz53NvMkaR 8bDiIqRhQms5RVrPpteJGcjyq3E0ksUvu57sP9lhUII15WS6L2s9Mwna7HghowcTcD LW4v+wKxu7Wyb0S8+5jvTOT3Ah/sQ3jiLI+IoEHE= 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 4.14 35/37] vgacon: Record video mode changes with VT_RESIZEX Date: Mon, 24 May 2021 17:25:39 +0200 Message-Id: <20210524152325.352993815@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152324.199089755@linuxfoundation.org> References: <20210524152324.199089755@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 @@ -1100,12 +1100,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);