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

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