]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.14.53/video-uvesafb-fix-integer-overflow-in-allocation.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.14.53 / video-uvesafb-fix-integer-overflow-in-allocation.patch
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
5
6 From: Kees Cook <keescook@chromium.org>
7
8 commit 9f645bcc566a1e9f921bdae7528a01ced5bc3713 upstream.
9
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.
12
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>
18
19 ---
20 drivers/video/fbdev/uvesafb.c | 3 ++-
21 1 file changed, 2 insertions(+), 1 deletion(-)
22
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)
27 return -EINVAL;
28
29 - entries = kmalloc(sizeof(*entries) * cmap->len, GFP_KERNEL);
30 + entries = kmalloc_array(cmap->len, sizeof(*entries),
31 + GFP_KERNEL);
32 if (!entries)
33 return -ENOMEM;
34