第 24 章 Extending, customizing, and troubleshooting kernel integrity subsystem
Extend, customize, and troubleshoot the kernel integrity subsystem to support diverse security requirements and operational environments.
24.1. Generate good reference values for IMA appraisal 复制链接链接已复制到粘贴板!
Before you deploy an IMA policy that includes IMA-appraisal rules, ensure that all files governed by these rules have valid reference values stored in the security.ima extended attribute. If these reference values are missing, IMA might prevent the system from booting properly or deny access to files.
# ima-appraise-file </path/to/file>
Use IMA signatures as trusted reference values for immutable files to support integrity verification. This approach helps ensure that only files with valid signatures are accessed, which strengthens system security and compliance.
Prerequisites
- You have created an IMA policy that includes IMA-appraisal rules.
Procedure
Install the
rpm-plugin-ima:$ sudo dnf install rpm-plugin-ima -yqThis ensures that package files have IMA signature stored in
security.xattrautomatically during package installation, reinstallation, or upgradation.Reinstall all the packages:
$ sudo dnf reinstall "*" -yThis ensures that the
security.xattrextended attribute is updated for all packages.Enable the dracut integrity module so the official IMA code-signing key in
/etc/keys/imaloads automatically on boot:$ sudo dracut -f
Verification
Verify that signature is correctly stored in
security.imaextended attribute:$ # evmctl ima_verify -k /etc/keys/ima/redhatimarelease-10.der /usr/lib/systemd/systemd keyid d3320449 (from /etc/keys/ima/redhatimarelease-10.der) key 1: d3320449 /etc/keys/ima/redhatimarelease-10.der /usr/lib/systemd/systemd: verification is OK $ # evmctl ima_verify -k /etc/keys/ima/redhatimarelease-10.der /bin/bash keyid d3320449 (from /etc/keys/ima/redhatimarelease-10.der) key 1: d3320449 /etc/keys/ima/redhatimarelease-10.der /bin/bash: verification is OK ...
To maintain integrity for files that might change over time, generate and update reference values as needed. This ensures that the system accurately verifies the authenticity of mutable files and prevent unauthorized modifications.
Prerequisites
- You have root privileges on the system.
- You have created an IMA policy that includes IMA-appraisal rules.
- You have generated good reference values for IMA appraisal.
- Secure Boot is disabled.
Procedure
Optional: Enable your chosen IMA-appraisal policy or skip this step if you only use your custom policy. Take built-in
ima_policy=appraise_tcbas an example:# grubby --update-kernel=/boot/vmlinuz-$(uname -r) --args="ima_policy=appraise_tcb"Additionally for
s390xsystems:# zipl
Enable IMA-appraisal fix mode by adding the
ima_appraise=fixkernel command line parameter:# grubby --update-kernel=/boot/vmlinuz-$(uname -r) --args="ima_appraise=fix"Additionally for
s390xsystems:# zipl
Reboot the system:
# rebootOptional: Load your custom IMA policy:
# echo <path_to_your_custom_ima_policy> > /sys/kernel/security/ima/policyRe-label the whole system:
# find / -fstype xfs -type f -uid 0 -exec head -c 0 '{}' \;Turn off IMA-appraisal fix mode by removing the
ima_appraise=fixkernel command line parameter:# grubby --update-kernel=/boot/vmlinuz-$(uname -r) --remove-args="ima_appraise=fix"Additionally for
s390xsystems:# zipl
- Enable the secure boot if it is disabled.
Additional resources