2013-09-12 17:29:56 +02: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 10:34:03 +01:00
|
|
|
|
|
|
|
|
|
References: fate#314485
|
|
|
|
|
Patch-Mainline: no
|
|
|
|
|
|
2021-07-08 11:03:14 +02:00
|
|
|
|
v2:
|
|
|
|
|
Use grub_efi_get_secureboot to get secure boot status
|
|
|
|
|
|
2012-11-28 10:34:03 +01:00
|
|
|
|
Signed-off-by: Michael Chang <mchang@suse.com>
|
|
|
|
|
---
|
2013-09-12 17:29:56 +02:00
|
|
|
|
grub-core/kern/dl.c | 17 +++++++++++++++++
|
2012-11-28 10:34:03 +01:00
|
|
|
|
grub-core/kern/efi/efi.c | 28 ++++++++++++++++++++++++++++
|
|
|
|
|
include/grub/efi/efi.h | 1 +
|
2013-09-12 17:29:56 +02:00
|
|
|
|
3 files changed, 46 insertions(+)
|
2012-11-28 10:34:03 +01:00
|
|
|
|
|
2023-08-24 05:25:56 +02:00
|
|
|
|
--- a/grub-core/kern/dl.c
|
|
|
|
|
+++ b/grub-core/kern/dl.c
|
2014-01-06 04:50:43 +01:00
|
|
|
|
@@ -38,6 +38,10 @@
|
|
|
|
|
#define GRUB_MODULES_MACHINE_READONLY
|
2013-09-12 17:29:56 +02:00
|
|
|
|
#endif
|
2012-11-28 10:34:03 +01:00
|
|
|
|
|
|
|
|
|
+#ifdef GRUB_MACHINE_EFI
|
2021-07-08 11:03:14 +02:00
|
|
|
|
+#include <grub/efi/sb.h>
|
2012-11-28 10:34:03 +01:00
|
|
|
|
+#endif
|
|
|
|
|
+
|
2013-09-12 17:29:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wcast-align"
|
2023-08-24 05:25:56 +02:00
|
|
|
|
@@ -708,6 +712,19 @@
|
2014-01-06 04:50:43 +01:00
|
|
|
|
|
|
|
|
|
grub_boot_time ("Loading module %s", filename);
|
2012-11-28 10:34:03 +01:00
|
|
|
|
|
|
|
|
|
+#ifdef GRUB_MACHINE_EFI
|
2021-07-08 11:03:14 +02:00
|
|
|
|
+ if (grub_efi_get_secureboot () == GRUB_EFI_SECUREBOOT_MODE_ENABLED)
|
2013-09-12 17:29:56 +02: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 10:34:03 +01:00
|
|
|
|
+#endif
|
|
|
|
|
+
|
2019-10-18 12:18:53 +02:00
|
|
|
|
file = grub_file_open (filename, GRUB_FILE_TYPE_GRUB_MODULE);
|
2013-09-12 17:29:56 +02:00
|
|
|
|
if (! file)
|
|
|
|
|
return 0;
|