Skip to content

Commit 6a515c2

Browse files
esnowbergsmb49
authored andcommitted
lockdown: Fix kexec lockdown bypass with ima policy
BugLink: https://bugs.launchpad.net/bugs/1988479 commit 543ce63b664e2c2f9533d089a4664b559c3e6b5b upstream. The lockdown LSM is primarily used in conjunction with UEFI Secure Boot. This LSM may also be used on machines without UEFI. It can also be enabled when UEFI Secure Boot is disabled. One of lockdown's features is to prevent kexec from loading untrusted kernels. Lockdown can be enabled through a bootparam or after the kernel has booted through securityfs. If IMA appraisal is used with the "ima_appraise=log" boot param, lockdown can be defeated with kexec on any machine when Secure Boot is disabled or unavailable. IMA prevents setting "ima_appraise=log" from the boot param when Secure Boot is enabled, but this does not cover cases where lockdown is used without Secure Boot. To defeat lockdown, boot without Secure Boot and add ima_appraise=log to the kernel command line; then: $ echo "integrity" > /sys/kernel/security/lockdown $ echo "appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig" > \ /sys/kernel/security/ima/policy $ kexec -ls unsigned-kernel Add a call to verify ima appraisal is set to "enforce" whenever lockdown is enabled. This fixes CVE-2022-21505. Cc: [email protected] Fixes: 29d3c1c ("kexec: Allow kexec_file() with appropriate IMA policy when locked down") Signed-off-by: Eric Snowberg <[email protected]> Acked-by: Mimi Zohar <[email protected]> Reviewed-by: John Haxby <[email protected]> Signed-off-by: Linus Torvalds <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent 9847287 commit 6a515c2

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

security/integrity/ima/ima_policy.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,6 +2052,10 @@ bool ima_appraise_signature(enum kernel_read_file_id id)
20522052
if (id >= READING_MAX_ID)
20532053
return false;
20542054

2055+
if (id == READING_KEXEC_IMAGE && !(ima_appraise & IMA_APPRAISE_ENFORCE)
2056+
&& security_locked_down(LOCKDOWN_KEXEC))
2057+
return false;
2058+
20552059
func = read_idmap[id] ?: FILE_CHECK;
20562060

20572061
rcu_read_lock();

0 commit comments

Comments
 (0)