mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
fbdev: fix potential buffer overflow in do_register_framebuffer()
[ Upstream commit 523b84dc7ccea9c4d79126d6ed1cf9033cf83b05 ] The current implementation may lead to buffer overflow when: 1. Unregistration creates NULL gaps in registered_fb[] 2. All array slots become occupied despite num_registered_fb < FB_MAX 3. The registration loop exceeds array bounds Add boundary check to prevent registered_fb[FB_MAX] access. Signed-off-by: Yongzhen Zhang <zhangyongzhen@kylinos.cn> Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
6daa13c201
commit
cbe740de32
@@ -943,6 +943,9 @@ static int do_register_framebuffer(struct fb_info *fb_info)
|
||||
if (!registered_fb[i])
|
||||
break;
|
||||
|
||||
if (i >= FB_MAX)
|
||||
return -ENXIO;
|
||||
|
||||
if (!fb_info->modelist.prev || !fb_info->modelist.next)
|
||||
INIT_LIST_HEAD(&fb_info->modelist);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user