Skip to content

Commit b44cc78

Browse files
tdzgregkh
authored andcommitted
fbcon: Avoid OOB font access if console rotation fails
commit e4ef723 upstream. 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: 6cc50e1 ("[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 # [1] Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3925301 commit b44cc78

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

drivers/video/fbdev/core/fbcon_rotate.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)
4646
info->fbops->fb_sync(info);
4747

4848
if (par->fd_size < d_cellsize * len) {
49+
kfree(par->fontbuffer);
50+
par->fontbuffer = NULL;
51+
par->fd_size = 0;
52+
4953
dst = kmalloc_array(len, d_cellsize, GFP_KERNEL);
5054

5155
if (dst == NULL) {
@@ -54,7 +58,6 @@ int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)
5458
}
5559

5660
par->fd_size = d_cellsize * len;
57-
kfree(par->fontbuffer);
5861
par->fontbuffer = dst;
5962
}
6063

0 commit comments

Comments
 (0)