tmp_suning_uos_patched/security/integrity/ima
Eric Snowberg ab5050fd74 lockdown: Fix kexec lockdown bypass with ima policy
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: stable@vger.kernel.org
Fixes: 29d3c1c8df ("kexec: Allow kexec_file() with appropriate IMA policy when locked down")
Signed-off-by: Eric Snowberg <eric.snowberg@oracle.com>
Acked-by: Mimi Zohar <zohar@linux.ibm.com>
Reviewed-by: John Haxby <john.haxby@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-29 17:19:06 +02:00
..
ima_api.c ima: Support additional conditionals in the KEXEC_CMDLINE hook function 2020-07-20 13:28:16 -04:00
ima_appraise.c ima: Fix a potential integer overflow in ima_appraise_measurement 2022-07-21 21:20:04 +02:00
ima_asymmetric_keys.c ima: Support additional conditionals in the KEXEC_CMDLINE hook function 2020-07-20 13:28:16 -04:00
ima_crypto.c ima: Fix potential memory leak in ima_init_crypto() 2022-07-21 21:20:11 +02:00
ima_fs.c ima: Remove ima_policy file before directory 2022-02-16 12:54:16 +01:00
ima_init.c ima: Call ima_calc_boot_aggregate() in ima_eventdigest_init() 2020-06-03 17:20:43 -04:00
ima_kexec.c ima: Free IMA measurement buffer after kexec syscall 2021-03-04 11:37:50 +01:00
ima_main.c integrity-v5.10 2020-10-15 15:58:18 -07:00
ima_modsig.c ima: Move comprehensive rule validation checks out of the token parser 2020-07-20 13:28:15 -04:00
ima_mok.c IMA: remove -Wmissing-prototypes warning 2021-09-15 09:50:48 +02:00
ima_policy.c lockdown: Fix kexec lockdown bypass with ima policy 2022-07-29 17:19:06 +02:00
ima_queue_keys.c ima: Support additional conditionals in the KEXEC_CMDLINE hook function 2020-07-20 13:28:16 -04:00
ima_queue.c ima: Remove semicolon at the end of ima_get_binary_runtime_size() 2020-09-15 13:47:41 -04:00
ima_template_lib.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
ima_template_lib.h Replace HTTP links with HTTPS ones: security 2020-08-06 12:00:05 -07:00
ima_template.c ima: Allow template selection with ima_template[_fmt]= after ima_hash= 2022-02-16 12:54:16 +01:00
ima.h ima: Replace zero-length array with flexible-array member 2020-10-29 17:22:59 -05:00
Kconfig ima: remove the IMA_TEMPLATE Kconfig option 2022-06-09 10:21:25 +02:00
Makefile IMA: Update KBUILD_MODNAME for IMA files to ima 2020-02-28 14:32:58 -05:00