mirror of
https://git.yoctoproject.org/poky
synced 2026-04-04 05:02:21 +02:00
grub: fix an integer overflow
This patch fixes a potential overflow in grub's disk/cryptodisk. It is a part of a security series [1] [1] https://lists.gnu.org/archive/html/grub-devel/2021-03/msg00007.html (From OE-Core rev: 85405f0d3a4b844f7bbb34717bd5f88b81acb074) Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com> Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
40d7b77030
commit
e97cfd1660
@@ -0,0 +1,50 @@
|
||||
From 2550aaa0c23fdf8b6c54e00c6b838f2e3aa81fe2 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Thu, 21 Jan 2021 11:38:31 +0000
|
||||
Subject: [PATCH] disk/cryptodisk: Fix potential integer overflow
|
||||
|
||||
The encrypt and decrypt functions expect a grub_size_t. So, we need to
|
||||
ensure that the constant bit shift is using grub_size_t rather than
|
||||
unsigned int when it is performing the shift.
|
||||
|
||||
Fixes: CID 307788
|
||||
|
||||
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
|
||||
Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=a201ad17caa430aa710654fdf2e6ab4c8166f031]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/disk/cryptodisk.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/grub-core/disk/cryptodisk.c b/grub-core/disk/cryptodisk.c
|
||||
index 5037768..6883f48 100644
|
||||
--- a/grub-core/disk/cryptodisk.c
|
||||
+++ b/grub-core/disk/cryptodisk.c
|
||||
@@ -311,10 +311,10 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
|
||||
case GRUB_CRYPTODISK_MODE_CBC:
|
||||
if (do_encrypt)
|
||||
err = grub_crypto_cbc_encrypt (dev->cipher, data + i, data + i,
|
||||
- (1U << dev->log_sector_size), iv);
|
||||
+ ((grub_size_t) 1 << dev->log_sector_size), iv);
|
||||
else
|
||||
err = grub_crypto_cbc_decrypt (dev->cipher, data + i, data + i,
|
||||
- (1U << dev->log_sector_size), iv);
|
||||
+ ((grub_size_t) 1 << dev->log_sector_size), iv);
|
||||
if (err)
|
||||
return err;
|
||||
break;
|
||||
@@ -322,10 +322,10 @@ grub_cryptodisk_endecrypt (struct grub_cryptodisk *dev,
|
||||
case GRUB_CRYPTODISK_MODE_PCBC:
|
||||
if (do_encrypt)
|
||||
err = grub_crypto_pcbc_encrypt (dev->cipher, data + i, data + i,
|
||||
- (1U << dev->log_sector_size), iv);
|
||||
+ ((grub_size_t) 1 << dev->log_sector_size), iv);
|
||||
else
|
||||
err = grub_crypto_pcbc_decrypt (dev->cipher, data + i, data + i,
|
||||
- (1U << dev->log_sector_size), iv);
|
||||
+ ((grub_size_t) 1 << dev->log_sector_size), iv);
|
||||
if (err)
|
||||
return err;
|
||||
break;
|
||||
@@ -65,6 +65,7 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
|
||||
file://0016-disk-ldm-Make-sure-comp-data-is-freed-before-exiting.patch \
|
||||
file://0017-disk-ldm-If-failed-then-free-vg-variable-too.patch \
|
||||
file://0018-disk-ldm-Fix-memory-leak-on-uninserted-lv-references.patch \
|
||||
file://0019-disk-cryptodisk-Fix-potential-integer-overflow.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934"
|
||||
SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"
|
||||
|
||||
Reference in New Issue
Block a user