nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0348-disk-cryptodisk-Fix-potential-integer-overflow.patch

9723a8
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
9723a8
From: Darren Kenny <darren.kenny@oracle.com>
9723a8
Date: Thu, 21 Jan 2021 11:38:31 +0000
9723a8
Subject: [PATCH] disk/cryptodisk: Fix potential integer overflow
9723a8
9723a8
The encrypt and decrypt functions expect a grub_size_t. So, we need to
9723a8
ensure that the constant bit shift is using grub_size_t rather than
9723a8
unsigned int when it is performing the shift.
9723a8
9723a8
Fixes: CID 307788
9723a8
9723a8
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
9723a8
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
9723a8
---
9723a8
 grub-core/disk/cryptodisk.c | 8 ++++----
9723a8
 1 file changed, 4 insertions(+), 4 deletions(-)
9723a8
9723a8
diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c
9723a8
index bd60a66b384..78a902515e9 100644
9723a8
--- a/grub-core/disk/cryptodisk.c
9723a8
+++ b/grub-core/disk/cryptodisk.c
9723a8
@@ -311,10 +311,10 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
9723a8
 	case GRUB_CRYPTODISK_MODE_CBC:
9723a8
 	  if (do_encrypt)
9723a8
 	    err = grub_crypto_cbc_encrypt (dev->cipher, data + i, data + i,
9723a8
-					   (1U << dev->log_sector_size), iv);
9723a8
+					   ((grub_size_t) 1 << dev->log_sector_size), iv);
9723a8
 	  else
9723a8
 	    err = grub_crypto_cbc_decrypt (dev->cipher, data + i, data + i,
9723a8
-					   (1U << dev->log_sector_size), iv);
9723a8
+					   ((grub_size_t) 1 << dev->log_sector_size), iv);
9723a8
 	  if (err)
9723a8
 	    return err;
9723a8
 	  break;
9723a8
@@ -322,10 +322,10 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
9723a8
 	case GRUB_CRYPTODISK_MODE_PCBC:
9723a8
 	  if (do_encrypt)
9723a8
 	    err = grub_crypto_pcbc_encrypt (dev->cipher, data + i, data + i,
9723a8
-					    (1U << dev->log_sector_size), iv);
9723a8
+					    ((grub_size_t) 1 << dev->log_sector_size), iv);
9723a8
 	  else
9723a8
 	    err = grub_crypto_pcbc_decrypt (dev->cipher, data + i, data + i,
9723a8
-					    (1U << dev->log_sector_size), iv);
9723a8
+					    ((grub_size_t) 1 << dev->log_sector_size), iv);
9723a8
 	  if (err)
9723a8
 	    return err;
9723a8
 	  break;