162306a36Sopenharmony_ciWhat: /sys/kernel/security/evm 262306a36Sopenharmony_ciWhat: /sys/kernel/security/*/evm 362306a36Sopenharmony_ciDate: March 2011 462306a36Sopenharmony_ciContact: Mimi Zohar <zohar@us.ibm.com> 562306a36Sopenharmony_ciDescription: 662306a36Sopenharmony_ci EVM protects a file's security extended attributes(xattrs) 762306a36Sopenharmony_ci against integrity attacks. The initial method maintains an 862306a36Sopenharmony_ci HMAC-sha1 value across the extended attributes, storing the 962306a36Sopenharmony_ci value as the extended attribute 'security.evm'. 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci EVM supports two classes of security.evm. The first is 1262306a36Sopenharmony_ci an HMAC-sha1 generated locally with a 1362306a36Sopenharmony_ci trusted/encrypted key stored in the Kernel Key 1462306a36Sopenharmony_ci Retention System. The second is a digital signature 1562306a36Sopenharmony_ci generated either locally or remotely using an 1662306a36Sopenharmony_ci asymmetric key. These keys are loaded onto root's 1762306a36Sopenharmony_ci keyring using keyctl, and EVM is then enabled by 1862306a36Sopenharmony_ci echoing a value to <securityfs>/evm made up of the 1962306a36Sopenharmony_ci following bits: 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci === ================================================== 2262306a36Sopenharmony_ci Bit Effect 2362306a36Sopenharmony_ci === ================================================== 2462306a36Sopenharmony_ci 0 Enable HMAC validation and creation 2562306a36Sopenharmony_ci 1 Enable digital signature validation 2662306a36Sopenharmony_ci 2 Permit modification of EVM-protected metadata at 2762306a36Sopenharmony_ci runtime. Not supported if HMAC validation and 2862306a36Sopenharmony_ci creation is enabled (deprecated). 2962306a36Sopenharmony_ci 31 Disable further runtime modification of EVM policy 3062306a36Sopenharmony_ci === ================================================== 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci For example:: 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci echo 1 ><securityfs>/evm 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci will enable HMAC validation and creation 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci :: 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci echo 0x80000003 ><securityfs>/evm 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci will enable HMAC and digital signature validation and 4362306a36Sopenharmony_ci HMAC creation and disable all further modification of policy. 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci :: 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci echo 0x80000006 ><securityfs>/evm 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci will enable digital signature validation, permit 5062306a36Sopenharmony_ci modification of EVM-protected metadata and 5162306a36Sopenharmony_ci disable all further modification of policy. This option is now 5262306a36Sopenharmony_ci deprecated in favor of:: 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci echo 0x80000002 ><securityfs>/evm 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci as the outstanding issues that prevent the usage of EVM portable 5762306a36Sopenharmony_ci signatures have been solved. 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci Echoing a value is additive, the new value is added to the 6062306a36Sopenharmony_ci existing initialization flags. 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci For example, after:: 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci echo 2 ><securityfs>/evm 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci another echo can be performed:: 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci echo 1 ><securityfs>/evm 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci and the resulting value will be 3. 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci Note that once an HMAC key has been loaded, it will no longer 7362306a36Sopenharmony_ci be possible to enable metadata modification. Signaling that an 7462306a36Sopenharmony_ci HMAC key has been loaded will clear the corresponding flag. 7562306a36Sopenharmony_ci For example, if the current value is 6 (2 and 4 set):: 7662306a36Sopenharmony_ci 7762306a36Sopenharmony_ci echo 1 ><securityfs>/evm 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci will set the new value to 3 (4 cleared). 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci Loading an HMAC key is the only way to disable metadata 8262306a36Sopenharmony_ci modification. 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_ci Until key loading has been signaled EVM can not create 8562306a36Sopenharmony_ci or validate the 'security.evm' xattr, but returns 8662306a36Sopenharmony_ci INTEGRITY_UNKNOWN. Loading keys and signaling EVM 8762306a36Sopenharmony_ci should be done as early as possible. Normally this is 8862306a36Sopenharmony_ci done in the initramfs, which has already been measured 8962306a36Sopenharmony_ci as part of the trusted boot. For more information on 9062306a36Sopenharmony_ci creating and loading existing trusted/encrypted keys, 9162306a36Sopenharmony_ci refer to: 9262306a36Sopenharmony_ci Documentation/security/keys/trusted-encrypted.rst. Both 9362306a36Sopenharmony_ci dracut (via 97masterkey and 98integrity) and systemd (via 9462306a36Sopenharmony_ci core/ima-setup) have support for loading keys at boot 9562306a36Sopenharmony_ci time. 9662306a36Sopenharmony_ci 9762306a36Sopenharmony_ciWhat: /sys/kernel/security/*/evm/evm_xattrs 9862306a36Sopenharmony_ciDate: April 2018 9962306a36Sopenharmony_ciContact: Matthew Garrett <mjg59@google.com> 10062306a36Sopenharmony_ciDescription: 10162306a36Sopenharmony_ci Shows the set of extended attributes used to calculate or 10262306a36Sopenharmony_ci validate the EVM signature, and allows additional attributes 10362306a36Sopenharmony_ci to be added at runtime. Any signatures generated after 10462306a36Sopenharmony_ci additional attributes are added (and on files possessing those 10562306a36Sopenharmony_ci additional attributes) will only be valid if the same 10662306a36Sopenharmony_ci additional attributes are configured on system boot. Writing 10762306a36Sopenharmony_ci a single period (.) will lock the xattr list from any further 10862306a36Sopenharmony_ci modification. 109