public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Chen Jun <chenjun102@huawei.com>
To: <stable@vger.kernel.org>, <deller@gmx.de>, <geert@linux-m68k.org>,
	<b.zolnierkie@samsung.com>, <gregkh@linuxfoundation.org>
Cc: <xuqiang36@huawei.com>, <xiujianfeng@huawei.com>
Subject: [PATCH stable 4.19 4.14 2/2] fbmem: Check virtual screen sizes in fb_set_var()
Date: Fri, 29 Jul 2022 03:11:40 +0000	[thread overview]
Message-ID: <20220729031140.21806-3-chenjun102@huawei.com> (raw)
In-Reply-To: <20220729031140.21806-1-chenjun102@huawei.com>

From: Helge Deller <deller@gmx.de>

commit 6c11df58fd1ac0aefcb3b227f72769272b939e56 upstream

Verify that the fbdev or drm driver correctly adjusted the virtual
screen sizes. On failure report the failing driver and reject the screen
size change.

Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
Link: https://lore.kernel.org/all/20220706150253.2186-1-deller@gmx.de/
[sudip: adjust context]
Signed-off-by: Chen Jun <chenjun102@huawei.com>
---
 drivers/video/fbdev/core/fbmem.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c
index b1733a2e0002..a8574a2a466e 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1006,6 +1006,16 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
 		if (ret)
 			goto done;
 
+		/* verify that virtual resolution >= physical resolution */
+		if (var->xres_virtual < var->xres ||
+		    var->yres_virtual < var->yres) {
+			pr_warn("WARNING: fbcon: Driver '%s' missed to adjust virtual screen size (%ux%u vs. %ux%u)\n",
+				info->fix.id,
+				var->xres_virtual, var->yres_virtual,
+				var->xres, var->yres);
+			return -EINVAL;
+		}
+
 		if ((var->activate & FB_ACTIVATE_MASK) == FB_ACTIVATE_NOW) {
 			struct fb_var_screeninfo old_var;
 			struct fb_videomode mode;
-- 
2.17.1


  parent reply	other threads:[~2022-07-29  3:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-29  3:11 [PATCH stable 4.19 4.14 0/2] add fix patch for CVE-2021-3365 Chen Jun
2022-07-29  3:11 ` [PATCH stable 4.19 4.14 1/2] fbcon: Prevent that screen size is smaller than font size Chen Jun
2022-07-29  3:11 ` Chen Jun [this message]
2022-07-31 12:36 ` [PATCH stable 4.19 4.14 0/2] add fix patch for CVE-2021-3365 Greg KH
2022-08-01  2:56   ` chenjun (AM)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220729031140.21806-3-chenjun102@huawei.com \
    --to=chenjun102@huawei.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=deller@gmx.de \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=stable@vger.kernel.org \
    --cc=xiujianfeng@huawei.com \
    --cc=xuqiang36@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox