fbcon: Fix out-of-bounds memory in fbcon_putcs
Subsystems (3)
RFC PATCH 1/1 fbcon: Fix out-of-bounds memory in fbcon_putcs
When a font is set on an invisible console, the screen will not update. However, the fontbuffer is not updated to match the new font dimensions.
This inconsistency leads to out-of-bounds memory access when writing to the tty bound to fbcon, as demonstrated by the following KASAN report:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0xdf/0x140 Read of size 1 at addr ffff8881195a2280 by task a.out/971 Call Trace: <TASK> fb_pad_aligned_buffer+0xdf/0x140 ud_putcs+0x88a/0xde0 fbcon_putcs+0x319/0x430 do_update_region+0x23c/0x3b0 do_con_write+0x225c/0x67f0 con_write+0xe/0x30 n_tty_write+0x4b5/0xff0 file_tty_write.isra.41+0x46c/0x880 vfs_write+0x868/0xd60 ksys_write+0xf2/0x1d0 do_syscall_64+0xfa/0x570
Fix this by calling fbcon_rotate_font() if vc is invisible in fbcon_do_set_font().
--- drivers/video/fbdev/core/fbcon.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/video/fbdev/core/fbcon.c +5 -0
@@ -2444,6 +2444,11 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, rows =FBCON_SWAP (par->rotate, info->var.yres, info->var.xres); cols /= w; rows /= h; +if (!con_is_visible (vc)) { + ret =fbcon_rotate_font (info, vc); +if (ret) + goto err_out; + } ret =vc_resize (vc, cols, rows);if (ret) goto err_out;
Signature · 1 line
2.22.0
Quoted 37 lines · chenjun (AM)
When a font is set on an invisible console, the screen will not update. However, the fontbuffer is not updated to match the new font dimensions.
This inconsistency leads to out-of-bounds memory access when writing to the tty bound to fbcon, as demonstrated by the following KASAN report:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0xdf/0x140 Read of size 1 at addr ffff8881195a2280 by task a.out/971 Call Trace: <TASK> fb_pad_aligned_buffer+0xdf/0x140 ud_putcs+0x88a/0xde0 fbcon_putcs+0x319/0x430 do_update_region+0x23c/0x3b0 do_con_write+0x225c/0x67f0 con_write+0xe/0x30 n_tty_write+0x4b5/0xff0 file_tty_write.isra.41+0x46c/0x880 vfs_write+0x868/0xd60 ksys_write+0xf2/0x1d0 do_syscall_64+0xfa/0x570Fix this by calling
fbcon_rotate_font()if vc is invisible infbcon_do_set_font().Signed-off-by Chen Jun <[email protected]>--- drivers/video/fbdev/core/fbcon.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/video/fbdev/core/fbcon.c +0
-0@@ -2444,6 +2444,11 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, rows =FBCON_SWAP (par->rotate, info->var.yres, info->var.xres);
drivers/video/fbdev/core/fbcon.c static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, · line 2454
Quoted 10 lines
drivers/video/fbdev/core/fbcon.c +5
-0cols /= w; rows /= h; +if (!con_is_visible (vc)) { + ret =fbcon_rotate_font (info, vc); +if (ret) + goto err_out; + } ret =vc_resize (vc, cols, rows);if (ret) goto err_out;
There is a poc:
```
#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include <linux/capability.h>
char my_font_data[512 * 1 * 32 * 32];
struct console_font_op {
unsigned int op;
unsigned int flags;
unsigned int width, height;
unsigned int charcount;
unsigned char *data;
};
void execute_one(void)
{
int tty = open("/dev/tty2", O_APPEND|O_RDWR, 0);
char buf[100] = {27, '#', '8', 0xa, 0x5, 0x5, 0x5, 0x5};
struct console_font_op op = {
.op = 0,
.width = 32,
.height = 32,
.charcount = 512,
.data = my_font_data,
};
ioctl(tty, 0x4B72, &op);
write(tty, buf, 100);
}
int main(void)
{
execute_one();
return 0;
}
```echo 2 > /sys/class/graphics/fbcon/rotate_all
./poc
Thomas Zimmermann
maintainerHi,
thanks for the patch.
Am 27.02.26 um 15:43 schrieb Chen Jun:
Quoted 2 lines
When a font is set on an invisible console, the screen will not update. However, the fontbuffer is not updated to match the new font dimensions.
I looked through vc_resize() but cannot quite find the logic that calls fbcon_rotate_font(). Can you please point to correct place?
Best regards
Thomas
Quoted 44 lines
This inconsistency leads to out-of-bounds memory access when writing to the tty bound to fbcon, as demonstrated by the following KASAN report:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0xdf/0x140 Read of size 1 at addr ffff8881195a2280 by task a.out/971 Call Trace: <TASK> fb_pad_aligned_buffer+0xdf/0x140 ud_putcs+0x88a/0xde0 fbcon_putcs+0x319/0x430 do_update_region+0x23c/0x3b0 do_con_write+0x225c/0x67f0 con_write+0xe/0x30 n_tty_write+0x4b5/0xff0 file_tty_write.isra.41+0x46c/0x880 vfs_write+0x868/0xd60 ksys_write+0xf2/0x1d0 do_syscall_64+0xfa/0x570Fix this by calling
fbcon_rotate_font()if vc is invisible infbcon_do_set_font().Signed-off-by Chen Jun <[email protected]>--- drivers/video/fbdev/core/fbcon.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/video/fbdev/core/fbcon.c +5
-0@@ -2444,6 +2444,11 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, rows =FBCON_SWAP (par->rotate, info->var.yres, info->var.xres); cols /= w; rows /= h; +if (!con_is_visible (vc)) { + ret =fbcon_rotate_font (info, vc); +if (ret) + goto err_out; + } ret =vc_resize (vc, cols, rows);if (ret) goto err_out;
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
Quoted 5 lines · Thomas Zimmermann
Hi,
thanks for the patch.
Am 27.02.26 um 15:43 schrieb Chen Jun:
Quoted 9 lines
Quoted 2 lines
When a font is set on an invisible console, the screen will not update. However, the fontbuffer is not updated to match the new font dimensions.
I looked through
vc_resize()but cannot quite find the logic that callsfbcon_rotate_font(). Can you please point to correct place?Best regards
Thomas
Hi, fbcon_rouate_font is called in fbcon_switch
[ 64.669554] CPU: 3 UID: 0 PID: 978 Comm: a.out Not tainted 7.0.0-rc1-00021-gd9d32e5bd5a4-dirty #10 PREEMPT(lazy) [ 64.669576] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/4 [ 64.669584] Call Trace:
[ 64.669589] <TASK>
[ 64.669595] dump_stack_lvl+0x53/0x70
[ 64.669615] fbcon_rotate_font+0x2d6/0xe90
[ 64.669636] ? kfree+0x159/0x3b0
[ 64.669650] ? ud_cursor+0x830/0x1d80
[ 64.669661] ? __kmalloc_noprof+0x198/0x4a0
[ 64.669674] fbcon_switch+0x67b/0x10f0
[ 64.669689] ? __pfx_fbcon_switch+0x10/0x10
[ 64.669708] ? con_is_visible+0xb0/0x130
[ 64.669723] redraw_screen+0x258/0x690
[ 64.669736] ? mutex_unlock+0x7d/0xd0
[ 64.669751] ? __pfx_redraw_screen+0x10/0x10
[ 64.669764] ? tty_get_pgrp+0x73/0xb0
[ 64.669784] vc_do_resize+0x9a5/0xec0
[ 64.669803] ? __pfx_vc_do_resize+0x10/0x10
[ 64.669815] ? kernel_fpu_begin_mask+0x1c5/0x210
[ 64.669832] ? __pfx_kernel_fpu_begin_mask+0x10/0x10
[ 64.669843] ? fbcon_set_font+0x2cb/0x8c0
[ 64.669853] ? __kasan_kmalloc_large+0x81/0xa0
[ 64.669863] ? __kmalloc_large_node_noprof+0x18/0xb0
[ 64.669874] fbcon_do_set_font+0x390/0xa70
[ 64.669890] ? __pfx_fbcon_set_font+0x10/0x10
[ 64.669900] con_font_op+0x7d5/0xc30
[ 64.669910] ? arch_stack_walk+0x9f/0xf0
[ 64.669924] ? __pfx_con_font_op+0x10/0x10
[ 64.669940] vt_ioctl+0x8ee/0x2480
[ 64.669953] ? __pfx_vt_ioctl+0x10/0x10
[ 64.669964] ? __x64_sys_open+0x79/0xc0
[ 64.669976] ? do_syscall_64+0xfa/0x570
[ 64.669986] ? entry_SYSCALL_64_after_hwframe+0x77/0x7f
[ 64.669996] ? __pfx_path_openat+0x10/0x10
[ 64.670006] ? __pfx_avc_has_extended_perms+0x10/0x10
[ 64.670022] ? _raw_spin_lock+0x7f/0xd0
[ 64.670040] ? do_file_open+0x22f/0x2b0
[ 64.670048] ? pte_offset_map_lock+0xe2/0x1e0
[ 64.670070] ? __pfx_do_file_open+0x10/0x10
[ 64.670082] tty_ioctl+0x3e7/0x1190
[ 64.670098] ? __pfx_tty_ioctl+0x10/0x10
[ 64.670109] ? __pfx_do_vfs_ioctl+0x10/0x10
[ 64.670124] ? ioctl_has_perm.constprop.74+0x2e1/0x4f0
[ 64.670137] ? __pfx_ioctl_has_perm.constprop.74+0x10/0x10
[ 64.670148] ? __pfx_do_sys_openat2+0x10/0x10
[ 64.670191] __x64_sys_ioctl+0x130/0x1a0
[ 64.670204] do_syscall_64+0xfa/0x570
[ 64.670214] entry_SYSCALL_64_after_hwframe+0x77/0x7f
[ 64.670223] RIP: 0033:0x7ff56cb0c577
[ 64.670233] Code: b3 66 90 48 8b 05 11 89 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 8 [ 64.670242] RSP: 002b:00007fff94ab6a48 EFLAGS: 00000206 ORIG_RAX: 0000000000000010 [ 64.670256] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007ff56cb0c577 [ 64.670263] RDX: 00007fff94ab6a60 RSI: 0000000000004b72 RDI: 0000000000000003 [ 64.670269] RBP: 00007fff94ab6af0 R08: 000055bf68e008d0 R09: 00007ff56cdec090 [ 64.670275] R10: 0000000000000000 R11: 0000000000000206 R12: 000055bf68e00630 [ 64.670281] R13: 00007fff94ab6be0 R14: 0000000000000000 R15: 0000000000000000 [ 64.670293] </TASK>
Quoted 45 lines
Quoted 44 lines
This inconsistency leads to out-of-bounds memory access when writing to the tty bound to fbcon, as demonstrated by the following KASAN report:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0xdf/0x140 Read of size 1 at addr ffff8881195a2280 by task a.out/971 Call Trace: <TASK> fb_pad_aligned_buffer+0xdf/0x140 ud_putcs+0x88a/0xde0 fbcon_putcs+0x319/0x430 do_update_region+0x23c/0x3b0 do_con_write+0x225c/0x67f0 con_write+0xe/0x30 n_tty_write+0x4b5/0xff0 file_tty_write.isra.41+0x46c/0x880 vfs_write+0x868/0xd60 ksys_write+0xf2/0x1d0 do_syscall_64+0xfa/0x570Fix this by calling
fbcon_rotate_font()if vc is invisible infbcon_do_set_font().Signed-off-by Chen Jun <[email protected]>--- drivers/video/fbdev/core/fbcon.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/video/fbdev/core/fbcon.c +5
-0@@ -2444,6 +2444,11 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, rows =FBCON_SWAP (par->rotate, info->var.yres, info->var.xres); cols /= w; rows /= h; +if (!con_is_visible (vc)) { + ret =fbcon_rotate_font (info, vc); +if (ret) + goto err_out; + } ret =vc_resize (vc, cols, rows);if (ret) goto err_out;
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Chen,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on linus/master v7.0-rc1 next-20260227] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Chen-Jun/fbcon-Fix-out-of-bounds-memory-in-fbcon_putcs/20260227-225307 base: https://gitlab.freedesktop.org/drm/misc/kernel.git drm-misc-next patch link: https://lore.kernel.org/r/20260227144358.101173-1-chenjun102%40huawei.com patch subject: [RFC PATCH] fbcon: Fix out-of-bounds memory in fbcon_putcs config: hexagon-randconfig-r071-20260228 (https://download.01.org/0day-ci/archive/20260228/[email protected]/config) compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff) smatch version: v0.5.0-8994-gd50c5a4c reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260228/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> ld.lld: error: undefined symbol: fbcon_rotate_font >>> referenced by fbcon.c >>> drivers/video/fbdev/core/fbcon.o:(fbcon_do_set_font) in archive vmlinux.a >>> referenced by fbcon.c >>> drivers/video/fbdev/core/fbcon.o:(fbcon_do_set_font) in archive vmlinux.a
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Chen,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on drm-misc/drm-misc-next]
[also build test ERROR on linus/master v7.0-rc1 next-20260227] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Chen-Jun/fbcon-Fix-out-of-bounds-memory-in-fbcon_putcs/20260227-225307 base: https://gitlab.freedesktop.org/drm/misc/kernel.git drm-misc-next patch link: https://lore.kernel.org/r/20260227144358.101173-1-chenjun102%40huawei.com patch subject: [RFC PATCH] fbcon: Fix out-of-bounds memory in fbcon_putcs config: x86_64-buildonly-randconfig-005-20260228 (https://download.01.org/0day-ci/archive/20260228/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260228/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
ld: drivers/video/fbdev/core/fbcon.o: in function `fbcon_do_set_font':
>> fbcon.c:(.text+0x3655): undefined reference to `fbcon_rotate_font'
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Thomas Zimmermann
maintainerHi
Am 28.02.26 um 02:53 schrieb chenjun (AM):
Quoted 34 lines · Thomas Zimmermann
Quoted 4 lines
Hi,
thanks for the patch.
Quoted 9 lines
Am 27.02.26 um 15:43 schrieb Chen Jun:
Quoted 2 lines
When a font is set on an invisible console, the screen will not update. However, the fontbuffer is not updated to match the new font dimensions.
I looked through
vc_resize()but cannot quite find the logic that callsfbcon_rotate_font(). Can you please point to correct place?Best regards
ThomasHi,
fbcon_rouate_fontis called infbcon_switch[ 64.669554] CPU: 3 UID: 0 PID: 978 Comm: a.out Not tainted 7.0.0-rc1-00021-gd9d32e5bd5a4-dirty #10 PREEMPT(lazy) [ 64.669576] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/4 [ 64.669584] Call Trace:[ 64.669589] <TASK>[ 64.669595] dump_stack_lvl+0x53/0x70[ 64.669615] fbcon_rotate_font+0x2d6/0xe90[ 64.669636] ? kfree+0x159/0x3b0[ 64.669650] ? ud_cursor+0x830/0x1d80[ 64.669661] ? __kmalloc_noprof+0x198/0x4a0
Quoted 7 lines
[ 64.669674] fbcon_switch+0x67b/0x10f0[ 64.669689] ? __pfx_fbcon_switch+0x10/0x10[ 64.669708] ? con_is_visible+0xb0/0x130[ 64.669723] redraw_screen+0x258/0x690
Thanks. Somehow I made a wrong turn in redraw_screen()
Best regards
Thomas
Quoted 134 lines
[ 64.669736] ? mutex_unlock+0x7d/0xd0[ 64.669751] ? __pfx_redraw_screen+0x10/0x10[ 64.669764] ? tty_get_pgrp+0x73/0xb0[ 64.669784] vc_do_resize+0x9a5/0xec0[ 64.669803] ? __pfx_vc_do_resize+0x10/0x10[ 64.669815] ? kernel_fpu_begin_mask+0x1c5/0x210[ 64.669832] ? __pfx_kernel_fpu_begin_mask+0x10/0x10[ 64.669843] ? fbcon_set_font+0x2cb/0x8c0[ 64.669853] ? __kasan_kmalloc_large+0x81/0xa0[ 64.669863] ? __kmalloc_large_node_noprof+0x18/0xb0[ 64.669874] fbcon_do_set_font+0x390/0xa70[ 64.669890] ? __pfx_fbcon_set_font+0x10/0x10[ 64.669900] con_font_op+0x7d5/0xc30[ 64.669910] ? arch_stack_walk+0x9f/0xf0[ 64.669924] ? __pfx_con_font_op+0x10/0x10[ 64.669940] vt_ioctl+0x8ee/0x2480[ 64.669953] ? __pfx_vt_ioctl+0x10/0x10[ 64.669964] ? __x64_sys_open+0x79/0xc0[ 64.669976] ? do_syscall_64+0xfa/0x570[ 64.669986] ? entry_SYSCALL_64_after_hwframe+0x77/0x7f[ 64.669996] ? __pfx_path_openat+0x10/0x10[ 64.670006] ? __pfx_avc_has_extended_perms+0x10/0x10[ 64.670022] ? _raw_spin_lock+0x7f/0xd0[ 64.670040] ? do_file_open+0x22f/0x2b0[ 64.670048] ? pte_offset_map_lock+0xe2/0x1e0[ 64.670070] ? __pfx_do_file_open+0x10/0x10[ 64.670082] tty_ioctl+0x3e7/0x1190[ 64.670098] ? __pfx_tty_ioctl+0x10/0x10[ 64.670109] ? __pfx_do_vfs_ioctl+0x10/0x10[ 64.670124] ? ioctl_has_perm.constprop.74+0x2e1/0x4f0[ 64.670137] ? __pfx_ioctl_has_perm.constprop.74+0x10/0x10[ 64.670148] ? __pfx_do_sys_openat2+0x10/0x10[ 64.670191] __x64_sys_ioctl+0x130/0x1a0[ 64.670204] do_syscall_64+0xfa/0x570[ 64.670214] entry_SYSCALL_64_after_hwframe+0x77/0x7f[ 64.670223] RIP: 0033:0x7ff56cb0c577[ 64.670233] Code: b3 66 90 48 8b 05 11 89 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 2e 0f 1f 84 00 00 00 00 8 [ 64.670242] RSP: 002b:00007fff94ab6a48 EFLAGS: 00000206 ORIG_RAX: 0000000000000010 [ 64.670256] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007ff56cb0c577 [ 64.670263] RDX: 00007fff94ab6a60 RSI: 0000000000004b72 RDI: 0000000000000003 [ 64.670269] RBP: 00007fff94ab6af0 R08: 000055bf68e008d0 R09: 00007ff56cdec090 [ 64.670275] R10: 0000000000000000 R11: 0000000000000206 R12: 000055bf68e00630 [ 64.670281] R13: 00007fff94ab6be0 R14: 0000000000000000 R15: 0000000000000000 [ 64.670293] </TASK>Quoted 43 lines
Quoted 43 lines
This inconsistency leads to out-of-bounds memory access when writing to the tty bound to fbcon, as demonstrated by the following KASAN report:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0xdf/0x140 Read of size 1 at addr ffff8881195a2280 by task a.out/971 Call Trace: <TASK> fb_pad_aligned_buffer+0xdf/0x140 ud_putcs+0x88a/0xde0 fbcon_putcs+0x319/0x430 do_update_region+0x23c/0x3b0 do_con_write+0x225c/0x67f0 con_write+0xe/0x30 n_tty_write+0x4b5/0xff0 file_tty_write.isra.41+0x46c/0x880 vfs_write+0x868/0xd60 ksys_write+0xf2/0x1d0 do_syscall_64+0xfa/0x570Fix this by calling
fbcon_rotate_font()if vc is invisible infbcon_do_set_font().Signed-off-by Chen Jun <[email protected]>--- drivers/video/fbdev/core/fbcon.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/video/fbdev/core/fbcon.c +5
-0@@ -2444,6 +2444,11 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, rows =FBCON_SWAP (par->rotate, info->var.yres, info->var.xres); cols /= w; rows /= h; +if (!con_is_visible (vc)) { + ret =fbcon_rotate_font (info, vc); +if (ret) + goto err_out; + } ret =vc_resize (vc, cols, rows);if (ret) goto err_out;
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
Am 27.02.26 um 15:43 schrieb Chen Jun:
Quoted 22 lines
When a font is set on an invisible console, the screen will not update. However, the fontbuffer is not updated to match the new font dimensions.
This inconsistency leads to out-of-bounds memory access when writing to the tty bound to fbcon, as demonstrated by the following KASAN report:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0xdf/0x140 Read of size 1 at addr ffff8881195a2280 by task a.out/971 Call Trace: <TASK> fb_pad_aligned_buffer+0xdf/0x140 ud_putcs+0x88a/0xde0 fbcon_putcs+0x319/0x430 do_update_region+0x23c/0x3b0 do_con_write+0x225c/0x67f0 con_write+0xe/0x30 n_tty_write+0x4b5/0xff0 file_tty_write.isra.41+0x46c/0x880 vfs_write+0x868/0xd60 ksys_write+0xf2/0x1d0 do_syscall_64+0xfa/0x570
Quoted 4 lines
Fix this by calling
fbcon_rotate_font()if vc is invisible infbcon_do_set_font().Signed-off-by Chen Jun <[email protected]>
Quoted 20 lines
--- drivers/video/fbdev/core/fbcon.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/video/fbdev/core/fbcon.c +5
-0@@ -2444,6 +2444,11 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, rows =FBCON_SWAP (par->rotate, info->var.yres, info->var.xres); cols /= w; rows /= h; +if (!con_is_visible (vc)) { + ret =fbcon_rotate_font (info, vc); +if (ret) + goto err_out; + } ret =vc_resize (vc, cols, rows);if (ret) goto err_out;
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
Quoted 25 lines · Thomas Zimmermann
Am 27.02.26 um 15:43 schrieb Chen Jun:
Quoted 22 lines
When a font is set on an invisible console, the screen will not update. However, the fontbuffer is not updated to match the new font dimensions.
This inconsistency leads to out-of-bounds memory access when writing to the tty bound to fbcon, as demonstrated by the following KASAN report:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0xdf/0x140 Read of size 1 at addr ffff8881195a2280 by task a.out/971 Call Trace: <TASK> fb_pad_aligned_buffer+0xdf/0x140 ud_putcs+0x88a/0xde0 fbcon_putcs+0x319/0x430 do_update_region+0x23c/0x3b0 do_con_write+0x225c/0x67f0 con_write+0xe/0x30 n_tty_write+0x4b5/0xff0 file_tty_write.isra.41+0x46c/0x880 vfs_write+0x868/0xd60 ksys_write+0xf2/0x1d0 do_syscall_64+0xfa/0x570
Quoted 6 lines
Quoted 4 lines
Fix this by calling
fbcon_rotate_font()if vc is invisible infbcon_do_set_font().Signed-off-by Chen Jun <[email protected]>Reviewed-by Thomas Zimmermann <[email protected]>
Hi Thomas,
Thanks for your review.
I'm not familiar with the fbcon module. Is there a better way to fix this?
Quoted 21 lines
Quoted 20 lines
--- drivers/video/fbdev/core/fbcon.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/video/fbdev/core/fbcon.c +5
-0@@ -2444,6 +2444,11 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, rows =FBCON_SWAP (par->rotate, info->var.yres, info->var.xres); cols /= w; rows /= h; +if (!con_is_visible (vc)) { + ret =fbcon_rotate_font (info, vc); +if (ret) + goto err_out; + } ret =vc_resize (vc, cols, rows);if (ret) goto err_out;
Thomas Zimmermann
maintainerHi
Am 02.03.26 um 12:24 schrieb chenjun (AM):
Quoted 28 lines · Thomas Zimmermann
Quoted 27 lines
Am 27.02.26 um 15:43 schrieb Chen Jun:
Quoted 25 lines
When a font is set on an invisible console, the screen will not update. However, the fontbuffer is not updated to match the new font dimensions.
This inconsistency leads to out-of-bounds memory access when writing to the tty bound to fbcon, as demonstrated by the following KASAN report:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0xdf/0x140 Read of size 1 at addr ffff8881195a2280 by task a.out/971 Call Trace: <TASK> fb_pad_aligned_buffer+0xdf/0x140 ud_putcs+0x88a/0xde0 fbcon_putcs+0x319/0x430 do_update_region+0x23c/0x3b0 do_con_write+0x225c/0x67f0 con_write+0xe/0x30 n_tty_write+0x4b5/0xff0 file_tty_write.isra.41+0x46c/0x880 vfs_write+0x868/0xd60 ksys_write+0xf2/0x1d0 do_syscall_64+0xfa/0x570Fix this by calling
fbcon_rotate_font()if vc is invisible infbcon_do_set_font().
Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Chen Jun <[email protected]>Reviewed-by Thomas Zimmermann <[email protected]>Hi Thomas,
Thanks for your review.
I'm not familiar with the fbcon module. Is there a better way to fix this?
Not really, I think. The whole module first needs a redesign to be easier to understand.
Best regards
Thomas
Quoted 22 lines
Quoted 21 lines
Quoted 21 lines
--- drivers/video/fbdev/core/fbcon.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/video/fbdev/core/fbcon.c +5
-0@@ -2444,6 +2444,11 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, rows =FBCON_SWAP (par->rotate, info->var.yres, info->var.xres); cols /= w; rows /= h; +if (!con_is_visible (vc)) { + ret =fbcon_rotate_font (info, vc); +if (ret) + goto err_out; + } ret =vc_resize (vc, cols, rows);if (ret) goto err_out;
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
Quoted 22 lines · Chen Jun
When a font is set on an invisible console, the screen will not update. However, the fontbuffer is not updated to match the new font dimensions.
This inconsistency leads to out-of-bounds memory access when writing to the tty bound to fbcon, as demonstrated by the following KASAN report:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0xdf/0x140 Read of size 1 at addr ffff8881195a2280 by task a.out/971 Call Trace: <TASK> fb_pad_aligned_buffer+0xdf/0x140 ud_putcs+0x88a/0xde0 fbcon_putcs+0x319/0x430 do_update_region+0x23c/0x3b0 do_con_write+0x225c/0x67f0 con_write+0xe/0x30 n_tty_write+0x4b5/0xff0 file_tty_write.isra.41+0x46c/0x880 vfs_write+0x868/0xd60 ksys_write+0xf2/0x1d0 do_syscall_64+0xfa/0x570
Quoted 7 lines
Fix this by calling
fbcon_rotate_font()if vc is invisible infbcon_do_set_font().Signed-off-by Chen Jun <[email protected]>--- drivers/video/fbdev/core/fbcon.c | 5 +++++ 1 file changed, 5 insertions(+)
applied to fbdev git tree.
Thanks!
Helge
Helge Deller
maintainerQuoted 26 lines · Helge Deller
Quoted 25 lines · Chen Jun
When a font is set on an invisible console, the screen will not update. However, the fontbuffer is not updated to match the new font dimensions.
This inconsistency leads to out-of-bounds memory access when writing to the tty bound to fbcon, as demonstrated by the following KASAN report:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0xdf/0x140 Read of size 1 at addr ffff8881195a2280 by task a.out/971 Call Trace: <TASK> fb_pad_aligned_buffer+0xdf/0x140 ud_putcs+0x88a/0xde0 fbcon_putcs+0x319/0x430 do_update_region+0x23c/0x3b0 do_con_write+0x225c/0x67f0 con_write+0xe/0x30 n_tty_write+0x4b5/0xff0 file_tty_write.isra.41+0x46c/0x880 vfs_write+0x868/0xd60 ksys_write+0xf2/0x1d0 do_syscall_64+0xfa/0x570Fix this by calling
fbcon_rotate_font()if vc is invisible infbcon_do_set_font().
Quoted 6 lines
Quoted 4 lines
Signed-off-by Chen Jun <[email protected]>---
drivers/video/fbdev/core/fbcon.c| 5 +++++1 file changed, 5 insertions(+)applied to fbdev git tree.
I got a compile error:
hppa-linux-gnu-ld: drivers/video/fbdev/core/fbcon.o: in function `fbcon_do_set_font':
/home/cvs/parisc/git-kernel/linus-linux-2.6/drivers/video/fbdev/core/fbcon.c:2392:(.text+0x1e28): undefined reference to `fbcon_rotate_font' make[3]: *** [/home/cvs/parisc/git-kernel/linus-linux-2.6/scripts/Makefile.vmlinux:72: vmlinux.unstripped] Error 1
I modified your patch like this:
drivers/video/fbdev/core/fbcon.c +1 -1
@@ -2388,7 +2388,7 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, rows =FBCON_SWAP (par->rotate, info->var.yres, info->var.xres); cols /= w; rows /= h; -if (!con_is_visible (vc)) { +if (IS_ENABLED (CONFIG_FRAMEBUFFER_CONSOLE_ROTATION ) && !con_is_visible (vc)) { ret =fbcon_rotate_font (info, vc);
Helge
Quoted 50 lines · Thomas Zimmermann
Hi
Am 02.03.26 um 12:24 schrieb chenjun (AM):
Quoted 28 lines · Thomas Zimmermann
Quoted 27 lines
Am 27.02.26 um 15:43 schrieb Chen Jun:
Quoted 25 lines
When a font is set on an invisible console, the screen will not update. However, the fontbuffer is not updated to match the new font dimensions.
This inconsistency leads to out-of-bounds memory access when writing to the tty bound to fbcon, as demonstrated by the following KASAN report:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0xdf/0x140 Read of size 1 at addr ffff8881195a2280 by task a.out/971 Call Trace: <TASK> fb_pad_aligned_buffer+0xdf/0x140 ud_putcs+0x88a/0xde0 fbcon_putcs+0x319/0x430 do_update_region+0x23c/0x3b0 do_con_write+0x225c/0x67f0 con_write+0xe/0x30 n_tty_write+0x4b5/0xff0 file_tty_write.isra.41+0x46c/0x880 vfs_write+0x868/0xd60 ksys_write+0xf2/0x1d0 do_syscall_64+0xfa/0x570Fix this by calling
fbcon_rotate_font()if vc is invisible infbcon_do_set_font().Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Chen Jun <[email protected]>Reviewed-by Thomas Zimmermann <[email protected]>Hi Thomas,
Thanks for your review.
I'm not familiar with the fbcon module. Is there a better way to fix this?
Not really, I think. The whole module first needs a redesign to be easier to understand.
Best regards
ThomasQuoted 5 lines
Quoted 5 lines
Quoted 5 lines
--- drivers/video/fbdev/core/fbcon.c | 5 +++++ 1 file changed, 5 insertions(+)
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/video/fbdev/core/fbcon.c +0
-0@@ -2444,6 +2444,11 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount,Quoted 8 lines
Quoted 8 lines
drivers/video/fbdev/core/fbcon.c static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, · line 2451
Quoted 8 lines
drivers/video/fbdev/core/fbcon.c +5
-0rows =FBCON_SWAP (par->rotate, info->var.yres, info->var.xres); cols /= w; rows /= h; +if (!con_is_visible (vc)) { + ret =fbcon_rotate_font (info, vc); +if (ret) + goto err_out; + }
Hi Thomas and Helge,
I apologize, but after reviewing the code, I believe there is a problem. The issue is that fbcon_do_set_font() updates members of info->fbcon_par, and the info are shared with other vc instances.
Best regards
Chen Jun
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
Quoted 3 lines
drivers/video/fbdev/core/fbcon.c +0
-0ret =vc_resize (vc, cols, rows);if (ret) goto err_out;
Thomas Zimmermann
maintainerHi
Am 04.03.26 um 04:47 schrieb chenjun (AM):
Quoted 63 lines · Thomas Zimmermann
Quoted 47 lines
Hi
Am 02.03.26 um 12:24 schrieb chenjun (AM):
Quoted 27 lines · Thomas Zimmermann
Quoted 26 lines
Am 27.02.26 um 15:43 schrieb Chen Jun:
Quoted 25 lines
When a font is set on an invisible console, the screen will not update. However, the fontbuffer is not updated to match the new font dimensions.
This inconsistency leads to out-of-bounds memory access when writing to the tty bound to fbcon, as demonstrated by the following KASAN report:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0xdf/0x140 Read of size 1 at addr ffff8881195a2280 by task a.out/971 Call Trace: <TASK> fb_pad_aligned_buffer+0xdf/0x140 ud_putcs+0x88a/0xde0 fbcon_putcs+0x319/0x430 do_update_region+0x23c/0x3b0 do_con_write+0x225c/0x67f0 con_write+0xe/0x30 n_tty_write+0x4b5/0xff0 file_tty_write.isra.41+0x46c/0x880 vfs_write+0x868/0xd60 ksys_write+0xf2/0x1d0 do_syscall_64+0xfa/0x570Fix this by calling
fbcon_rotate_font()if vc is invisible infbcon_do_set_font().Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Chen Jun <[email protected]>Reviewed-by Thomas Zimmermann <[email protected]>Hi Thomas,
Thanks for your review.
I'm not familiar with the fbcon module. Is there a better way to fix this?
Not really, I think. The whole module first needs a redesign to be easier to understand.
Best regards
ThomasQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
--- drivers/video/fbdev/core/fbcon.c | 5 +++++ 1 file changed, 5 insertions(+)Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/video/fbdev/core/fbcon.c +0
-0@@ -2444,6 +2444,11 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount,Quoted 8 lines
Quoted 8 lines
drivers/video/fbdev/core/fbcon.c static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, · line 2451
Quoted 8 lines
drivers/video/fbdev/core/fbcon.c +5
-0rows =FBCON_SWAP (par->rotate, info->var.yres, info->var.xres); cols /= w; rows /= h; +if (!con_is_visible (vc)) { + ret =fbcon_rotate_font (info, vc); +if (ret) + goto err_out; + }Hi Thomas and Helge,
Quoted 3 lines
I apologize, but after reviewing the code, I believe there is a problem. The issue is that
fbcon_do_set_font()updates members ofinfo->fbcon_par, and the info are shared with other vc instances.
Than let's drop the patch for now.
My best idea to fix this is to move the rotated font out of fbcon_par. The unrotated font data is stored at [1]. The struct fbcon_display stores a vc's display settings. It might be possible to move the rotated data there as well. Tracked correctly, each vc would have its own rotated font. BUT this might also have other side effects.
Best regards
Thomas
[1] https://elixir.bootlin.com/linux/v6.19.3/source/drivers/video/fbdev/core/fbcon.h#L28
Quoted 8 lines
Best regards
Chen JunQuoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
drivers/video/fbdev/core/fbcon.c +0
-0ret =vc_resize (vc, cols, rows);if (ret) goto err_out;
Signature · 6 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
Helge Deller
maintainerQuoted 66 lines · Thomas Zimmermann
Hi
Am 04.03.26 um 04:47 schrieb chenjun (AM):
Quoted 63 lines · Thomas Zimmermann
Quoted 47 lines
Hi
Am 02.03.26 um 12:24 schrieb chenjun (AM):
Quoted 27 lines · Thomas Zimmermann
Quoted 26 lines
Am 27.02.26 um 15:43 schrieb Chen Jun:
Quoted 25 lines
When a font is set on an invisible console, the screen will not update. However, the fontbuffer is not updated to match the new font dimensions.
This inconsistency leads to out-of-bounds memory access when writing to the tty bound to fbcon, as demonstrated by the following KASAN report:
BUG: KASAN: slab-out-of-bounds in fb_pad_aligned_buffer+0xdf/0x140 Read of size 1 at addr ffff8881195a2280 by task a.out/971 Call Trace: <TASK> fb_pad_aligned_buffer+0xdf/0x140 ud_putcs+0x88a/0xde0 fbcon_putcs+0x319/0x430 do_update_region+0x23c/0x3b0 do_con_write+0x225c/0x67f0 con_write+0xe/0x30 n_tty_write+0x4b5/0xff0 file_tty_write.isra.41+0x46c/0x880 vfs_write+0x868/0xd60 ksys_write+0xf2/0x1d0 do_syscall_64+0xfa/0x570Fix this by calling
fbcon_rotate_font()if vc is invisible infbcon_do_set_font().Quoted 7 lines
Quoted 2 lines
Quoted 1 line
Signed-off-by Chen Jun <[email protected]>Reviewed-by Thomas Zimmermann <[email protected]>Hi Thomas,
Thanks for your review.
I'm not familiar with the fbcon module. Is there a better way to fix this?
Not really, I think. The whole module first needs a redesign to be easier to understand.
Best regards
ThomasQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
---
drivers/video/fbdev/core/fbcon.c| 5 +++++1 file changed, 5 insertions(+)Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/video/fbdev/core/fbcon.c +0
-0@@ -2444,6 +2444,11 @@ static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount,Quoted 8 lines
Quoted 8 lines
drivers/video/fbdev/core/fbcon.c static int fbcon_do_set_font(struct vc_data *vc, int w, int h, int charcount, · line 2451
Quoted 8 lines
drivers/video/fbdev/core/fbcon.c +5
-0rows = FBCON_SWAP(par->rotate, info->var.yres, info->var.xres); cols /= w; rows /= h; + if (!con_is_visible(vc)) { + ret = fbcon_rotate_font(info, vc); + if (ret) + goto err_out; + }Hi Thomas and Helge,
Quoted 5 lines
Quoted 3 lines
I apologize, but after reviewing the code, I believe there is a problem. The issue is that
fbcon_do_set_font()updates members ofinfo->fbcon_par, and the info are shared with other vc instances.Than let's drop the patch for now.
Patch is now dropped from fbdev git tree.
Helge