Skip to content

Commit 4c1408f

Browse files
jeduardoqzed
authored andcommitted
PM: hibernate: Add a lockdown_hibernate parameter
This allows the user to tell the kernel that they know better (namely, they secured their swap properly), and that it can enable hibernation. Signed-off-by: Kelvie Wong <[email protected]> Link: #158 Link: https://gist.github.com/brknkfr/95d1925ccdbb7a2d18947c168dfabbee Patchset: secureboot
1 parent 021ec07 commit 4c1408f

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Documentation/admin-guide/kernel-parameters.txt

+5
Original file line numberDiff line numberDiff line change
@@ -3154,6 +3154,11 @@
31543154
to extract confidential information from the kernel
31553155
are also disabled.
31563156

3157+
lockdown_hibernate [HIBERNATION]
3158+
Enable hibernation even if lockdown is enabled. Enable this only if
3159+
your swap is encrypted and secured properly, as an attacker can
3160+
modify the kernel offline during hibernation.
3161+
31573162
locktorture.acq_writer_lim= [KNL]
31583163
Set the time limit in jiffies for a lock
31593164
acquisition. Acquisitions exceeding this limit

kernel/power/hibernate.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "power.h"
3838

3939

40+
static int lockdown_hibernate;
4041
static int nocompress;
4142
static int noresume;
4243
static int nohibernate;
@@ -92,7 +93,7 @@ void hibernate_release(void)
9293
bool hibernation_available(void)
9394
{
9495
return nohibernate == 0 &&
95-
!security_locked_down(LOCKDOWN_HIBERNATION) &&
96+
(lockdown_hibernate || !security_locked_down(LOCKDOWN_HIBERNATION)) &&
9697
!secretmem_active() && !cxl_mem_active();
9798
}
9899

@@ -1434,6 +1435,12 @@ static int __init nohibernate_setup(char *str)
14341435
return 1;
14351436
}
14361437

1438+
static int __init lockdown_hibernate_setup(char *str)
1439+
{
1440+
lockdown_hibernate = 1;
1441+
return 1;
1442+
}
1443+
14371444
static const char * const comp_alg_enabled[] = {
14381445
#if IS_ENABLED(CONFIG_CRYPTO_LZO)
14391446
COMPRESSION_ALGO_LZO,
@@ -1492,3 +1499,4 @@ __setup("hibernate=", hibernate_setup);
14921499
__setup("resumewait", resumewait_setup);
14931500
__setup("resumedelay=", resumedelay_setup);
14941501
__setup("nohibernate", nohibernate_setup);
1502+
__setup("lockdown_hibernate", lockdown_hibernate_setup);

0 commit comments

Comments
 (0)