2013-09-12 15:29:56 +00:00
|
|
|
|
From 29c89e27805f7a6a22bce11ed9bb430e19c972a9 Mon Sep 17 00:00:00 2001
|
|
|
|
|
From: Colin Watson <cjwatson@ubuntu.com>
|
|
|
|
|
Date: Tue, 23 Oct 2012 10:40:49 -0400
|
|
|
|
|
Subject: [PATCH 449/482] Don't allow insmod when secure boot is enabled.
|
2012-11-28 09:34:03 +00:00
|
|
|
|
|
|
|
|
|
References: fate#314485
|
|
|
|
|
Patch-Mainline: no
|
|
|
|
|
|
2021-07-08 09:03:14 +00:00
|
|
|
|
v2:
|
|
|
|
|
Use grub_efi_get_secureboot to get secure boot status
|
|
|
|
|
|
2012-11-28 09:34:03 +00:00
|
|
|
|
Signed-off-by: Michael Chang <mchang@suse.com>
|
|
|
|
|
---
|
2013-09-12 15:29:56 +00:00
|
|
|
|
grub-core/kern/dl.c | 17 +++++++++++++++++
|
2012-11-28 09:34:03 +00:00
|
|
|
|
grub-core/kern/efi/efi.c | 28 ++++++++++++++++++++++++++++
|
|
|
|
|
include/grub/efi/efi.h | 1 +
|
2013-09-12 15:29:56 +00:00
|
|
|
|
3 files changed, 46 insertions(+)
|
2012-11-28 09:34:03 +00:00
|
|
|
|
|
2021-07-08 09:03:14 +00:00
|
|
|
|
Index: grub-2.04/grub-core/kern/dl.c
|
2012-11-28 09:34:03 +00:00
|
|
|
|
===================================================================
|
2021-07-08 09:03:14 +00:00
|
|
|
|
--- grub-2.04.orig/grub-core/kern/dl.c
|
|
|
|
|
+++ grub-2.04/grub-core/kern/dl.c
|
2014-01-06 03:50:43 +00:00
|
|
|
|
@@ -38,6 +38,10 @@
|
|
|
|
|
#define GRUB_MODULES_MACHINE_READONLY
|
2013-09-12 15:29:56 +00:00
|
|
|
|
#endif
|
2012-11-28 09:34:03 +00:00
|
|
|
|
|
|
|
|
|
+#ifdef GRUB_MACHINE_EFI
|
2021-07-08 09:03:14 +00:00
|
|
|
|
+#include <grub/efi/sb.h>
|
2012-11-28 09:34:03 +00:00
|
|
|
|
+#endif
|
|
|
|
|
+
|
2013-09-12 15:29:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wcast-align"
|
2019-10-18 10:18:53 +00:00
|
|
|
|
@@ -688,6 +692,19 @@ grub_dl_load_file (const char *filename)
|
2014-01-06 03:50:43 +00:00
|
|
|
|
|
|
|
|
|
grub_boot_time ("Loading module %s", filename);
|
2012-11-28 09:34:03 +00:00
|
|
|
|
|
|
|
|
|
+#ifdef GRUB_MACHINE_EFI
|
2021-07-08 09:03:14 +00:00
|
|
|
|
+ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED)
|
2013-09-12 15:29:56 +00:00
|
|
|
|
+ {
|
|
|
|
|
+#if 0
|
|
|
|
|
+ /* This is an error, but grub2-mkconfig still generates a pile of
|
|
|
|
|
+ * insmod commands, so emitting it would be mostly just obnoxious. */
|
|
|
|
|
+ grub_error (GRUB_ERR_ACCESS_DENIED,
|
|
|
|
|
+ "Secure Boot forbids loading module from %s", filename);
|
|
|
|
|
+#endif
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
2012-11-28 09:34:03 +00:00
|
|
|
|
+#endif
|
|
|
|
|
+
|
2019-10-18 10:18:53 +00:00
|
|
|
|
file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE);
|
2013-09-12 15:29:56 +00:00
|
|
|
|
if (! file)
|
|
|
|
|
return 0;
|