grub2/0095-Fix-a-btrfs-read-before-init-bug.patch
Peter Jones 77d0810cf0 Fix tftp filename mangling and secure boot dmesg error.
Fix tftp filename mangling to not reuse the wrong variable
  Resolves: rhbz#1405208
Make grub2 initialize the kernel's boot_params structure correctly so the
  upstream SB code doesn't throw a fit.
  Resolves: rhbz#1418360
  Resolves: rhbz#1451071

Signed-off-by: Peter Jones <pjones@redhat.com>
2017-06-26 17:02:20 -04:00

39 lines
1.4 KiB
Diff

From de37bf80fed16a991a9218ca5fb73008f59cd689 Mon Sep 17 00:00:00 2001
From: Peter Jones <pjones@redhat.com>
Date: Mon, 26 Jun 2017 12:35:47 -0400
Subject: [PATCH 095/105] Fix a btrfs read-before-init bug
---
grub-core/fs/btrfs.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/grub-core/fs/btrfs.c b/grub-core/fs/btrfs.c
index 9cffa91fa..cb25b9ddd 100644
--- a/grub-core/fs/btrfs.c
+++ b/grub-core/fs/btrfs.c
@@ -232,10 +232,6 @@ read_sblock (grub_disk_t disk, struct grub_btrfs_superblock *sb)
for (i = 0; i < ARRAY_SIZE (superblock_sectors); i++)
{
struct grub_btrfs_superblock sblock;
- /* Don't try additional superblocks beyond device size. */
- if (i && (grub_le_to_cpu64 (sblock.this_device.size)
- >> GRUB_DISK_SECTOR_BITS) <= superblock_sectors[i])
- break;
err = grub_disk_read (disk, superblock_sectors[i], 0,
sizeof (sblock), &sblock);
if (err == GRUB_ERR_OUT_OF_RANGE)
@@ -247,6 +243,11 @@ read_sblock (grub_disk_t disk, struct grub_btrfs_superblock *sb)
if (i == 0 || grub_le_to_cpu64 (sblock.generation)
> grub_le_to_cpu64 (sb->generation))
grub_memcpy (sb, &sblock, sizeof (sblock));
+
+ /* Don't try additional superblocks beyond device size. */
+ if (i && (grub_le_to_cpu64 (sblock.this_device.size)
+ >> GRUB_DISK_SECTOR_BITS) <= superblock_sectors[i])
+ break;
}
if ((err == GRUB_ERR_OUT_OF_RANGE || !err) && i == 0)
--
2.13.0