~psusi/ubuntu/saucy/grub2/fix-dmraid

« back to all changes in this revision

Viewing changes to debian/patches/ubuntu_no_insmod_on_sb.patch

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2013-01-03 11:40:44 UTC
  • mfrom: (17.6.31 experimental)
  • Revision ID: package-import@ubuntu.com-20130103114044-et8gar9lol415wc9
Tags: 2.00-10ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Adjust for default Ubuntu boot options ("quiet splash").
  - Default to hiding the menu; holding down Shift at boot will show it.
  - Set a monochromatic theme and an appropriate background for Ubuntu.
  - Apply Ubuntu GRUB Legacy changes to legacy update-grub script.
  - Fix backslash-escaping in merge_debconf_into_conf.
  - Remove "GNU/Linux" from default distributor string.
  - Add crashkernel option.
  - Bypass menu unless other OSes are installed or Shift is pressed.
  - Allow Shift to interrupt 'sleep --interruptible'.
  - Reduce visual clutter in normal mode.
  - Remove verbose messages printed before reading configuration.
  - Suppress kernel/initrd progress messages, except in recovery mode.
  - Show the boot menu if the previous boot failed.
  - Adjust upgrade version checks for Ubuntu.
  - Suppress "GRUB loading" message unless Shift is held down.
  - Adjust versions of grub-doc and grub-legacy-doc conflicts.
  - Build-depend on qemu-kvm rather than qemu-system for grub-pc tests.
  - Check hardware support before using gfxpayload=keep.
  - Set vt.handoff=7 for smooth handoff to kernel graphical mode.
  - In recovery mode, add nomodeset to the Linux kernel arguments, and
    remove the 'set gfxpayload=keep' command.
  - Skip Windows os-prober entries on Wubi systems, and suppress the menu
    by default if those are the only other-OS entries.
  - Handle probing striped DM-RAID devices.
  - Replace 'single' by 'recovery' when friendly-recovery is installed.
  - Disable cursor as early as possible in grub_main.
  - Apply patch from Fedora to add a "linuxefi" loader.
  - Automatically call linuxefi from linux when necessary.
  - On amd64, add raw-uefi custom upload tarballs for signing.
  - Generate configuration for signed UEFI kernels if available.
  - Install signed images if UEFI Secure Boot is enabled.
  - Output a menu entry for firmware setup on UEFI FastBoot systems.
  - Stop using the /usr/share/images/desktop-base/desktop-grub.png
    alternative as the fallback background.
  - If the postinst is running in a container, skip grub-install and all
    its associated questions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
Description: Don't permit loading modules on UEFI secure boot
2
 
Author: Matthew Garrett <mjg@redhat.com>
3
 
Author: Colin Watson <cjwatson@ubuntu.com>
4
 
Origin: vendor, http://pkgs.fedoraproject.org/cgit/grub2.git/tree/grub-2.00-no-insmod-on-sb.patch
5
 
Forwarded: no
6
 
Last-Update: 2012-09-19
7
 
 
8
 
Index: b/grub-core/kern/dl.c
9
 
===================================================================
10
 
--- a/grub-core/kern/dl.c
11
 
+++ b/grub-core/kern/dl.c
12
 
@@ -42,6 +42,10 @@
13
 
 #include <sys/mman.h>
14
 
 #endif
15
 
 
16
 
+#ifdef GRUB_MACHINE_EFI
17
 
+#include <grub/efi/efi.h>
18
 
+#endif
19
 
+
20
 
 
21
 
 
22
 
 #pragma GCC diagnostic ignored "-Wcast-align"
23
 
@@ -668,6 +672,15 @@
24
 
   void *core = 0;
25
 
   grub_dl_t mod = 0;
26
 
 
27
 
+#ifdef GRUB_MACHINE_EFI
28
 
+  if (grub_efi_secure_boot ())
29
 
+    {
30
 
+      grub_error (GRUB_ERR_ACCESS_DENIED,
31
 
+                 "Secure Boot forbids loading module from %s", filename);
32
 
+      return 0;
33
 
+    }
34
 
+#endif
35
 
+
36
 
   file = grub_file_open (filename);
37
 
   if (! file)
38
 
     return 0;
39
 
Index: b/grub-core/kern/efi/efi.c
40
 
===================================================================
41
 
--- a/grub-core/kern/efi/efi.c
42
 
+++ b/grub-core/kern/efi/efi.c
43
 
@@ -259,6 +259,34 @@
44
 
   return NULL;
45
 
 }
46
 
 
47
 
+grub_efi_boolean_t
48
 
+grub_efi_secure_boot (void)
49
 
+{
50
 
+  grub_efi_guid_t efi_var_guid = GRUB_EFI_GLOBAL_VARIABLE_GUID;
51
 
+  grub_size_t datasize;
52
 
+  char *secure_boot = NULL;
53
 
+  char *setup_mode = NULL;
54
 
+  grub_efi_boolean_t ret = 0;
55
 
+
56
 
+  secure_boot = grub_efi_get_variable("SecureBoot", &efi_var_guid, &datasize);
57
 
+
58
 
+  if (datasize != 1 || !secure_boot)
59
 
+    goto out;
60
 
+
61
 
+  setup_mode = grub_efi_get_variable("SetupMode", &efi_var_guid, &datasize);
62
 
+
63
 
+  if (datasize != 1 || !setup_mode)
64
 
+    goto out;
65
 
+
66
 
+  if (*secure_boot && !*setup_mode)
67
 
+    ret = 1;
68
 
+
69
 
+ out:
70
 
+  grub_free (secure_boot);
71
 
+  grub_free (setup_mode);
72
 
+  return ret;
73
 
+}
74
 
+
75
 
 #pragma GCC diagnostic ignored "-Wcast-align"
76
 
 
77
 
 /* Search the mods section from the PE32/PE32+ image. This code uses
78
 
Index: b/include/grub/efi/efi.h
79
 
===================================================================
80
 
--- a/include/grub/efi/efi.h
81
 
+++ b/include/grub/efi/efi.h
82
 
@@ -69,6 +69,7 @@
83
 
                                     const grub_efi_guid_t *guid,
84
 
                                     void *data,
85
 
                                     grub_size_t datasize);
86
 
+grub_efi_boolean_t EXPORT_FUNC (grub_efi_secure_boot) (void);
87
 
 int
88
 
 EXPORT_FUNC (grub_efi_compare_device_paths) (const grub_efi_device_path_t *dp1,
89
 
                                             const grub_efi_device_path_t *dp2);