1 From 9f645bcc566a1e9f921bdae7528a01ced5bc3713 Mon Sep 17 00:00:00 2001
2 From: Kees Cook <keescook@chromium.org>
3 Date: Fri, 11 May 2018 18:24:12 +1000
4 Subject: video: uvesafb: Fix integer overflow in allocation
6 From: Kees Cook <keescook@chromium.org>
8 commit 9f645bcc566a1e9f921bdae7528a01ced5bc3713 upstream.
10 cmap->len can get close to INT_MAX/2, allowing for an integer overflow in
11 allocation. This uses kmalloc_array() instead to catch the condition.
13 Reported-by: Dr Silvio Cesare of InfoSect <silvio.cesare@gmail.com>
14 Fixes: 8bdb3a2d7df48 ("uvesafb: the driver core")
15 Cc: stable@vger.kernel.org
16 Signed-off-by: Kees Cook <keescook@chromium.org>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20 drivers/video/fbdev/uvesafb.c | 3 ++-
21 1 file changed, 2 insertions(+), 1 deletion(-)
23 --- a/drivers/video/fbdev/uvesafb.c
24 +++ b/drivers/video/fbdev/uvesafb.c
25 @@ -1044,7 +1044,8 @@ static int uvesafb_setcmap(struct fb_cma
26 info->cmap.len || cmap->start < info->cmap.start)
29 - entries = kmalloc(sizeof(*entries) * cmap->len, GFP_KERNEL);
30 + entries = kmalloc_array(cmap->len, sizeof(*entries),