Skip to content

Commit 47add87

Browse files
stefanbergermimizohar
authored andcommitted
evm: Enforce signatures on unsupported filesystem for EVM_INIT_X509
Unsupported filesystems currently do not enforce any signatures. Add support for signature enforcement of the "original" and "portable & immutable" signatures when EVM_INIT_X509 is enabled. The "original" signature type contains filesystem specific metadata. Thus it cannot be copied up and verified. However with EVM_INIT_X509 and EVM_ALLOW_METADATA_WRITES enabled, the "original" file signature may be written. When EVM_ALLOW_METADATA_WRITES is not set or once it is removed from /sys/kernel/security/evm by setting EVM_INIT_HMAC for example, it is not possible to write or remove xattrs on the overlay filesystem. This change still prevents EVM from writing HMAC signatures on unsupported filesystem when EVM_INIT_HMAC is enabled. Co-developed-by: Mimi Zohar <[email protected]> Signed-off-by: Stefan Berger <[email protected]> Signed-off-by: Mimi Zohar <[email protected]>
1 parent cd9b909 commit 47add87

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

security/integrity/evm/evm_main.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
192192
iint->evm_status == INTEGRITY_PASS_IMMUTABLE))
193193
return iint->evm_status;
194194

195-
if (is_unsupported_fs(dentry))
195+
/*
196+
* On unsupported filesystems without EVM_INIT_X509 enabled, skip
197+
* signature verification.
198+
*/
199+
if (!(evm_initialized & EVM_INIT_X509) && is_unsupported_fs(dentry))
196200
return INTEGRITY_UNKNOWN;
197201

198202
/* if status is not PASS, try to check again - against -ENOMEM */
@@ -261,7 +265,8 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
261265
evm_status = INTEGRITY_PASS_IMMUTABLE;
262266
} else if (!IS_RDONLY(inode) &&
263267
!(inode->i_sb->s_readonly_remount) &&
264-
!IS_IMMUTABLE(inode)) {
268+
!IS_IMMUTABLE(inode) &&
269+
!is_unsupported_fs(dentry)) {
265270
evm_update_evmxattr(dentry, xattr_name,
266271
xattr_value,
267272
xattr_value_len);
@@ -419,9 +424,6 @@ enum integrity_status evm_verifyxattr(struct dentry *dentry,
419424
if (!evm_key_loaded() || !evm_protected_xattr(xattr_name))
420425
return INTEGRITY_UNKNOWN;
421426

422-
if (is_unsupported_fs(dentry))
423-
return INTEGRITY_UNKNOWN;
424-
425427
return evm_verify_hmac(dentry, xattr_name, xattr_value,
426428
xattr_value_len);
427429
}

0 commit comments

Comments
 (0)