summaryrefslogtreecommitdiffstats
path: root/meta/recipes-bsp/grub/files/0032-video-fb-fbfill-Fix-potential-integer-overflow.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-bsp/grub/files/0032-video-fb-fbfill-Fix-potential-integer-overflow.patch')
-rw-r--r--meta/recipes-bsp/grub/files/0032-video-fb-fbfill-Fix-potential-integer-overflow.patch78
1 files changed, 78 insertions, 0 deletions
diff --git a/meta/recipes-bsp/grub/files/0032-video-fb-fbfill-Fix-potential-integer-overflow.patch b/meta/recipes-bsp/grub/files/0032-video-fb-fbfill-Fix-potential-integer-overflow.patch
new file mode 100644
index 0000000000..8165ea3f71
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/0032-video-fb-fbfill-Fix-potential-integer-overflow.patch
@@ -0,0 +1,78 @@
1From 99ecf5a44b99d529a6405fe276bedcefa3657a0a Mon Sep 17 00:00:00 2001
2From: Darren Kenny <darren.kenny@oracle.com>
3Date: Wed, 4 Nov 2020 15:10:51 +0000
4Subject: [PATCH] video/fb/fbfill: Fix potential integer overflow
5
6The multiplication of 2 unsigned 32-bit integers may overflow before
7promotion to unsigned 64-bit. We should ensure that the multiplication
8is done with overflow detection. Additionally, use grub_sub() for
9subtraction.
10
11Fixes: CID 73640, CID 73697, CID 73702, CID 73823
12
13Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
14Signed-off-by: Marco A Benatto <mbenatto@redhat.com>
15Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
16
17Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=7ce3259f67ac2cd93acb0ec0080c24b3b69e66c6]
18Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
19---
20 grub-core/video/fb/fbfill.c | 17 +++++++++++++----
21 1 file changed, 13 insertions(+), 4 deletions(-)
22
23diff --git a/grub-core/video/fb/fbfill.c b/grub-core/video/fb/fbfill.c
24index 11816d0..a37acd1 100644
25--- a/grub-core/video/fb/fbfill.c
26+++ b/grub-core/video/fb/fbfill.c
27@@ -31,6 +31,7 @@
28 #include <grub/fbfill.h>
29 #include <grub/fbutil.h>
30 #include <grub/types.h>
31+#include <grub/safemath.h>
32 #include <grub/video.h>
33
34 /* Generic filler that works for every supported mode. */
35@@ -61,7 +62,9 @@ grub_video_fbfill_direct32 (struct grub_video_fbblit_info *dst,
36
37 /* Calculate the number of bytes to advance from the end of one line
38 to the beginning of the next line. */
39- rowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
40+ if (grub_mul (dst->mode_info->bytes_per_pixel, width, &rowskip) ||
41+ grub_sub (dst->mode_info->pitch, rowskip, &rowskip))
42+ return;
43
44 /* Get the start address. */
45 dstptr = grub_video_fb_get_video_ptr (dst, x, y);
46@@ -98,7 +101,9 @@ grub_video_fbfill_direct24 (struct grub_video_fbblit_info *dst,
47 #endif
48 /* Calculate the number of bytes to advance from the end of one line
49 to the beginning of the next line. */
50- rowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
51+ if (grub_mul (dst->mode_info->bytes_per_pixel, width, &rowskip) ||
52+ grub_sub (dst->mode_info->pitch, rowskip, &rowskip))
53+ return;
54
55 /* Get the start address. */
56 dstptr = grub_video_fb_get_video_ptr (dst, x, y);
57@@ -131,7 +136,9 @@ grub_video_fbfill_direct16 (struct grub_video_fbblit_info *dst,
58
59 /* Calculate the number of bytes to advance from the end of one line
60 to the beginning of the next line. */
61- rowskip = (dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width);
62+ if (grub_mul (dst->mode_info->bytes_per_pixel, width, &rowskip) ||
63+ grub_sub (dst->mode_info->pitch, rowskip, &rowskip))
64+ return;
65
66 /* Get the start address. */
67 dstptr = grub_video_fb_get_video_ptr (dst, x, y);
68@@ -161,7 +168,9 @@ grub_video_fbfill_direct8 (struct grub_video_fbblit_info *dst,
69
70 /* Calculate the number of bytes to advance from the end of one line
71 to the beginning of the next line. */
72- rowskip = dst->mode_info->pitch - dst->mode_info->bytes_per_pixel * width;
73+ if (grub_mul (dst->mode_info->bytes_per_pixel, width, &rowskip) ||
74+ grub_sub (dst->mode_info->pitch, rowskip, &rowskip))
75+ return;
76
77 /* Get the start address. */
78 dstptr = grub_video_fb_get_video_ptr (dst, x, y);