All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] multiboot2: set min address for mbi allocation to 0x1000
@ 2019-12-16 10:15 Lukasz Hawrylko
  2019-12-16 10:54 ` Daniel Kiper
  0 siblings, 1 reply; 2+ messages in thread
From: Lukasz Hawrylko @ 2019-12-16 10:15 UTC (permalink / raw)
  To: grub-devel; +Cc: daniel.kiper, Lukasz Hawrylko

In some cases GRUB2 allocates multiboot2 structure at 0 address, that is
a confusing behavior. Consumers of that structure can have internal NULL-checks
that will throw an error when get a pointer to data allocated at address 0.
To prevent that, define min address for mbi allocation in x86 and x86_64
platforms.

Signed-off-by: Lukasz Hawrylko <lukasz.hawrylko@linux.intel.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
 grub-core/loader/multiboot_mbi2.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/grub-core/loader/multiboot_mbi2.c b/grub-core/loader/multiboot_mbi2.c
index 53da78615..18e766c7b 100644
--- a/grub-core/loader/multiboot_mbi2.c
+++ b/grub-core/loader/multiboot_mbi2.c
@@ -48,6 +48,12 @@
 #define HAS_VGA_TEXT 0
 #endif
 
+#if defined (__i386__) || defined (__x86_64__)
+#define MBI_MIN_ADDR 0x1000
+#else
+#define MBI_MIN_ADDR 0
+#endif
+
 struct module
 {
   struct module *next;
@@ -708,7 +714,7 @@ grub_multiboot2_make_mbi (grub_uint32_t *target)
   COMPILE_TIME_ASSERT (MULTIBOOT_TAG_ALIGN % sizeof (grub_properly_aligned_t) == 0);
 
   err = grub_relocator_alloc_chunk_align (grub_multiboot2_relocator, &ch,
-					  0, 0xffffffff - bufsize,
+					  MBI_MIN_ADDR, 0xffffffff - bufsize,
 					  bufsize, MULTIBOOT_TAG_ALIGN,
 					  GRUB_RELOCATOR_PREFERENCE_NONE, 1);
   if (err)
-- 
2.20.1



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

* Re: [PATCH v2] multiboot2: set min address for mbi allocation to 0x1000
  2019-12-16 10:15 [PATCH v2] multiboot2: set min address for mbi allocation to 0x1000 Lukasz Hawrylko
@ 2019-12-16 10:54 ` Daniel Kiper
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Kiper @ 2019-12-16 10:54 UTC (permalink / raw)
  To: Lukasz Hawrylko; +Cc: grub-devel

On Mon, Dec 16, 2019 at 11:15:55AM +0100, Lukasz Hawrylko wrote:
> In some cases GRUB2 allocates multiboot2 structure at 0 address, that is
> a confusing behavior. Consumers of that structure can have internal NULL-checks
> that will throw an error when get a pointer to data allocated at address 0.
> To prevent that, define min address for mbi allocation in x86 and x86_64
> platforms.
>
> Signed-off-by: Lukasz Hawrylko <lukasz.hawrylko@linux.intel.com>
> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

LGTM. If there are no objections I will commit it by the end of this week.

Thanks,

Daniel


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

end of thread, other threads:[~2019-12-16 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-16 10:15 [PATCH v2] multiboot2: set min address for mbi allocation to 0x1000 Lukasz Hawrylko
2019-12-16 10:54 ` 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.