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

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