mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-29 21:33:00 +01:00
fbdev: bitblit: bound-check glyph index in bit_putcs*
bit_putcs_aligned()/unaligned() derived the glyph pointer from the character value masked by 0xff/0x1ff, which may exceed the actual font's glyph count and read past the end of the built-in font array. Clamp the index to the actual glyph count before computing the address. This fixes a global out-of-bounds read reported by syzbot. Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=793cf822d213be1a74f2 Tested-by: [email protected] Signed-off-by: Junjie Cao <[email protected]> Reviewed-by: Thomas Zimmermann <[email protected]> Signed-off-by: Helge Deller <[email protected]> Cc: [email protected]
This commit is contained in:
1 parent
5f566c0ac5
commit
18c4ef4e76
1 file changed
+12
-4
@@ -79,12 +79,16 @@ static inline void bit_putcs_aligned(struct vc_data *vc, struct fb_info *info,
|
||||
struct fb_image *image, u8 *buf, u8 *dst)
|
||||
{
|
||||
u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
|
||||
unsigned int charcnt = vc->vc_font.charcount;
|
||||
u32 idx = vc->vc_font.width >> 3;
|
||||
u8 *src;
|
||||
|
||||
while (cnt--) {
|
||||
src = vc->vc_font.data + (scr_readw(s++)&
|
||||
charmask)*cellsize;
|
||||
u16 ch = scr_readw(s++) & charmask;
|
||||
|
||||
if (ch >= charcnt)
|
||||
ch = 0;
|
||||
src = vc->vc_font.data + (unsigned int)ch * cellsize;
|
||||
|
||||
if (attr) {
|
||||
update_attr(buf, src, attr, vc);
|
||||
@@ -112,14 +116,18 @@ static inline void bit_putcs_unaligned(struct vc_data *vc,
|
||||
u8 *dst)
|
||||
{
|
||||
u16 charmask = vc->vc_hi_font_mask ? 0x1ff : 0xff;
|
||||
unsigned int charcnt = vc->vc_font.charcount;
|
||||
u32 shift_low = 0, mod = vc->vc_font.width % 8;
|
||||
u32 shift_high = 8;
|
||||
u32 idx = vc->vc_font.width >> 3;
|
||||
u8 *src;
|
||||
|
||||
while (cnt--) {
|
||||
src = vc->vc_font.data + (scr_readw(s++)&
|
||||
charmask)*cellsize;
|
||||
u16 ch = scr_readw(s++) & charmask;
|
||||
|
||||
if (ch >= charcnt)
|
||||
ch = 0;
|
||||
src = vc->vc_font.data + (unsigned int)ch * cellsize;
|
||||
|
||||
if (attr) {
|
||||
update_attr(buf, src, attr, vc);
|
||||
|
||||
Reference in new issue
Block a user