Skip to contentSkip to conversation

fbmem: add margin check to fb_check_caps()

PATCH In review Dongliang Mu 2 participants 3 messages Sep 2, 2021 – Sep 4, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fbmem: add margin check to fb_check_caps()

[ Upstream commit a49145acfb975d921464b84fe00279f99827d816 ]

A fb_ioctl() FBIOPUT_VSCREENINFO call with invalid xres setting or yres setting in struct fb_var_screeninfo will result in a

KASAN: vmalloc-out-of-bounds failure in bitfill_aligned() as

the margins are being cleared. The margins are cleared in chunks and if the xres setting or yres setting is a value of zero upto the chunk size, the failure will occur.

Add a margin check to validate xres and yres settings.

Note that, this patch needs special handling to backport it to linux kernel 4.19, 4.14, 4.9, 4.4.

---
 drivers/video/fbdev/core/fbmem.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/video/fbdev/core/fbmem.c +4 -0
index 84845275dbef..de04c097d67c 100644
@@ -991,6 +991,10 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var)
 			goto done;
 		}
 
+		/* bitfill_aligned() assumes that it's at least 8x8 */
+		if (var->xres < 8 || var->yres < 8)
+			return -EINVAL;
+
 		ret = info->fbops->fb_check_var(var, info);
 
 		if (ret)
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 5 lines · Dongliang Mu

[ Upstream commit a49145acfb975d921464b84fe00279f99827d816 ]

A fb_ioctl() FBIOPUT_VSCREENINFO call with invalid xres setting or yres setting in struct fb_var_screeninfo will result in a

KASAN: vmalloc-out-of-bounds failure in bitfill_aligned() as
Quoted 8 lines

the margins are being cleared. The margins are cleared in chunks and if the xres setting or yres setting is a value of zero upto the chunk size, the failure will occur.

Add a margin check to validate xres and yres settings.

Note that, this patch needs special handling to backport it to linux kernel 4.19, 4.14, 4.9, 4.4.

Looks like this is already in the 4.4.283, 4.9.282, 4.14.246, and 4.19.206 kernel releases. Can you check them to verify that it matches your backport as well?

thanks,

greg k-h

#2 lore raw
Quoted 11 lines · Greg KH
Quoted 9 lines · Dongliang Mu

[ Upstream commit a49145acfb975d921464b84fe00279f99827d816 ]

A fb_ioctl() FBIOPUT_VSCREENINFO call with invalid xres setting or yres setting in struct fb_var_screeninfo will result in a

KASAN: vmalloc-out-of-bounds failure in bitfill_aligned() as

the margins are being cleared. The margins are cleared in chunks and if the xres setting or yres setting is a value of zero upto the chunk size, the failure will occur.

Quoted 8 lines
Quoted 4 lines

Add a margin check to validate xres and yres settings.

Note that, this patch needs special handling to backport it to linux kernel 4.19, 4.14, 4.9, 4.4.

Looks like this is already in the 4.4.283, 4.9.282, 4.14.246, and 4.19.206 kernel releases. Can you check them to verify that it matches your backport as well?

Yes, I have seen them in these releases and they are fine to me.

Quoted 4 lines

thanks,

greg k-h