Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fbdev: fbmem: Fix the implicit type casting

In function do_fb_ioctl(), the "arg" is the type of unsigned long,
and in "case FBIOBLANK:" this argument is casted into an int before
passig to fb_blank(). In fb_blank(), the comparision
if (blank > FB_BLANK_POWERDOWN) would be bypass if the original
"arg" is a large number, which is possible because it comes from
the user input. Fix this by adding the check before the function
call.

Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Helge Deller <deller@gmx.de>
Signed-off-by: Yizhuo Zhai <yzhai003@ucr.edu>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20220202235811.1621017-1-yzhai003@ucr.edu

authored by

Yizhuo Zhai and committed by
Daniel Vetter
68e8cc2a 622c9a3a

+2
+2
drivers/video/fbdev/core/fbmem.c
··· 1160 1160 ret = fbcon_set_con2fb_map_ioctl(argp); 1161 1161 break; 1162 1162 case FBIOBLANK: 1163 + if (arg > FB_BLANK_POWERDOWN) 1164 + return -EINVAL; 1163 1165 console_lock(); 1164 1166 lock_fb_info(info); 1165 1167 ret = fb_blank(info, arg);