nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

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

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