Commit 086ff846 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-5.19/fbdev-3' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev

Pull fbdev fixes from Helge Deller:

 - fbcon now prevents switching to screen resolutions which are smaller
   than the font size, and prevents enabling a font which is bigger than
   the current screen resolution. This fixes vmalloc-out-of-bounds
   accesses found by KASAN.

 - Guiling Deng fixed a bug where the centered fbdev logo wasn't
   displayed correctly if the screen size matched the logo size.

 - Hsin-Yi Wang provided a patch to include errno.h to fix build when
   CONFIG_OF isn't enabled.

* tag 'for-5.19/fbdev-3' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev:
  fbcon: Use fbcon_info_from_console() in fbcon_modechange_possible()
  fbmem: Check virtual screen sizes in fb_set_var()
  fbcon: Prevent that screen size is smaller than font size
  fbcon: Disallow setting font bigger than screen size
  video: of_display_timing.h: include errno.h
  fbdev: fbmem: Fix logo center image dx issue
parents e8a4e1c1 53a6e66b
...@@ -2469,6 +2469,11 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, ...@@ -2469,6 +2469,11 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font,
if (charcount != 256 && charcount != 512) if (charcount != 256 && charcount != 512)
return -EINVAL; return -EINVAL;
/* font bigger than screen resolution ? */
if (w > FBCON_SWAP(info->var.rotate, info->var.xres, info->var.yres) ||
h > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres))
return -EINVAL;
/* Make sure drawing engine can handle the font */ /* Make sure drawing engine can handle the font */
if (!(info->pixmap.blit_x & (1 << (font->width - 1))) || if (!(info->pixmap.blit_x & (1 << (font->width - 1))) ||
!(info->pixmap.blit_y & (1 << (font->height - 1)))) !(info->pixmap.blit_y & (1 << (font->height - 1))))
...@@ -2731,6 +2736,34 @@ void fbcon_update_vcs(struct fb_info *info, bool all) ...@@ -2731,6 +2736,34 @@ void fbcon_update_vcs(struct fb_info *info, bool all)
} }
EXPORT_SYMBOL(fbcon_update_vcs); EXPORT_SYMBOL(fbcon_update_vcs);
/* let fbcon check if it supports a new screen resolution */
int fbcon_modechange_possible(struct fb_info *info, struct fb_var_screeninfo *var)
{
struct fbcon_ops *ops = info->fbcon_par;
struct vc_data *vc;
unsigned int i;
WARN_CONSOLE_UNLOCKED();
if (!ops)
return 0;
/* prevent setting a screen size which is smaller than font size */
for (i = first_fb_vc; i <= last_fb_vc; i++) {
vc = vc_cons[i].d;
if (!vc || vc->vc_mode != KD_TEXT ||
fbcon_info_from_console(i) != info)
continue;
if (vc->vc_font.width > FBCON_SWAP(var->rotate, var->xres, var->yres) ||
vc->vc_font.height > FBCON_SWAP(var->rotate, var->yres, var->xres))
return -EINVAL;
}
return 0;
}
EXPORT_SYMBOL_GPL(fbcon_modechange_possible);
int fbcon_mode_deleted(struct fb_info *info, int fbcon_mode_deleted(struct fb_info *info,
struct fb_videomode *mode) struct fb_videomode *mode)
{ {
......
...@@ -511,7 +511,7 @@ static int fb_show_logo_line(struct fb_info *info, int rotate, ...@@ -511,7 +511,7 @@ static int fb_show_logo_line(struct fb_info *info, int rotate,
while (n && (n * (logo->width + 8) - 8 > xres)) while (n && (n * (logo->width + 8) - 8 > xres))
--n; --n;
image.dx = (xres - n * (logo->width + 8) - 8) / 2; image.dx = (xres - (n * (logo->width + 8) - 8)) / 2;
image.dy = y ?: (yres - logo->height) / 2; image.dy = y ?: (yres - logo->height) / 2;
} else { } else {
image.dx = 0; image.dx = 0;
...@@ -1017,6 +1017,16 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) ...@@ -1017,6 +1017,16 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
if (ret) if (ret)
return ret; return ret;
/* 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) if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW)
return 0; return 0;
...@@ -1107,6 +1117,8 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd, ...@@ -1107,6 +1117,8 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
return -EFAULT; return -EFAULT;
console_lock(); console_lock();
lock_fb_info(info); lock_fb_info(info);
ret = fbcon_modechange_possible(info, &var);
if (!ret)
ret = fb_set_var(info, &var); ret = fb_set_var(info, &var);
if (!ret) if (!ret)
fbcon_update_vcs(info, var.activate & FB_ACTIVATE_ALL); fbcon_update_vcs(info, var.activate & FB_ACTIVATE_ALL);
......
...@@ -15,6 +15,8 @@ void fbcon_new_modelist(struct fb_info *info); ...@@ -15,6 +15,8 @@ void fbcon_new_modelist(struct fb_info *info);
void fbcon_get_requirement(struct fb_info *info, void fbcon_get_requirement(struct fb_info *info,
struct fb_blit_caps *caps); struct fb_blit_caps *caps);
void fbcon_fb_blanked(struct fb_info *info, int blank); void fbcon_fb_blanked(struct fb_info *info, int blank);
int fbcon_modechange_possible(struct fb_info *info,
struct fb_var_screeninfo *var);
void fbcon_update_vcs(struct fb_info *info, bool all); void fbcon_update_vcs(struct fb_info *info, bool all);
void fbcon_remap_all(struct fb_info *info); void fbcon_remap_all(struct fb_info *info);
int fbcon_set_con2fb_map_ioctl(void __user *argp); int fbcon_set_con2fb_map_ioctl(void __user *argp);
...@@ -33,6 +35,8 @@ static inline void fbcon_new_modelist(struct fb_info *info) {} ...@@ -33,6 +35,8 @@ static inline void fbcon_new_modelist(struct fb_info *info) {}
static inline void fbcon_get_requirement(struct fb_info *info, static inline void fbcon_get_requirement(struct fb_info *info,
struct fb_blit_caps *caps) {} struct fb_blit_caps *caps) {}
static inline void fbcon_fb_blanked(struct fb_info *info, int blank) {} static inline void fbcon_fb_blanked(struct fb_info *info, int blank) {}
static inline int fbcon_modechange_possible(struct fb_info *info,
struct fb_var_screeninfo *var) { return 0; }
static inline void fbcon_update_vcs(struct fb_info *info, bool all) {} static inline void fbcon_update_vcs(struct fb_info *info, bool all) {}
static inline void fbcon_remap_all(struct fb_info *info) {} static inline void fbcon_remap_all(struct fb_info *info) {}
static inline int fbcon_set_con2fb_map_ioctl(void __user *argp) { return 0; } static inline int fbcon_set_con2fb_map_ioctl(void __user *argp) { return 0; }
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#ifndef __LINUX_OF_DISPLAY_TIMING_H #ifndef __LINUX_OF_DISPLAY_TIMING_H
#define __LINUX_OF_DISPLAY_TIMING_H #define __LINUX_OF_DISPLAY_TIMING_H
#include <linux/errno.h>
struct device_node; struct device_node;
struct display_timing; struct display_timing;
struct display_timings; struct display_timings;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment