]> Git Repo - linux.git/commitdiff
evm: check hash algorithm passed to init_desc()
authorRoberto Sassu <[email protected]>
Wed, 29 May 2019 13:30:33 +0000 (15:30 +0200)
committerMimi Zohar <[email protected]>
Thu, 30 May 2019 03:18:25 +0000 (23:18 -0400)
This patch prevents memory access beyond the evm_tfm array by checking the
validity of the index (hash algorithm) passed to init_desc(). The hash
algorithm can be arbitrarily set if the security.ima xattr type is not
EVM_XATTR_HMAC.

Fixes: 5feeb61183dde ("evm: Allow non-SHA1 digital signatures")
Signed-off-by: Roberto Sassu <[email protected]>
Cc: [email protected]
Signed-off-by: Mimi Zohar <[email protected]>
security/integrity/evm/evm_crypto.c

index e11564eb645bb7a8c6c46593576fe2d8d0f5389d..82a38e801ee43072530798c1d4b0a75f47e00f03 100644 (file)
@@ -89,6 +89,9 @@ static struct shash_desc *init_desc(char type, uint8_t hash_algo)
                tfm = &hmac_tfm;
                algo = evm_hmac;
        } else {
+               if (hash_algo >= HASH_ALGO__LAST)
+                       return ERR_PTR(-EINVAL);
+
                tfm = &evm_tfm[hash_algo];
                algo = hash_algo_name[hash_algo];
        }
This page took 0.052558 seconds and 4 git commands to generate.