mirror of
https://git.yoctoproject.org/poky
synced 2026-04-05 08:02:25 +02:00
grub: add a fix for possible integer overflows
This patch adds a fix for a possible integer overflows in grub's zfs. 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: a21a1f225090b2f9d4c76e323fa7cc2051587924) 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
0dd3f436f4
commit
f4c3f4508a
@@ -0,0 +1,56 @@
|
||||
From ec35d862f3567671048aa0d0d8ad1ded1fd25336 Mon Sep 17 00:00:00 2001
|
||||
From: Darren Kenny <darren.kenny@oracle.com>
|
||||
Date: Tue, 8 Dec 2020 22:17:04 +0000
|
||||
Subject: [PATCH] zfs: Fix possible integer overflows
|
||||
|
||||
In all cases the problem is that the value being acted upon by
|
||||
a left-shift is a 32-bit number which is then being used in the
|
||||
context of a 64-bit number.
|
||||
|
||||
To avoid overflow we ensure that the number being shifted is 64-bit
|
||||
before the shift is done.
|
||||
|
||||
Fixes: CID 73684, CID 73695, CID 73764
|
||||
|
||||
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=302c12ff5714bc455949117c1c9548ccb324d55b]
|
||||
Signed-off-by: Marta Rybczynska <marta.rybczynska@huawei.com>
|
||||
---
|
||||
grub-core/fs/zfs/zfs.c | 8 ++++----
|
||||
1 file changed, 4 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c
|
||||
index 9087a72..b078ccc 100644
|
||||
--- a/grub-core/fs/zfs/zfs.c
|
||||
+++ b/grub-core/fs/zfs/zfs.c
|
||||
@@ -564,7 +564,7 @@ find_bestub (uberblock_phys_t * ub_array,
|
||||
ubptr = (uberblock_phys_t *) ((grub_properly_aligned_t *) ub_array
|
||||
+ ((i << ub_shift)
|
||||
/ sizeof (grub_properly_aligned_t)));
|
||||
- err = uberblock_verify (ubptr, offset, 1 << ub_shift);
|
||||
+ err = uberblock_verify (ubptr, offset, (grub_size_t) 1 << ub_shift);
|
||||
if (err)
|
||||
{
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
@@ -1543,7 +1543,7 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc,
|
||||
|
||||
high = grub_divmod64 ((offset >> desc->ashift) + c,
|
||||
desc->n_children, &devn);
|
||||
- csize = bsize << desc->ashift;
|
||||
+ csize = (grub_size_t) bsize << desc->ashift;
|
||||
if (csize > len)
|
||||
csize = len;
|
||||
|
||||
@@ -1635,8 +1635,8 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc,
|
||||
|
||||
while (len > 0)
|
||||
{
|
||||
- grub_size_t csize;
|
||||
- csize = ((s / (desc->n_children - desc->nparity))
|
||||
+ grub_size_t csize = s;
|
||||
+ csize = ((csize / (desc->n_children - desc->nparity))
|
||||
<< desc->ashift);
|
||||
if (csize > len)
|
||||
csize = len;
|
||||
@@ -69,6 +69,7 @@ SRC_URI = "${GNU_MIRROR}/grub/grub-${PV}.tar.gz \
|
||||
file://0020-hfsplus-Check-that-the-volume-name-length-is-valid.patch \
|
||||
file://0021-zfs-Fix-possible-negative-shift-operation.patch \
|
||||
file://0022-zfs-Fix-resource-leaks-while-constructing-path.patch \
|
||||
file://0023-zfs-Fix-possible-integer-overflows.patch \
|
||||
"
|
||||
SRC_URI[md5sum] = "5ce674ca6b2612d8939b9e6abed32934"
|
||||
SRC_URI[sha256sum] = "f10c85ae3e204dbaec39ae22fa3c5e99f0665417e91c2cb49b7e5031658ba6ea"
|
||||
|
||||
Reference in New Issue
Block a user