Skip to content

Commit

Permalink
fbdev: sis: Error out if pixclock equals zero
Browse files Browse the repository at this point in the history
[ Upstream commit e421946 ]

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.

In sisfb_check_var(), var->pixclock is used as a divisor to caculate
drate before it is checked against zero. Fix this by checking it
at the beginning.

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Fullway Wang authored and gregkh committed Mar 1, 2024
1 parent bc3c2e5 commit 99f1abc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/video/fbdev/sis/sis_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1475,6 +1475,8 @@ sisfb_check_var(struct fb_var_screeninfo *var, struct fb_info *info)

vtotal = var->upper_margin + var->lower_margin + var->vsync_len;

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

if((var->vmode & FB_VMODE_MASK) == FB_VMODE_NONINTERLACED) {
Expand Down

0 comments on commit 99f1abc

Please sign in to comment.