Skip to contentSkip to conversation

verifiers: fix calling uninitialized function pointer

PATCH In review Michael Chang 3 participants 3 messages Feb 18, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 verifiers: fix calling uninitialized function pointer

The necessary check for null before use of function ver->close is not taking place in the failure path. This patch simply adds the missing check and fixes the problem that grub hangs indefinitely after booting rogue image without valid signature if secure boot turned on.

Now it displays like this for booting rogue uefi image.

error: bad shim signature
error: you need to load the kernel first

Press any key to continue...

and then you can go back to boot menu by pressing any key or after a few seconds expired.

---
 grub-core/commands/verifiers.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
grub-core/commands/verifiers.c +2 -1
index 0dde48182..7b9297cd3 100644
@@ -196,7 +196,8 @@ grub_verifiers_open (grub_file_t io, enum grub_file_type type)
   return ret;
 
  fail:
-  ver->close (context);
+  if (ver->close)
+    ver->close (context);
  fail_noclose:
   verified_free (verified);
   grub_free (ret);
Signature · 1 line
2.16.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Michael Chang

The necessary check for null before use of function ver->close is not taking place in the failure path. This patch simply adds the missing check and fixes the problem that grub hangs indefinitely after booting rogue image without valid signature if secure boot turned on.

Now it displays like this for booting rogue uefi image.

error: bad shim signature
error: you need to load the kernel first

Quoted 7 lines

Press any key to continue...

and then you can go back to boot menu by pressing any key or after a few seconds expired.

---

Best regards,
Javier

Reviewed-by
#2 lore raw
Quoted 13 lines · Javier Martinez Canillas
Quoted 12 lines · Michael Chang

The necessary check for null before use of function ver->close is not taking place in the failure path. This patch simply adds the missing check and fixes the problem that grub hangs indefinitely after booting rogue image without valid signature if secure boot turned on.

Now it displays like this for booting rogue uefi image.

error: bad shim signature
error: you need to load the kernel first

Press any key to continue...

Quoted 7 lines
Quoted 5 lines

and then you can go back to boot menu by pressing any key or after a few seconds expired.

---

Thanks,

Daniel