0001-secureboot.patch 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. From 505a0ba56061dd331e950bcd43fe2266972ccc96 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.47.1
  33. From 0494ea66d3d0a1de801409b6e9a60b12be6a254b 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 be010fec7654..cc6e7ae5786e 100644
  49. --- a/Documentation/admin-guide/kernel-parameters.txt
  50. +++ b/Documentation/admin-guide/kernel-parameters.txt
  51. @@ -3020,6 +3020,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 0a213f69a9e4..8e4f9dcc9f4c 100644
  64. --- a/kernel/power/hibernate.c
  65. +++ b/kernel/power/hibernate.c
  66. @@ -37,6 +37,7 @@
  67. #include "power.h"
  68. +static int lockdown_hibernate;
  69. static int nocompress;
  70. static int noresume;
  71. static int nohibernate;
  72. @@ -92,7 +93,7 @@ void hibernate_release(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. @@ -1422,6 +1423,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. @@ -1480,3 +1487,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.47.1