diff options
Diffstat (limited to 'meta/recipes-bsp/grub/files/0034-video-fb-video_fb-Fix-possible-integer-overflow.patch')
-rw-r--r-- | meta/recipes-bsp/grub/files/0034-video-fb-video_fb-Fix-possible-integer-overflow.patch | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/meta/recipes-bsp/grub/files/0034-video-fb-video_fb-Fix-possible-integer-overflow.patch b/meta/recipes-bsp/grub/files/0034-video-fb-video_fb-Fix-possible-integer-overflow.patch new file mode 100644 index 0000000000..c82b2c7df0 --- /dev/null +++ b/meta/recipes-bsp/grub/files/0034-video-fb-video_fb-Fix-possible-integer-overflow.patch | |||
@@ -0,0 +1,39 @@ | |||
1 | From aac5574ff340a665ccc78d4c3d61596ac67acbbe Mon Sep 17 00:00:00 2001 | ||
2 | From: Darren Kenny <darren.kenny@oracle.com> | ||
3 | Date: Fri, 4 Dec 2020 14:51:30 +0000 | ||
4 | Subject: [PATCH] video/fb/video_fb: Fix possible integer overflow | ||
5 | |||
6 | It is minimal possibility that the values being used here will overflow. | ||
7 | So, change the code to use the safemath function grub_mul() to ensure | ||
8 | that doesn't happen. | ||
9 | |||
10 | Fixes: CID 73761 | ||
11 | |||
12 | Signed-off-by: Darren Kenny <darren.kenny@oracle.com> | ||
13 | Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com> | ||
14 | |||
15 | Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=08413f2f4edec0e2d9bf15f836f6ee5ca2e379cb] | ||
16 | Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com> | ||
17 | --- | ||
18 | grub-core/video/fb/video_fb.c | 8 +++++++- | ||
19 | 1 file changed, 7 insertions(+), 1 deletion(-) | ||
20 | |||
21 | diff --git a/grub-core/video/fb/video_fb.c b/grub-core/video/fb/video_fb.c | ||
22 | index 1c9a138..ae6b89f 100644 | ||
23 | --- a/grub-core/video/fb/video_fb.c | ||
24 | +++ b/grub-core/video/fb/video_fb.c | ||
25 | @@ -1537,7 +1537,13 @@ doublebuf_pageflipping_init (struct grub_video_mode_info *mode_info, | ||
26 | volatile void *page1_ptr) | ||
27 | { | ||
28 | grub_err_t err; | ||
29 | - grub_size_t page_size = mode_info->pitch * mode_info->height; | ||
30 | + grub_size_t page_size = 0; | ||
31 | + | ||
32 | + if (grub_mul (mode_info->pitch, mode_info->height, &page_size)) | ||
33 | + { | ||
34 | + /* Shouldn't happen, but if it does we've a bug. */ | ||
35 | + return GRUB_ERR_BUG; | ||
36 | + } | ||
37 | |||
38 | framebuffer.offscreen_buffer = grub_malloc (page_size); | ||
39 | if (! framebuffer.offscreen_buffer) | ||