提交 c3bd05c9 编写于 作者: R Roberto Sassu 提交者: Zheng Zengkai

ima: Add enforce-evm and log-evm modes to strictly check EVM status

hulk inclusion
category: feature
feature: IMA Digest Lists extension
bugzilla: 46797

-------------------------------------------------

IMA and EVM have been designed as two independent subsystems: the first for
checking the integrity of file data; the second for checking file metadata.
Making them independent allows users to adopt them incrementally.

The point of intersection is in IMA-Appraise, which calls evm_verifyxattr()
to ensure that security.ima wasn't modified during an offline attack. The
design choice, to ensure incremental adoption, was to continue appraisal
verification if evm_verifyxattr() returns INTEGRITY_UNKNOWN. This value is
returned when EVM is not enabled in the kernel configuration, or if the
HMAC key has not been loaded yet.

Although this choice appears legitimate, it might not be suitable for
hardened systems, where the administrator expects that access is denied if
there is any error. An attacker could intentionally delete the EVM keys
from the system and set the file digest in security.ima to the actual file
digest so that the final appraisal status is INTEGRITY_PASS.

This patch allows such hardened systems to strictly enforce an access
control policy based on the validity of signatures/HMACs, by introducing
two new values for the ima_appraise= kernel option: enforce-evm and
log-evm.

Cc: stable@vger.kernel.org
Fixes: 2fe5d6de ("ima: integrity appraisal extension")
Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
Signed-off-by: NTianxing Zhang <zhangtianxing3@huawei.com>
Reviewed-by: NJason Yan <yanaijie@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 86ff6456
...@@ -1733,7 +1733,8 @@ ...@@ -1733,7 +1733,8 @@
Set number of hash buckets for inode cache. Set number of hash buckets for inode cache.
ima_appraise= [IMA] appraise integrity measurements ima_appraise= [IMA] appraise integrity measurements
Format: { "off" | "enforce" | "fix" | "log" } Format: { "off" | "enforce" | "fix" | "log" |
"enforce-evm" | "log-evm" }
default: "enforce" default: "enforce"
ima_appraise_tcb [IMA] Deprecated. Use ima_policy= instead. ima_appraise_tcb [IMA] Deprecated. Use ima_policy= instead.
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "ima.h" #include "ima.h"
static bool ima_appraise_req_evm __ro_after_init;
static int __init default_appraise_setup(char *str) static int __init default_appraise_setup(char *str)
{ {
#ifdef CONFIG_IMA_APPRAISE_BOOTPARAM #ifdef CONFIG_IMA_APPRAISE_BOOTPARAM
...@@ -43,6 +44,9 @@ static int __init default_appraise_setup(char *str) ...@@ -43,6 +44,9 @@ static int __init default_appraise_setup(char *str)
ima_appraise = appraisal_state; ima_appraise = appraisal_state;
} }
#endif #endif
if (strcmp(str, "enforce-evm") == 0 ||
strcmp(str, "log-evm") == 0)
ima_appraise_req_evm = true;
return 1; return 1;
} }
...@@ -404,7 +408,11 @@ int ima_appraise_measurement(enum ima_hooks func, ...@@ -404,7 +408,11 @@ int ima_appraise_measurement(enum ima_hooks func,
switch (status) { switch (status) {
case INTEGRITY_PASS: case INTEGRITY_PASS:
case INTEGRITY_PASS_IMMUTABLE: case INTEGRITY_PASS_IMMUTABLE:
break;
case INTEGRITY_UNKNOWN: case INTEGRITY_UNKNOWN:
if (ima_appraise_req_evm &&
xattr_value->type != EVM_IMA_XATTR_DIGSIG)
goto out;
break; break;
case INTEGRITY_NOXATTRS: /* No EVM protected xattrs. */ case INTEGRITY_NOXATTRS: /* No EVM protected xattrs. */
/* It's fine not to have xattrs when using a modsig. */ /* It's fine not to have xattrs when using a modsig. */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册