]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fbcon: Avoid OOB font access if console rotation fails
authorThomas Zimmermann <tzimmermann@suse.de>
Tue, 7 Apr 2026 09:23:12 +0000 (11:23 +0200)
committerHelge Deller <deller@gmx.de>
Tue, 7 Apr 2026 15:38:06 +0000 (17:38 +0200)
Clear the font buffer if the reallocation during console rotation fails
in fbcon_rotate_font(). The putcs implementations for the rotated buffer
will return early in this case. See [1] for an example.

Currently, fbcon_rotate_font() keeps the old buffer, which is too small
for the rotated font. Printing to the rotated console with a high-enough
character code will overflow the font buffer.

v2:
- fix typos in commit message

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Fixes: 6cc50e1c5b57 ("[PATCH] fbcon: Console Rotation - Add support to rotate font bitmap")
Cc: stable@vger.kernel.org # v2.6.15+
Link: https://elixir.bootlin.com/linux/v6.19/source/drivers/video/fbdev/core/fbcon_ccw.c#L144
Signed-off-by: Helge Deller <deller@gmx.de>
drivers/video/fbdev/core/fbcon_rotate.c

index 1562a8f20b4f59ce111a0f95dc84658f45306c87..5348f6c6f57c7c3fbeee344d5b2410c54a3bf968 100644 (file)
@@ -46,6 +46,10 @@ int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)
                info->fbops->fb_sync(info);
 
        if (par->fd_size < d_cellsize * len) {
+               kfree(par->fontbuffer);
+               par->fontbuffer = NULL;
+               par->fd_size = 0;
+
                dst = kmalloc_array(len, d_cellsize, GFP_KERNEL);
 
                if (dst == NULL) {
@@ -54,7 +58,6 @@ int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)
                }
 
                par->fd_size = d_cellsize * len;
-               kfree(par->fontbuffer);
                par->fontbuffer = dst;
        }