Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] fbcon: invalid kfree() of font_data_t pointer in fbcon_do_set_font() - [Low] lib/fonts: contradictory kernel-doc comment for font_data_rotate() --
commit b5f0d07cd7c39fad0c72c3148ca9444f977625ca Author: Thomas Zimmermann <[email protected]> lib/fonts, fbcon: Use font_data_t for rotated fonts This commit converts font_data_rotate() and struct fbcon_rotated.buf to use font_data_t instead of unsigned char *, releasing rotated font data in fbcon with font_data_put(). > diff --git a/drivers/video/fbdev/core/fbcon.h > b/drivers/video/fbdev/core/fbcon.h > index 289a3d18f917f..28111c706e348 100644 > --- a/drivers/video/fbdev/core/fbcon.h > +++ b/drivers/video/fbdev/core/fbcon.h > @@ -75,8 +75,7 @@ struct fbcon_bitops { > #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION > struct fbcon_rotated { > font_data_t *fontdata; /* source font */ > - unsigned char *buf; /* rotated glyphs */ > - size_t bufsize; > + font_data_t *buf; /* rotated font */ > int buf_rotate; /* rotation of buf */ > unsigned int buf_width; /* geometry of source font */ > unsigned int buf_height; [Severity: High] Does fbcon_do_set_font() still pass struct fbcon_rotated.buf directly to kfree() when changing the font on a visible rotated console? drivers/video/fbdev/core/fbcon.c:fbcon_do_set_font() { ... #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION if (rotated_saved) kfree(saved_rotated.buf); #endif ... err_out: #ifdef CONFIG_FRAMEBUFFER_CONSOLE_ROTATION if (rotated_saved) { kfree(par->rotated.buf); par->rotated = saved_rotated; } #endif ... } Because __font_data_alloc() returns &font_data->data[0] (offset 16 bytes past the start of struct font_data), calling kfree() on saved_rotated.buf or par->rotated.buf frees an interior pointer and corrupts the slab. Both paths need to check for a non-NULL buffer and release it with font_data_put() instead. [ ... ] > diff --git a/lib/fonts/font_rotate.c b/lib/fonts/font_rotate.c > index 275406008823b..ea54bd618ffb0 100644 > --- a/lib/fonts/font_rotate.c > +++ b/lib/fonts/font_rotate.c > @@ -181,8 +181,7 @@ EXPORT_SYMBOL_GPL(font_glyph_rotate_270); > * @height: The number of scanlines in the glyph > * @charcount: The number of glyphs in the font > * @steps: Number of rotation steps of 90° > - * @buf: Preallocated output buffer; can be NULL > - * @bufsize: The size of @buf in bytes; can be NULL > + * @buf: Preallocated font data; can be NULL > * > * The parameters @width and @height refer to the visible number of pixels > * and scanlines in a single glyph. The number of glyphs is given in > @charcount. > @@ -194,16 +193,14 @@ EXPORT_SYMBOL_GPL(font_glyph_rotate_270); > * as returned by font_data_buf(). Callers are responsible to free the > returned > * buffer with kfree(). Font rotation typically happens when displays get > * re-oriented. To avoid unnecessary re-allocation of the memory buffer, the > - * caller can pass in an earlier result buffer in @buf for reuse. The old and > - * new buffer sizes are given and retrieved by the caller in @bufsize. The > - * allocation semantics are compatible with krealloc(). > + * caller can pass in an earlier result in @buf for reuse. The returned font > + * data should be released with font_data_put(). [Severity: Low] This isn't a bug, but the earlier sentences in this kernel-doc comment still say that the returned buffer is not compatible with font_data_t and must be freed with kfree(), contradicting the new sentence at the end. -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
