linux/drivers/video
Ian Bridges 7f08fc10fa fbdev: Fix fb_new_modelist to prevent null-ptr-deref in fb_videomode_to_var
info->var, a framebuffer's current mode, is expected to have a matching
entry in info->modelist. var_to_display() relies on this and treats a
failed fb_match_mode() as "This should not happen". fb_set_var() keeps it
true by adding the mode to the list on every change, and
do_register_framebuffer() does the same at registration.

store_modes() replaces the modelist from userspace. fb_new_modelist()
validates the new modes but does not check that info->var still has a
match. It relies on fbcon_new_modelist() to re-point consoles, but that
only handles consoles mapped to the framebuffer. With fbcon unbound there
are none, so info->var is left describing a mode that is no longer in the
list.

A later console takeover runs var_to_display(), where fb_match_mode()
returns NULL and leaves fb_display[i].mode NULL. fbcon_switch() passes it
to display_to_var(), and fb_videomode_to_var() dereferences the NULL mode.

Keep the current mode in the list in fb_new_modelist(), the same way
fb_set_var() does.

Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Ian Bridges <icb@fastmail.org>
Signed-off-by: Helge Deller <deller@gmx.de>
2026-06-26 15:12:45 +02:00
..
backlight backlight: Use named initializers for arrays of i2c_device_data 2026-06-11 15:12:12 +01:00
console console: mdacon: remove this obsolete driver 2026-05-20 20:23:32 +02:00
fbdev fbdev: Fix fb_new_modelist to prevent null-ptr-deref in fb_videomode_to_var 2026-06-26 15:12:45 +02:00
logo video/logo: don't select LOGO_LINUX_MONO and LOGO_LINUX_VGA16 by default 2026-02-14 11:09:46 +01:00
aperture.c video/aperture: optionally match the device in sysfb_disable() 2024-08-26 19:14:48 -04:00
cmdline.c video/cmdline: Hide __video_get_options() behind CONFIG_FB_CORE 2024-01-23 10:11:34 +01:00
display_timing.c
hdmi.c video: hdmi: Remove unused hdmi_infoframe_check 2024-12-22 07:03:42 +01:00
Kconfig Merge drm/drm-next into drm-misc-next 2026-02-23 11:48:20 +01:00
Makefile video: Provide screen_info_get_pci_dev() to find screen_info's PCI device 2024-02-14 10:09:16 +01:00
nomodeset.c drm: Move nomodeset kernel parameter to drivers/video 2022-11-16 13:26:12 +01:00
of_display_timing.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
of_videomode.c
screen_info_generic.c video: screen_info: Add pixel-format helper for linear framebuffers 2025-08-26 09:54:16 +02:00
screen_info_pci.c sysfb: Replace screen_info with sysfb_primary_display 2025-12-16 14:12:44 +01:00
sticore.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
vgastate.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
videomode.c