diff options
author | Wei Chen <harperchen1110@gmail.com> | 2023-03-07 16:08:56 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-04-05 12:14:19 +0300 |
commit | 9e4b357b30b01c08e987316048baac10b9d8b19d (patch) | |
tree | 3584492ffdd2cdfcc934184ab29c7a8eb2ad3a69 | |
parent | ff5e8b49348f6a550c136b74efaf8b3c1d3ceaea (diff) | |
download | linux-9e4b357b30b01c08e987316048baac10b9d8b19d.tar.xz |
fbdev: tgafb: Fix potential divide by zero
[ Upstream commit f90bd245de82c095187d8c2cabb8b488a39eaecc ]
fb_set_var would by called when user invokes ioctl with cmd
FBIOPUT_VSCREENINFO. User-provided data would finally reach
tgafb_check_var. In case var->pixclock is assigned to zero,
divide by zero would occur when checking whether reciprocal
of var->pixclock is too high.
Similar crashes have happened in other fbdev drivers. There
is no check and modification on var->pixclock along the call
chain to tgafb_check_var. We believe it could also be triggered
in driver tgafb from user site.
Signed-off-by: Wei Chen <harperchen1110@gmail.com>
Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | drivers/video/fbdev/tgafb.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/video/fbdev/tgafb.c b/drivers/video/fbdev/tgafb.c index 65ba9921506e..9d2912947eef 100644 --- a/drivers/video/fbdev/tgafb.c +++ b/drivers/video/fbdev/tgafb.c @@ -166,6 +166,9 @@ tgafb_check_var(struct fb_var_screeninfo *var, struct fb_info *info) { struct tga_par *par = (struct tga_par *)info->par; + if (!var->pixclock) + return -EINVAL; + if (par->tga_type == TGA_TYPE_8PLANE) { if (var->bits_per_pixel != 8) return -EINVAL; |