All of lore.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>
Subject: [PATCH stable 4.14 v3 3/3] fbmem: Check virtual screen sizes in fb_set_var()
Date: Thu, 4 Aug 2022 12:27:34 +0000	[thread overview]
Message-ID: <20220804122734.121201-4-chenjun102@huawei.com> (raw)
In-Reply-To: <20220804122734.121201-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>
[Chen Jun: 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 264e8ca5efa7..1238cc9f42c0 100644
--- a/drivers/video/fbdev/core/fbmem.c
+++ b/drivers/video/fbdev/core/fbmem.c
@@ -1019,6 +1019,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-08-04 12:29 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04 12:27 [PATCH stable 4.14 v3 0/3] add fix patches for CVE-2021-33655 Chen Jun
2022-08-04 12:27 ` [PATCH stable 4.14 v3 1/3] printk: Export is_console_locked Chen Jun
2022-08-04 12:27 ` [PATCH stable 4.14 v3 2/3] fbcon: Prevent that screen size is smaller than font size Chen Jun
2022-08-05  6:09   ` Cengiz Can
2022-08-05  6:22     ` chenjun (AM)
2022-08-08 13:34       ` gregkh
2022-08-04 12:27 ` Chen Jun [this message]

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=20220804122734.121201-4-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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.