All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: Fix block lists not being able to address to end of disk sometimes
@ 2020-11-23  9:27 Glenn Washburn
  2020-12-02 14:51 ` Daniel Kiper
  0 siblings, 1 reply; 2+ messages in thread
From: Glenn Washburn @ 2020-11-23  9:27 UTC (permalink / raw)
  To: grub-devel; +Cc: Daniel Kiper, Glenn Washburn

When checking if a block list goes past the end of the disk, make sure
the total size of the disk is in grub native sector sizes, otherwise there
will be blocks at the end of the disk unaccessible by block lists.

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 grub-core/kern/fs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c
index fb30da9f4..c698295bc 100644
--- a/grub-core/kern/fs.c
+++ b/grub-core/kern/fs.c
@@ -139,6 +139,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name)
   unsigned i;
   grub_disk_t disk = file->device->disk;
   struct grub_fs_block *blocks;
+  grub_size_t max_sectors;
 
   /* First, count the number of blocks.  */
   do
@@ -156,6 +157,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name)
     return 0;
 
   file->size = 0;
+  max_sectors = grub_disk_from_native_sector (disk, disk->total_sectors);
   p = (char *) name;
   for (i = 0; i < num; i++)
     {
@@ -181,7 +183,7 @@ grub_fs_blocklist_open (grub_file_t file, const char *name)
 	  goto fail;
 	}
 
-      if (disk->total_sectors < blocks[i].offset + blocks[i].length)
+      if (max_sectors < blocks[i].offset + blocks[i].length)
 	{
 	  grub_error (GRUB_ERR_BAD_FILENAME, "beyond the total sectors");
 	  goto fail;
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fs: Fix block lists not being able to address to end of disk sometimes
  2020-11-23  9:27 [PATCH] fs: Fix block lists not being able to address to end of disk sometimes Glenn Washburn
@ 2020-12-02 14:51 ` Daniel Kiper
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Kiper @ 2020-12-02 14:51 UTC (permalink / raw)
  To: Glenn Washburn; +Cc: grub-devel

On Mon, Nov 23, 2020 at 03:27:42AM -0600, Glenn Washburn wrote:
> When checking if a block list goes past the end of the disk, make sure
> the total size of the disk is in grub native sector sizes, otherwise there
> will be blocks at the end of the disk unaccessible by block lists.
>
> Signed-off-by: Glenn Washburn <development@efficientek.com>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-02 14:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-23  9:27 [PATCH] fs: Fix block lists not being able to address to end of disk sometimes Glenn Washburn
2020-12-02 14:51 ` Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.