Skip to contentSkip to conversation

lib/relocator: Enforce GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT divisibility by 8

PATCH In review Daniel Kiper 2 participants 2 messages Jun 22, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/relocator: Enforce GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT divisibility by 8

Most of leftover code blindly assumes GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT divisibility by 8. So, enforce this at compile time.

---
 grub-core/lib/relocator.c | 2 ++
 1 file changed, 2 insertions(+)
grub-core/lib/relocator.c +2 -0
index 725bca7c3..568fc0b8f 100644
@@ -478,6 +478,8 @@ malloc_in_range (struct grub_relocator *rel,
 
 #if GRUB_RELOCATOR_HAVE_LEFTOVERS
   {
+    COMPILE_TIME_ASSERT (GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT % 8 == 0);
+
     struct grub_relocator_fw_leftover *cur;
     for (cur = leftovers; cur; cur = cur->next)
       {
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw

Le ven. 23 juin 2023, 00:08, Daniel Kiper <[email protected]> a écrit :

Quoted 26 lines

Most of leftover code blindly assumes GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT divisibility by 8. So, enforce this at compile time.

---
 grub-core/lib/relocator.c | 2 ++
 1 file changed, 2 insertions(+)
grub-core/lib/relocator.c +2 -1
index 725bca7c3..568fc0b8f 100644
@@ -478,6 +478,8 @@ malloc_in_range (struct grub_relocator *rel,
 
 #if GRUB_RELOCATOR_HAVE_LEFTOVERS
   {
+    COMPILE_TIME_ASSERT (GRUB_RELOCATOR_FIRMWARE_REQUESTS_QUANT % 8 == 0);
+
     struct grub_relocator_fw_leftover *cur;
     for (cur = leftovers; cur; cur = cur->next)
       {
--

2.11.0