mirror of
https://src.fedoraproject.org/rpms/grub2.git
synced 2024-11-24 06:22:43 +00:00
Fix disk sector size computation
Signed-off-by: Robbie Harwood <rharwood@redhat.com>
This commit is contained in:
parent
63b29f783e
commit
b86fd390b8
3 changed files with 75 additions and 1 deletions
|
@ -0,0 +1,70 @@
|
|||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Mukesh Kumar Chaurasiya <mchauras@linux.vnet.ibm.com>
|
||||
Date: Thu, 9 Feb 2023 13:09:16 +0530
|
||||
Subject: [PATCH] osdep/linux/hostdisk: Modify sector by sysfs as disk sector
|
||||
|
||||
The disk sector size provided by sysfs file system considers the sector
|
||||
size of 512 irrespective of disk sector size, thus causing the read by
|
||||
the GRUB to an incorrect offset from what was originally intended.
|
||||
|
||||
Considering the 512 sector size of sysfs data the actual sector needs to
|
||||
be modified corresponding to disk sector size.
|
||||
|
||||
Signed-off-by: Mukesh Kumar Chaurasiya <mchauras@linux.vnet.ibm.com>
|
||||
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
||||
(cherry picked from commit f7564844f82b57078d601befadc438b5bc1fa01b)
|
||||
---
|
||||
grub-core/osdep/linux/hostdisk.c | 7 ++++---
|
||||
include/grub/disk.h | 7 +++++++
|
||||
2 files changed, 11 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/grub-core/osdep/linux/hostdisk.c b/grub-core/osdep/linux/hostdisk.c
|
||||
index 7bc99ac1c1..a9ea0bb465 100644
|
||||
--- a/grub-core/osdep/linux/hostdisk.c
|
||||
+++ b/grub-core/osdep/linux/hostdisk.c
|
||||
@@ -240,7 +240,8 @@ have_devfs (void)
|
||||
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
||||
|
||||
static int
|
||||
-grub_hostdisk_linux_find_partition (char *dev, grub_disk_addr_t sector)
|
||||
+grub_hostdisk_linux_find_partition (const grub_disk_t disk, char *dev,
|
||||
+ grub_disk_addr_t sector)
|
||||
{
|
||||
size_t len = strlen (dev);
|
||||
const char *format;
|
||||
@@ -305,7 +306,7 @@ grub_hostdisk_linux_find_partition (char *dev, grub_disk_addr_t sector)
|
||||
if (fstat (fd, &st) < 0
|
||||
|| !grub_util_device_is_mapped_stat (&st)
|
||||
|| !grub_util_get_dm_node_linear_info (st.st_rdev, 0, 0, &start))
|
||||
- start = grub_util_find_partition_start_os (real_dev);
|
||||
+ start = grub_disk_to_native_sector (disk, grub_util_find_partition_start_os (real_dev));
|
||||
/* We don't care about errors here. */
|
||||
grub_errno = GRUB_ERR_NONE;
|
||||
|
||||
@@ -386,7 +387,7 @@ grub_util_fd_open_device (const grub_disk_t disk, grub_disk_addr_t sector, int f
|
||||
&& strncmp (dev, "/dev/", 5) == 0)
|
||||
{
|
||||
if (sector >= part_start)
|
||||
- is_partition = grub_hostdisk_linux_find_partition (dev, part_start);
|
||||
+ is_partition = grub_hostdisk_linux_find_partition (disk, dev, part_start);
|
||||
else
|
||||
*max = part_start - sector;
|
||||
}
|
||||
diff --git a/include/grub/disk.h b/include/grub/disk.h
|
||||
index 06210a7049..881addcc77 100644
|
||||
--- a/include/grub/disk.h
|
||||
+++ b/include/grub/disk.h
|
||||
@@ -208,6 +208,13 @@ grub_disk_from_native_sector (grub_disk_t disk, grub_disk_addr_t sector)
|
||||
return sector << (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
|
||||
}
|
||||
|
||||
+/* Convert from GRUB native disk sized sector to disk sized sector. */
|
||||
+static inline grub_disk_addr_t
|
||||
+grub_disk_to_native_sector (grub_disk_t disk, grub_disk_addr_t sector)
|
||||
+{
|
||||
+ return sector >> (disk->log_sector_size - GRUB_DISK_SECTOR_BITS);
|
||||
+}
|
||||
+
|
||||
/* This is called from the memory manager. */
|
||||
void grub_disk_cache_invalidate_all (void);
|
||||
|
|
@ -316,3 +316,4 @@ Patch0315: 0315-ieee1275-support-runtime-memory-claiming.patch
|
|||
Patch0316: 0316-ieee1275-implement-vec5-for-cas-negotiation.patch
|
||||
Patch0317: 0317-ibmvtpm-Add-support-for-trusted-boot-using-a-vTPM-2..patch
|
||||
Patch0318: 0318-powerpc-Drop-Open-Hack-Ware.patch
|
||||
Patch0319: 0319-osdep-linux-hostdisk-Modify-sector-by-sysfs-as-disk-.patch
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
Name: grub2
|
||||
Epoch: 1
|
||||
Version: 2.06
|
||||
Release: 86%{?dist}
|
||||
Release: 87%{?dist}
|
||||
Summary: Bootloader with support for Linux, Multiboot and more
|
||||
License: GPLv3+
|
||||
URL: http://www.gnu.org/software/grub/
|
||||
|
@ -544,6 +544,9 @@ mv ${EFI_HOME}/grub.cfg.stb ${EFI_HOME}/grub.cfg
|
|||
%endif
|
||||
|
||||
%changelog
|
||||
* Thu Feb 16 2023 Robbie Harwood <rharwood@redhat.com> - 2.06-87
|
||||
- Fix disk sector size computation
|
||||
|
||||
* Fri Feb 10 2023 Robbie Harwood <rharwood@redhat.com> - 2.06-86
|
||||
- Override the linker and force nonexecutable stacks
|
||||
|
||||
|
|
Loading…
Reference in a new issue