|
|
9723a8 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
9723a8 |
From: Darren Kenny <darren.kenny@oracle.com>
|
|
|
9723a8 |
Date: Tue, 8 Dec 2020 22:17:04 +0000
|
|
|
9723a8 |
Subject: [PATCH] zfs: Fix possible integer overflows
|
|
|
9723a8 |
|
|
|
9723a8 |
In all cases the problem is that the value being acted upon by
|
|
|
9723a8 |
a left-shift is a 32-bit number which is then being used in the
|
|
|
9723a8 |
context of a 64-bit number.
|
|
|
9723a8 |
|
|
|
9723a8 |
To avoid overflow we ensure that the number being shifted is 64-bit
|
|
|
9723a8 |
before the shift is done.
|
|
|
9723a8 |
|
|
|
9723a8 |
Fixes: CID 73684, CID 73695, CID 73764
|
|
|
9723a8 |
|
|
|
9723a8 |
Signed-off-by: Darren Kenny <darren.kenny@oracle.com>
|
|
|
9723a8 |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
9723a8 |
---
|
|
|
9723a8 |
grub-core/fs/zfs/zfs.c | 8 ++++----
|
|
|
9723a8 |
1 file changed, 4 insertions(+), 4 deletions(-)
|
|
|
9723a8 |
|
|
|
9723a8 |
diff --git a/grub-core/fs/zfs/zfs.c b/grub-core/fs/zfs/zfs.c
|
|
|
b71686 |
index 44d8bde6b..0d8c08eec 100644
|
|
|
9723a8 |
--- a/grub-core/fs/zfs/zfs.c
|
|
|
9723a8 |
+++ b/grub-core/fs/zfs/zfs.c
|
|
|
9723a8 |
@@ -564,7 +564,7 @@ find_bestub (uberblock_phys_t * ub_array,
|
|
|
9723a8 |
ubptr = (uberblock_phys_t *) ((grub_properly_aligned_t *) ub_array
|
|
|
9723a8 |
+ ((i << ub_shift)
|
|
|
9723a8 |
/ sizeof (grub_properly_aligned_t)));
|
|
|
9723a8 |
- err = uberblock_verify (ubptr, offset, 1 << ub_shift);
|
|
|
9723a8 |
+ err = uberblock_verify (ubptr, offset, (grub_size_t) 1 << ub_shift);
|
|
|
9723a8 |
if (err)
|
|
|
9723a8 |
{
|
|
|
9723a8 |
grub_errno = GRUB_ERR_NONE;
|
|
|
9723a8 |
@@ -1543,7 +1543,7 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc,
|
|
|
9723a8 |
|
|
|
9723a8 |
high = grub_divmod64 ((offset >> desc->ashift) + c,
|
|
|
9723a8 |
desc->n_children, &devn);
|
|
|
9723a8 |
- csize = bsize << desc->ashift;
|
|
|
9723a8 |
+ csize = (grub_size_t) bsize << desc->ashift;
|
|
|
9723a8 |
if (csize > len)
|
|
|
9723a8 |
csize = len;
|
|
|
9723a8 |
|
|
|
9723a8 |
@@ -1635,8 +1635,8 @@ read_device (grub_uint64_t offset, struct grub_zfs_device_desc *desc,
|
|
|
9723a8 |
|
|
|
9723a8 |
while (len > 0)
|
|
|
9723a8 |
{
|
|
|
9723a8 |
- grub_size_t csize;
|
|
|
9723a8 |
- csize = ((s / (desc->n_children - desc->nparity))
|
|
|
9723a8 |
+ grub_size_t csize = s;
|
|
|
9723a8 |
+ csize = ((csize / (desc->n_children - desc->nparity))
|
|
|
9723a8 |
<< desc->ashift);
|
|
|
9723a8 |
if (csize > len)
|
|
|
9723a8 |
csize = len;
|