diff options
author | Dmitry Kasatkin <dmitry.kasatkin@nokia.com> | 2011-05-06 04:34:14 -0400 |
---|---|---|
committer | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2011-07-18 12:29:48 -0400 |
commit | 6d38ca01c0c2d6c2e46ec1984db9ada6bad6ca26 (patch) | |
tree | 6084a84cd87d18c261d62dc816d48335ce602447 /security/integrity | |
parent | 2960e6cb5f7c662b8edb6b0d2edc72095b4f5672 (diff) |
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>
Diffstat (limited to 'security/integrity')
-rw-r--r-- | security/integrity/evm/evm_main.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c index 0fa8261c3655..bfe44dff61bb 100644 --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c | |||
@@ -56,13 +56,15 @@ static enum integrity_status evm_verify_hmac(struct dentry *dentry, | |||
56 | struct evm_ima_xattr_data xattr_data; | 56 | struct evm_ima_xattr_data xattr_data; |
57 | int rc; | 57 | int rc; |
58 | 58 | ||
59 | if (iint->hmac_status != INTEGRITY_UNKNOWN) | 59 | if (iint->hmac_status == INTEGRITY_PASS) |
60 | return iint->hmac_status; | 60 | return iint->hmac_status; |
61 | 61 | ||
62 | /* if status is not PASS, try to check again - against -ENOMEM */ | ||
63 | |||
62 | rc = evm_calc_hmac(dentry, xattr_name, xattr_value, | 64 | rc = evm_calc_hmac(dentry, xattr_name, xattr_value, |
63 | xattr_value_len, xattr_data.digest); | 65 | xattr_value_len, xattr_data.digest); |
64 | if (rc < 0) | 66 | if (rc < 0) |
65 | return INTEGRITY_UNKNOWN; | 67 | goto err_out; |
66 | 68 | ||
67 | xattr_data.type = EVM_XATTR_HMAC; | 69 | xattr_data.type = EVM_XATTR_HMAC; |
68 | rc = vfs_xattr_cmp(dentry, XATTR_NAME_EVM, (u8 *)&xattr_data, | 70 | rc = vfs_xattr_cmp(dentry, XATTR_NAME_EVM, (u8 *)&xattr_data, |
@@ -77,11 +79,8 @@ err_out: | |||
77 | case -ENODATA: /* file not labelled */ | 79 | case -ENODATA: /* file not labelled */ |
78 | iint->hmac_status = INTEGRITY_NOLABEL; | 80 | iint->hmac_status = INTEGRITY_NOLABEL; |
79 | break; | 81 | break; |
80 | case -EINVAL: | ||
81 | iint->hmac_status = INTEGRITY_FAIL; | ||
82 | break; | ||
83 | default: | 82 | default: |
84 | iint->hmac_status = INTEGRITY_UNKNOWN; | 83 | iint->hmac_status = INTEGRITY_FAIL; |
85 | } | 84 | } |
86 | return iint->hmac_status; | 85 | return iint->hmac_status; |
87 | } | 86 | } |