Skip to content

Commit

Permalink
fbdev: savage: Error out if pixclock equals zero
Browse files Browse the repository at this point in the history
The userspace program could pass any values to the driver through
ioctl() interface. If the driver doesn't check the value of pixclock,
it may cause divide-by-zero error.

Although pixclock is checked in savagefb_decode_var(), but it is not
checked properly in savagefb_probe(). Fix this by checking whether
pixclock is zero in the function savagefb_check_var() before
info->var.pixclock is used as the divisor.

This is similar to CVE-2022-3061 in i740fb which was fixed by
commit 15cf0b8.

Signed-off-by: Fullway Wang <fullwaywang@outlook.com>
Signed-off-by: Helge Deller <deller@gmx.de>
  • Loading branch information
Fullway Wang authored and Helge Deller committed Jan 21, 2024
1 parent fead905 commit 04e5eac
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/video/fbdev/savage/savagefb_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,9 @@ static int savagefb_check_var(struct fb_var_screeninfo *var,

DBG("savagefb_check_var");

if (!var->pixclock)
return -EINVAL;

var->transp.offset = 0;
var->transp.length = 0;
switch (var->bits_per_pixel) {
Expand Down

0 comments on commit 04e5eac

Please sign in to comment.