0001-secureboot.patch 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. From 58aa22bec32223a605375d0aea0a961105ee3e50 Mon Sep 17 00:00:00 2001
  2. From: Maximilian Luz <luzmaximilian@gmail.com>
  3. Date: Sun, 9 Jun 2024 19:48:58 +0200
  4. Subject: [PATCH] Revert "efi/x86: Set the PE/COFF header's NX compat flag
  5. unconditionally"
  6. This reverts commit 891f8890a4a3663da7056542757022870b499bc1.
  7. Revert because of compatibility issues of MS Surface devices and GRUB
  8. with NX. In short, these devices get stuck on boot with NX advertised.
  9. So to not advertise it, add the respective option back in.
  10. Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
  11. Patchset: secureboot
  12. ---
  13. arch/x86/boot/header.S | 4 ++++
  14. 1 file changed, 4 insertions(+)
  15. diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
  16. index b5c79f43359b..a1bbedd989e4 100644
  17. --- a/arch/x86/boot/header.S
  18. +++ b/arch/x86/boot/header.S
  19. @@ -111,7 +111,11 @@ extra_header_fields:
  20. .long salign # SizeOfHeaders
  21. .long 0 # CheckSum
  22. .word IMAGE_SUBSYSTEM_EFI_APPLICATION # Subsystem (EFI application)
  23. +#ifdef CONFIG_EFI_DXE_MEM_ATTRIBUTES
  24. .word IMAGE_DLL_CHARACTERISTICS_NX_COMPAT # DllCharacteristics
  25. +#else
  26. + .word 0 # DllCharacteristics
  27. +#endif
  28. #ifdef CONFIG_X86_32
  29. .long 0 # SizeOfStackReserve
  30. .long 0 # SizeOfStackCommit
  31. --
  32. 2.50.0
  33. From ce1b44f9e408c1bc34413c8a4558df3770700340 Mon Sep 17 00:00:00 2001
  34. From: "J. Eduardo" <j.eduardo@gmail.com>
  35. Date: Sun, 25 Aug 2024 14:17:45 +0200
  36. Subject: [PATCH] PM: hibernate: Add a lockdown_hibernate parameter
  37. This allows the user to tell the kernel that they know better (namely,
  38. they secured their swap properly), and that it can enable hibernation.
  39. Signed-off-by: Kelvie Wong <kelvie@kelvie.ca>
  40. Link: https://github.com/linux-surface/kernel/pull/158
  41. Link: https://gist.github.com/brknkfr/95d1925ccdbb7a2d18947c168dfabbee
  42. Patchset: secureboot
  43. ---
  44. Documentation/admin-guide/kernel-parameters.txt | 5 +++++
  45. kernel/power/hibernate.c | 10 +++++++++-
  46. 2 files changed, 14 insertions(+), 1 deletion(-)
  47. diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
  48. index 8f75ec177399..b6c4edfc3c13 100644
  49. --- a/Documentation/admin-guide/kernel-parameters.txt
  50. +++ b/Documentation/admin-guide/kernel-parameters.txt
  51. @@ -3200,6 +3200,11 @@
  52. to extract confidential information from the kernel
  53. are also disabled.
  54. + lockdown_hibernate [HIBERNATION]
  55. + Enable hibernation even if lockdown is enabled. Enable this only if
  56. + your swap is encrypted and secured properly, as an attacker can
  57. + modify the kernel offline during hibernation.
  58. +
  59. locktorture.acq_writer_lim= [KNL]
  60. Set the time limit in jiffies for a lock
  61. acquisition. Acquisitions exceeding this limit
  62. diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
  63. index 5af9c7ee98cd..d52aa94e2fa2 100644
  64. --- a/kernel/power/hibernate.c
  65. +++ b/kernel/power/hibernate.c
  66. @@ -38,6 +38,7 @@
  67. #include "power.h"
  68. +static int lockdown_hibernate;
  69. static int nocompress;
  70. static int noresume;
  71. static int nohibernate;
  72. @@ -98,7 +99,7 @@ bool hibernation_in_progress(void)
  73. bool hibernation_available(void)
  74. {
  75. return nohibernate == 0 &&
  76. - !security_locked_down(LOCKDOWN_HIBERNATION) &&
  77. + (lockdown_hibernate || !security_locked_down(LOCKDOWN_HIBERNATION)) &&
  78. !secretmem_active() && !cxl_mem_active();
  79. }
  80. @@ -1440,6 +1441,12 @@ static int __init nohibernate_setup(char *str)
  81. return 1;
  82. }
  83. +static int __init lockdown_hibernate_setup(char *str)
  84. +{
  85. + lockdown_hibernate = 1;
  86. + return 1;
  87. +}
  88. +
  89. static const char * const comp_alg_enabled[] = {
  90. #if IS_ENABLED(CONFIG_CRYPTO_LZO)
  91. COMPRESSION_ALGO_LZO,
  92. @@ -1498,3 +1505,4 @@ __setup("hibernate=", hibernate_setup);
  93. __setup("resumewait", resumewait_setup);
  94. __setup("resumedelay=", resumedelay_setup);
  95. __setup("nohibernate", nohibernate_setup);
  96. +__setup("lockdown_hibernate", lockdown_hibernate_setup);
  97. --
  98. 2.50.0