Blame SOURCES/0407-zfs-Fix-possible-integer-overflows.patch

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