Skip to content

Commit 6d38ca0

Browse files
Dmitry KasatkinMimi Zohar
authored andcommitted
evm: evm_verify_hmac must not return INTEGRITY_UNKNOWN
If EVM is not supported or enabled, evm_verify_hmac() returns INTEGRITY_UNKNOWN, which ima_appraise_measurement() ignores and sets the appraisal status based solely on the security.ima verification. evm_verify_hmac() also returns INTEGRITY_UNKNOWN for other failures, such as temporary failures like -ENOMEM, resulting in possible attack vectors. This patch changes the default return code for temporary/unexpected failures, like -ENOMEM, from INTEGRITY_UNKNOWN to INTEGRITY_FAIL, making evm_verify_hmac() fail safe. As a result, failures need to be re-evaluated in order to catch both temporary errors, such as the -ENOMEM, as well as errors that have been resolved in fix mode. Signed-off-by: Dmitry Kasatkin <dmitry.kasatkin@nokia.com> Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
1 parent 2960e6c commit 6d38ca0

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

‎security/integrity/evm/evm_main.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,15 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
5656
struct evm_ima_xattr_data xattr_data;
5757
int rc;
5858

59-
if (iint->hmac_status != INTEGRITY_UNKNOWN)
59+
if (iint->hmac_status == INTEGRITY_PASS)
6060
return iint->hmac_status;
6161

62+
/* if status is not PASS, try to check again - against -ENOMEM */
63+
6264
rc = evm_calc_hmac(dentry, xattr_name, xattr_value,
6365
xattr_value_len, xattr_data.digest);
6466
if (rc < 0)
65-
return INTEGRITY_UNKNOWN;
67+
goto err_out;
6668

6769
xattr_data.type = EVM_XATTR_HMAC;
6870
rc = vfs_xattr_cmp(dentry, XATTR_NAME_EVM, (u8 *)&xattr_data,
@@ -77,11 +79,8 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry,
7779
case -ENODATA: /* file not labelled */
7880
iint->hmac_status = INTEGRITY_NOLABEL;
7981
break;
80-
case -EINVAL:
81-
iint->hmac_status = INTEGRITY_FAIL;
82-
break;
8382
default:
84-
iint->hmac_status = INTEGRITY_UNKNOWN;
83+
iint->hmac_status = INTEGRITY_FAIL;
8584
}
8685
return iint->hmac_status;
8786
}

0 commit comments

Comments
 (0)