dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0418-video-fb-video_fb-Fix-possible-integer-overflow.patch

80913e
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
80913e
From: Darren Kenny <darren.kenny@oracle.com>
80913e
Date: Fri, 4 Dec 2020 14:51:30 +0000
80913e
Subject: [PATCH] video/fb/video_fb: Fix possible integer overflow
80913e
80913e
It is minimal possibility that the values being used here will overflow.
80913e
So, change the code to use the safemath function grub_mul() to ensure
80913e
that doesn't happen.
80913e
80913e
Fixes: CID 73761
80913e
80913e
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
80913e
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
80913e
---
80913e
 grub-core/video/fb/video_fb.c | 8 +++++++-
80913e
 1 file changed, 7 insertions(+), 1 deletion(-)
80913e
80913e
diff --git a/grub-core/video/fb/video_fb.c b/grub-core/video/fb/video_fb.c
80913e
index 1c9a138dcdc..ae6b89f9aea 100644
80913e
--- a/grub-core/video/fb/video_fb.c
80913e
+++ b/grub-core/video/fb/video_fb.c
80913e
@@ -1537,7 +1537,13 @@ doublebuf_pageflipping_init (struct grub_video_mode_info *mode_info,
80913e
 			     volatile void *page1_ptr)
80913e
 {
80913e
   grub_err_t err;
80913e
-  grub_size_t page_size = mode_info->pitch * mode_info->height;
80913e
+  grub_size_t page_size = 0;
80913e
+
80913e
+  if (grub_mul (mode_info->pitch, mode_info->height, &page_size))
80913e
+    {
80913e
+      /* Shouldn't happen, but if it does we've a bug. */
80913e
+      return GRUB_ERR_BUG;
80913e
+    }
80913e
 
80913e
   framebuffer.offscreen_buffer = grub_malloc (page_size);
80913e
   if (! framebuffer.offscreen_buffer)