Skip to contentSkip to conversation

ima: Use KEXEC_SIG_FORCE for rejecting unsigned kexec images

PATCH In review Chi Wang 2 participants 2 messages Apr 15

Subsystems (4)
lore
Share & tools
lore

Chi Wang

author
#0 lore raw

PATCH 1/1 ima: Use KEXEC_SIG_FORCE for rejecting unsigned kexec images

From: Chi Wang <[email protected]>

Following the split of KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE, only KEXEC_SIG_FORCE indicates that unsigned kernel images must be rejected. KEXEC_SIG alone enables signature verification but permits unsigned images, so it should not trigger the IMA appraisal denial for kexec_load.

Update the condition in ima_load_data() to check for KEXEC_SIG_FORCE instead of KEXEC_SIG.

Fixes 99d5cadfde2b ("kexec_file: split KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE")
---
 security/integrity/ima/ima_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/integrity/ima/ima_main.c +1 -1
index 1d6229b156fb..ec70e78ab8cd 100644
@@ -953,7 +953,7 @@ static int ima_load_data(enum kernel_load_data_id id, bool contents)
 
 	switch (id) {
 	case LOADING_KEXEC_IMAGE:
-		if (IS_ENABLED(CONFIG_KEXEC_SIG)
+		if (IS_ENABLED(CONFIG_KEXEC_SIG_FORCE)
 		    && arch_ima_get_secureboot()) {
 			pr_err("impossible to appraise a kernel image without a file descriptor; try using kexec_file_load syscall.\n");
 			return -EACCES;

--
2.25.1

maintainer
#1 lore raw
Quoted 7 lines · Chi Wang

From: Chi Wang <[email protected]>

Following the split of KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE, only KEXEC_SIG_FORCE indicates that unsigned kernel images must be rejected. KEXEC_SIG alone enables signature verification but permits unsigned images, so it should not trigger the IMA appraisal denial for kexec_load.

Quoted 6 lines

Update the condition in ima_load_data() to check for KEXEC_SIG_FORCE instead of KEXEC_SIG.

Fixes 99d5cadfde2b ("kexec_file: split KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE")

It isn't enough to check whether CONFIG_KEXEC_SIG_FORCE is configured, since it is possible to require the kexec kernel image to be signed at runtime. Based on the IMA policy, IMA will call set_kexec_sig_enforced() to require the kexec kernel image to be signed.

Mimi

Quoted 19 lines
---
 security/integrity/ima/ima_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
security/integrity/ima/ima_main.c +1 -2
index 1d6229b156fb..ec70e78ab8cd 100644
@@ -953,7 +953,7 @@ static int ima_load_data(enum kernel_load_data_id id, bool contents)
 
 	switch (id) {
 	case LOADING_KEXEC_IMAGE:
-		if (IS_ENABLED(CONFIG_KEXEC_SIG)
+		if (IS_ENABLED(CONFIG_KEXEC_SIG_FORCE)
 		    && arch_ima_get_secureboot()) {
 			pr_err("impossible to appraise a kernel image without a file descriptor; try using kexec_file_load syscall.\n");
 			return -EACCES;
--

2.25.1