On 10/16/26 09:30, Yao Yiqi wrote:
From: Yao Yiqi <[email protected]>fbcon_rotate_font() caches a rotated copy of the console font in par->rotated.buf and skips the rebuild when the cache appears to be up to date. The cache is keyed on the source font's data pointer and the rotation alone, on the assumption that an unchanged fontdata pointer implies an unchanged font. That assumption does not hold. Raw font data (font_data_t) stores no glyph geometry; width, height and charcount are tracked separately in vc->vc_font. When a font is uploaded, fbcon_set_font() deduplicates it against the fonts of all consoles with font_data_is_equal(), which compares only the byte count, the checksum and the raw bytes. Two uploads of the same data that declare different dimensions therefore end up sharing one font_data_t, and a console can install a new geometry while its fontdata pointer stays the same. The early-out in fbcon_rotate_font() then skips the rebuild, and the rotated blitting routines index the stale buffer with cell sizes computed from the new geometry: src = par->rotated.buf + (scr_readw(s) & charmask) * cellsize; Rotation swaps a glyph's width and height, so the size of the rotated cell depends on pitch rounding and differs between geometries. A 4x16 font whose 4096 bytes are re-uploaded as 16x8 on a CW-rotated console, for example, grows the rotated cell size from 8 to 16 bytes, and the largest character then reads past the end of the 2048-byte buffer that was built for the 4x16 geometry. The key has never included the geometry. Its exposure was limited, but not eliminated, while the deduplication in fbcon_set_font() also compared the consoles' font widths and total byte counts: with the charcount restricted to 256 or 512, differing uploads could then only trade height against charcount (such as 4x18x256 against 4x9x512), and even those can change the rotated cell size. Commit 1e3c49aa03fb ("lib/fonts: Compare font data for equality with font_data_is_equal()") dropped the width comparison, so identical bytes now share font data across arbitrary dimensions. Record the geometry that the buffer was built from and compare it in the early-out, so a geometry change always triggers a rebuild. Fixes: 6cc50e1c5b57 ("[PATCH] fbcon: Console Rotation - Add support to rotate font bitmap") Cc: [email protected] Signed-off-by: Yao Yiqi <[email protected]> --- drivers/video/fbdev/core/fbcon.h | 9 ++++++--- drivers/video/fbdev/core/fbcon_rotate.c | 9 ++++++++- 2 files changed, 14 insertions(+), 4 deletions(-)
I've replaced the v1 version of this series with this v3 version in fbdev/for-next git tree for further testing. Thanks! Helge
