Re: [PATCH 4.19 085/125] fbcon: prevent user font height or width change from causing potential out-of-bounds access

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue 2020-09-01 17:10:40, Greg Kroah-Hartman wrote:
> From: George Kennedy <george.kennedy@xxxxxxxxxx>
> 
> commit 39b3cffb8cf3111738ea993e2757ab382253d86a upstream.
> 
> Add a check to fbcon_resize() to ensure that a possible change to user font
> height or user font width will not allow a font data out-of-bounds access.
> NOTE: must use original charcount in calculation as font charcount can
> change and cannot be used to determine the font data allocated size.


> +#define PITCH(w) (((w) + 7) >> 3)
> +#define CALC_FONTSZ(h, p, c) ((h) * (p) * (c)) /* size = height * pitch * charcount */

Ok, so we validate data from user. Can this overflow? Should it be
inline function for readability?

>  static int fbcon_resize(struct vc_data *vc, unsigned int width, 
>  			unsigned int height, unsigned int user)
>  {
> @@ -2161,6 +2164,24 @@ static int fbcon_resize(struct vc_data *
>  	struct fb_var_screeninfo var = info->var;
>  	int x_diff, y_diff, virt_w, virt_h, virt_fw, virt_fh;
>  
> +	if (ops->p && ops->p->userfont && FNTSIZE(vc->vc_font.data)) {
> +		int size;
> +		int pitch = PITCH(vc->vc_font.width);

Should size be unsigned?

Best regards,
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux