Linux Framebuffer Layer development
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Syed Tayyab Farooq <syedtayyabfarooq08@gmail.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Simona Vetter <simona@ffwll.ch>, Andrew Morton <akpm@osdl.org>,
	Antonino Daplas <adaplas@pol.net>,
	"open list:FRAMEBUFFER CONSOLE" <dri-devel@lists.freedesktop.org>,
	"open list:FRAMEBUFFER CONSOLE" <linux-fbdev@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Cc: syzbot+bf4020519fbd94b2355d@syzkaller.appspotmail.com
Subject: Re: [PATCH] fbdev: fbcon: Fix KASAN slab-out-of-bounds read in rotated font buffer
Date: Wed, 18 Nov 2026 22:33:44 +0100	[thread overview]
Message-ID: <ed40f891-5fc9-4f97-b380-e2ca92856fa1@gmx.de> (raw)
In-Reply-To: <20260923060924.45742-1-syedtayyabfarooq08@gmail.com>

On 9/23/26 08:08, Syed Tayyab Farooq wrote:
> The root cause of this KASAN slab-out-of-bounds read is that fbcon fails to
> reallocate the rotated font buffer (par->rotated.buf) when the font
> character count changes but the font dimensions (width and height) remain
> the same.
> 
> When a user changes the font via ioctl(KDFONTOP), fbcon_do_set_font() is
> called. If the user first sets a 256-character font, enables rotation, and
> then sets a 512-character font with the exact same width and height, resize
> evaluates to false. The function then directly calls update_screen(vc).
> Notice that fbcon_do_set_font() never calls par->bitops->rotate_font() to
> update the rotated font buffer for the new font. As a result,
> par->rotated.buf remains sized for the old 256-character font.
> 
> When update_screen(vc) is called, it eventually reaches cw_putcs_aligned(),
> which attempts to read the glyphs from the rotated buffer. Since
> vc->vc_font.charcount is now 512, vc->vc_hi_font_mask is set, making
> charmask equal to 0x1ff (511). If the text buffer contains a character with
> an index >= 256, src will point out of bounds of the old par->rotated.buf
> (which only holds 256 glyphs). The subsequent read in
> __fb_pad_aligned_buffer() triggers the KASAN slab-out-of-bounds crash.
> 
> To fix this, fbcon_do_set_font() must call par->bitops->rotate_font() to
> update the rotated font buffer before calling vc_resize() or
> update_screen(). If vc_resize() fails and the old font is restored in the
> error path, rotate_font() must be called again to restore the rotated
> buffer.
> 
> This pattern of updating the rotated font buffer was previously established
> in fbcon_modechanged() by commit ef7656e85f1a ("fbdev: Fix out-of-bounds
> access when rotating console after font resize"). The fix applies this
> exact idiom to fbcon_do_set_font(). By placing it before vc_resize() and
> update_screen(), we ensure the buffer is correctly sized before any
> rendering occurs. Checking con_is_visible(vc) is also correct here, as
> hidden consoles will have their rotation state updated later via
> fbcon_switch() when they become visible.
> 
> Furthermore, by calling rotate_font() again in the err_out path, we ensure
> that if vc_resize() fails, the rotated buffer is restored to match the old
> vc->vc_font. Without this, restoring a 512-character font to a
> 256-character font on failure would leave the rotated buffer sized for 512
> characters, which wastes memory; or worse, restoring a 256-character font
> to a 512-character font would leave the buffer too small, causing an
> out-of-bounds read later.
> 
> Fixes: e4fc27618b75 ("[PATCH] fbcon: Console Rotation - Prepare fbcon for console rotation")
> Assisted-by: Gemini:gemini-3.6-flash Gemini:gemini-3.1-pro-preview syzbot
> Reported-by: syzbot+bf4020519fbd94b2355d@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=bf4020519fbd94b2355d
> Link: https://syzkaller.appspot.com/ai_job?id=59f0d7d9-607c-4497-b2e2-0b16693f9502
> Signed-off-by: Syed Tayyab Farooq <syedtayyabfarooq08@gmail.com>
> ---
>   drivers/video/fbdev/core/fbcon.c | 14 ++++++++++++++
>   1 file changed, 14 insertions(+)
applied to fbdev for further testing.

Thanks!
Helge

      parent reply	other threads:[~2026-11-18 21:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23  6:08 [PATCH] fbdev: fbcon: Fix KASAN slab-out-of-bounds read in rotated font buffer Syed Tayyab Farooq
2026-11-11 11:30 ` Syed Tayyab Farooq
2026-11-18 21:33 ` Helge Deller [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ed40f891-5fc9-4f97-b380-e2ca92856fa1@gmx.de \
    --to=deller@gmx.de \
    --cc=adaplas@pol.net \
    --cc=akpm@osdl.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=syedtayyabfarooq08@gmail.com \
    --cc=syzbot+bf4020519fbd94b2355d@syzkaller.appspotmail.com \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox