Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+53 -2
+33
drivers/video/fbdev/core/fbcon.c
··· 2469 2469 if (charcount != 256 && charcount != 512) 2470 2470 return -EINVAL; 2471 2471 2472 + /* font bigger than screen resolution ? */ 2473 + if (w > FBCON_SWAP(info->var.rotate, info->var.xres, info->var.yres) || 2474 + h > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres)) 2475 + return -EINVAL; 2476 + 2472 2477 /* Make sure drawing engine can handle the font */ 2473 2478 if (!(info->pixmap.blit_x & (1 << (font->width - 1))) || 2474 2479 !(info->pixmap.blit_y & (1 << (font->height - 1)))) ··· 2735 2730 fbcon_modechanged(info); 2736 2731 } 2737 2732 EXPORT_SYMBOL(fbcon_update_vcs); 2733 + 2734 + /* let fbcon check if it supports a new screen resolution */ 2735 + int fbcon_modechange_possible(struct fb_info *info, struct fb_var_screeninfo *var) 2736 + { 2737 + struct fbcon_ops *ops = info->fbcon_par; 2738 + struct vc_data *vc; 2739 + unsigned int i; 2740 + 2741 + WARN_CONSOLE_UNLOCKED(); 2742 + 2743 + if (!ops) 2744 + return 0; 2745 + 2746 + /* prevent setting a screen size which is smaller than font size */ 2747 + for (i = first_fb_vc; i <= last_fb_vc; i++) { 2748 + vc = vc_cons[i].d; 2749 + if (!vc || vc->vc_mode != KD_TEXT || 2750 + fbcon_info_from_console(i) != info) 2751 + continue; 2752 + 2753 + if (vc->vc_font.width > FBCON_SWAP(var->rotate, var->xres, var->yres) || 2754 + vc->vc_font.height > FBCON_SWAP(var->rotate, var->yres, var->xres)) 2755 + return -EINVAL; 2756 + } 2757 + 2758 + return 0; 2759 + } 2760 + EXPORT_SYMBOL_GPL(fbcon_modechange_possible); 2738 2761 2739 2762 int fbcon_mode_deleted(struct fb_info *info, 2740 2763 struct fb_videomode *mode)
+14 -2
drivers/video/fbdev/core/fbmem.c
··· 511 511 512 512 while (n && (n * (logo->width + 8) - 8 > xres)) 513 513 --n; 514 - image.dx = (xres - n * (logo->width + 8) - 8) / 2; 514 + image.dx = (xres - (n * (logo->width + 8) - 8)) / 2; 515 515 image.dy = y ?: (yres - logo->height) / 2; 516 516 } else { 517 517 image.dx = 0; ··· 1017 1017 if (ret) 1018 1018 return ret; 1019 1019 1020 + /* verify that virtual resolution >= physical resolution */ 1021 + if (var->xres_virtual < var->xres || 1022 + var->yres_virtual < var->yres) { 1023 + pr_warn("WARNING: fbcon: Driver '%s' missed to adjust virtual screen size (%ux%u vs. %ux%u)\n", 1024 + info->fix.id, 1025 + var->xres_virtual, var->yres_virtual, 1026 + var->xres, var->yres); 1027 + return -EINVAL; 1028 + } 1029 + 1020 1030 if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW) 1021 1031 return 0; 1022 1032 ··· 1117 1107 return -EFAULT; 1118 1108 console_lock(); 1119 1109 lock_fb_info(info); 1120 - ret = fb_set_var(info, &var); 1110 + ret = fbcon_modechange_possible(info, &var); 1111 + if (!ret) 1112 + ret = fb_set_var(info, &var); 1121 1113 if (!ret) 1122 1114 fbcon_update_vcs(info, var.activate & FB_ACTIVATE_ALL); 1123 1115 unlock_fb_info(info);
+4
include/linux/fbcon.h
··· 15 15 void fbcon_get_requirement(struct fb_info *info, 16 16 struct fb_blit_caps *caps); 17 17 void fbcon_fb_blanked(struct fb_info *info, int blank); 18 + int fbcon_modechange_possible(struct fb_info *info, 19 + struct fb_var_screeninfo *var); 18 20 void fbcon_update_vcs(struct fb_info *info, bool all); 19 21 void fbcon_remap_all(struct fb_info *info); 20 22 int fbcon_set_con2fb_map_ioctl(void __user *argp); ··· 35 33 static inline void fbcon_get_requirement(struct fb_info *info, 36 34 struct fb_blit_caps *caps) {} 37 35 static inline void fbcon_fb_blanked(struct fb_info *info, int blank) {} 36 + static inline int fbcon_modechange_possible(struct fb_info *info, 37 + struct fb_var_screeninfo *var) { return 0; } 38 38 static inline void fbcon_update_vcs(struct fb_info *info, bool all) {} 39 39 static inline void fbcon_remap_all(struct fb_info *info) {} 40 40 static inline int fbcon_set_con2fb_map_ioctl(void __user *argp) { return 0; }
+2
include/video/of_display_timing.h
··· 8 8 #ifndef __LINUX_OF_DISPLAY_TIMING_H 9 9 #define __LINUX_OF_DISPLAY_TIMING_H 10 10 11 + #include <linux/errno.h> 12 + 11 13 struct device_node; 12 14 struct display_timing; 13 15 struct display_timings;