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